// Use this for initialization void Start() { orientationFixNode = transform.Find("OrientationFix").gameObject; controllerReticle = transform.Find("Reticle").gameObject; laserPointer = GetComponent <BELaserPointer>(); lineRenderer = GetComponent <LineRenderer>(); laserVisual = GetComponent <GvrLaserVisual>(); beUnity = BridgeEngineUnity.main; if (beUnity) { beUnity.onControllerDidConnect.AddListener(OnConnectionChanged); beUnity.onControllerDidDisconnect.AddListener(OnConnectionChanged); beUnity.onControllerMotionEvent.AddListener(OnMotionEvent); beUnity.onControllerButtonEvent.AddListener(OnButtonEvent); beUnity.onControllerTouchEvent.AddListener(OnTouchEvent); } appButton = transform.Find("OrientationFix/AppButton"); appButtonMaterial = appButton.GetComponent <MeshRenderer>().material; homeButton = transform.Find("OrientationFix/HomeButton"); homeButtonMaterial = homeButton.GetComponent <MeshRenderer>().material; trigger = transform.Find("OrientationFix/Trigger"); triggerButtonMaterial = trigger.GetComponent <MeshRenderer>().material; touch = transform.Find("OrientationFix/TrackPad/Touch"); touchButtonMaterial = touch.GetComponent <MeshRenderer>().material; OnConnectionChanged(); }
public void Setup() { GameObject laserObj = new GameObject(); laserObj.AddComponent <LineRenderer>(); laserVisual = ComponentHelpers.AddComponentInvokeLifecycle <GvrLaserVisual>(laserObj); laserVisual.lerpThreshold = 0.0f; pointer = ComponentHelpers.AddComponentInvokeLifecycle <GvrLaserPointer>(laserObj); pointer.raycastMode = GvrBasePointer.RaycastMode.Direct; pointer.maxPointerDistance = MAX_RETICLE_DISTANCE; pointer.defaultReticleDistance = MAX_RETICLE_DISTANCE; ComponentHelpers.CallStart(pointer); reticle = new GameObject(); laserVisual.Reticle = reticle.transform; raycastResult.worldPosition = CLOSE_HIT_POS; raycastResult.distance = CLOSE_HIT_POS.z; }
private void SetPropertiesForVisual(bool shrinkLaser, float maxLaserDistance) { foreach (Object obj in serializedObject.targetObjects) { GvrLaserVisual laserVisual = (obj as MonoBehaviour).GetComponent <GvrLaserVisual>(); if (laserVisual != null) { SerializedObject serializedLaserVisual = new SerializedObject(laserVisual); SerializedProperty serializedShrinkLaser = serializedLaserVisual.FindProperty(GvrLaserVisualEditor.SHRINK_LASER_PROP_NAME); serializedShrinkLaser.boolValue = shrinkLaser; SerializedProperty serializedMaxLaserDistance = serializedLaserVisual.FindProperty(GvrLaserVisualEditor.MAX_LASER_DISTANCE_PROP_NAME); serializedMaxLaserDistance.floatValue = maxLaserDistance; serializedLaserVisual.ApplyModifiedProperties(); } } }