public void Awake() { //if (!controllerTracker) Debug.LogError(gameObject + " controllerTracker value not set."); skin = GetComponentInChildren <SetControllerSkin>(); if (!skin) { skin = gameObject.AddComponent <SetControllerSkin>(); } skin.checkDeviceIndexEachUpdate = false; if (deviceIndex != -1) { SetDeviceIndex(deviceIndex); } //Make sure we have a collider. Collider collider = GetComponent <Collider>(); if (!collider) { collider = gameObject.AddComponent <SphereCollider>(); ((SphereCollider)collider).radius = 0.15f; } collider.isTrigger = true; if (!labelText) { labelText = GetComponentInChildren <TextMesh>(); } }
public void Update() { //Draw the primary hand controller on the inside. SetControllerSkin skin = PrimaryHandSwitcher.primaryHandObject.GetComponentInChildren <SetControllerSkin>(); if (skin != null) { Mesh mesh = skin.GetFirstControllerMesh(); if (mesh) { Quaternion drawrot = Quaternion.LookRotation(zedManager.transform.position - transform.position, Vector3.up); Vector3 drawpos = transform.position - drawrot * mesh.bounds.center; controllerDrawMat.SetPass(0); Graphics.DrawMesh(mesh, drawpos, drawrot, controllerDrawMat, CameraAnchor.HIDE_FROM_ZED_LAYER); } } }