unity easyar2019-11-10

unity easyar2019-11-10_第1张图片
三张图片在Resource里面streamAsssets里面也要有
unity easyar2019-11-10_第2张图片
ar配key多图识别

视频音频资源直接拖拽到plane或者cube上面,刚开始没添加音频组件,声音放不出来。

unity easyar2019-11-10_第3张图片
音视频

button切换场景(吐槽都在注释里了,不知道怎么实时预览....):

using System.Collections.Generic;
using UnityEngine;

public class main : MonoBehaviour
{
    public Texture2D mainMenuBG;

    // Use this for initialization
    void Start()
    {

    }

    // Update is called once per frame
    void OnGUI()
    {  
        GUIStyle fontStyle = new GUIStyle(); //更多操作等你发现
        fontStyle.alignment = TextAnchor.MiddleCenter;//居中???
        fontStyle.fontSize = 50;//设置文字大小
 
        GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), mainMenuBG, ScaleMode.StretchToFill);
        if (GUI.Button(new Rect(Screen.width - 680, 1000,300, 200), "欢迎进入天猫双十一!点击文字进入",fontStyle ))
            //这里太坑了,前两个参数是左上角坐标,后两个是长和宽,小伙伴1000以内加减法都要算哭了。各种语言就不能统一吗?
        {
            //切换场景,加载关卡之类
            Application.LoadLevel("workone");
        }
        
        
    }
}




碰撞器:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class bighouse : MonoBehaviour {
   

    public  void  Show()
    {

        gameObject.SetActive(true);
        Debug.Log("show函数");
    }

    void Hide()
    {
        gameObject.SetActive(false); 

    }
    public void Update()
    {
        
        if (boom.flag == true)
        {
            Hide();
            Debug.Log("看不到我,hide,true");
        }

    }



}





using UnityEngine;
using System.Collections;

public class boom : MonoBehaviour
{

    public static bool flag=true;
    public bighouse big1;
    public bighouse big2;
    private GameObject  house;


    void OnTriggerEnter(Collider other)
    {

        flag = false;
        
        Destroy(this.gameObject);  // 摧毁陨石
        Destroy(other.gameObject); // 摧毁子弹
        Debug.Log("盖楼了");
        
        Debug.Log("flag=false");
        big1.Show();
        big2.Show();

    }

}

unity easyar2019-11-10_第4张图片
你品!!!

unity easyar2019-11-10_第5张图片
你细品!!!

最终预览:

unity easyar2019-11-10_第6张图片
为了button居中花了好久时间
扫天猫图片出视频
扫第一个草地
扫第二个草地
两个小房子碰撞器,boom!大房子

你可能感兴趣的:(unity easyar2019-11-10)