private void Update() { //Rotate the controller object slightly. if (rotationAxis.sqrMagnitude > 0f) { float degrees = 360f / secondsPerRevolution * Time.deltaTime; skin.transform.Rotate(rotationAxis, degrees, Space.World); Mesh mesh = skin.GetFirstControllerMesh(); if (mesh) { Vector3 center = mesh.bounds.center; skin.transform.localPosition = -(skin.transform.localRotation * center); } } }
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); } } }