Unity如何深入使用Vuforia
发表于2018-01-05
Vuforia 是被广泛使用的 AR 开发平台,面对如此有用的Vuforia,本文就重点突出实现如下功能:
普通游戏 —–> AR
具体如下:
点击按钮后,调用的方法
public void kaiShiShiBie01(){ arcam.SetActive (true); //开启AR相机 maincam.SetActive (false); //关掉主相机 btn.gameObject.SetActive (false); //按钮也关掉 }
DefaultTrackableEventHandler.cs
private void OnTrackingFound() //发现目标就调用,注意发现后只会执行一次 { Renderer[] rendererComponents = GetComponentsInChildren<Renderer>(true); Collider[] colliderComponents = GetComponentsInChildren<Collider>(true); // Enable rendering: foreach (Renderer component in rendererComponents) { component.enabled = true; } // Enable colliders: foreach (Collider component in colliderComponents) { component.enabled = true; } // Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " found"); //注意这里,参考下面截图 //haitao.instance.found1 (); } private void OnTrackingLost() //目标跟踪丢失,就调用一次 { Renderer[] rendererComponents = GetComponentsInChildren<Renderer>(true); Collider[] colliderComponents = GetComponentsInChildren<Collider>(true); // Disable rendering: foreach (Renderer component in rendererComponents) { component.enabled = false; } // Disable colliders: foreach (Collider component in colliderComponents) { component.enabled = false; } Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " lost"); }