private void Reset() { if (intCtrl == null) { intCtrl = GetComponent <InteractionXRController>(); } if (intCtrl != null && intHand == null && this.transform.parent != null) { intHand = this.transform.parent.GetChildren().Query() .Select(t => t.GetComponent <InteractionHand>()) .Where(h => h != null) .FirstOrDefault(h => h.isLeft == intCtrl.isLeft); } }
void Start() { currentId = 0; currentObj = null; originalPosition = Vector3.zero; halfWayPosition = Vector3.zero; originalRotation = new Quaternion(); holder = new GameObject(); holder.transform.parent = this.transform; //holder.transform.localPosition = Vector3.zero; holder.transform.localPosition = new Vector3(0.0f, 0f, -0.1f); holder.transform.localRotation = Quaternion.Euler(45.0f, 45.0f, 0f); //holder.transform.localPosition = (holder.transform.forward.normalized * 0.05f); projectileCalc = GetComponent <ProjectileCalculator>(); if (controller) { interact = controller.GetComponent <InteractionXRController>(); } if (debugLine) { Color c1 = Color.blue; Color c2 = Color.blue; LineRenderer lineRenderer = gameObject.AddComponent <LineRenderer>(); lineRenderer.material = new Material(Shader.Find("Sprites/Default")); lineRenderer.startWidth = thickness; lineRenderer.endWidth = thickness; lineRenderer.positionCount = 2; // A simple 2 color gradient with a fixed alpha of 1.0f. float alpha = 1.0f; Gradient gradient = new Gradient(); gradient.SetKeys( new GradientColorKey[] { new GradientColorKey(c1, 0.0f), new GradientColorKey(c2, 1.0f) }, new GradientAlphaKey[] { new GradientAlphaKey(alpha, 0.0f), new GradientAlphaKey(alpha, 1.0f) } ); lineRenderer.colorGradient = gradient; } }
/// <summary> /// Call this at the start of an Interaction engine test with the name of a stage /// object and the name of a rig object to load those objects and fill utility /// parameters such as manager, leftHand, box0, etc. for testing. /// </summary> protected void InitTest(string rigObjName, string stageObjName) { // Load test rig objects. base.InitTest(rigObjName); rigObj = testObj; recording = rigObj.GetComponentInChildren <PlayableDirector>(); provider = rigObj.GetComponentInChildren <LeapProvider>(); manager = rigObj.GetComponentInChildren <InteractionManager>(); foreach (var controller in manager.interactionControllers) { if (controller.intHand != null && controller.isLeft) { leftHand = controller.intHand; continue; } if (controller.intHand != null && !controller.isLeft) { rightHand = controller.intHand; continue; } var vrController = controller as InteractionXRController; if (vrController != null && vrController.isLeft) { leftVRController = vrController; continue; } if (vrController != null && !vrController.isLeft) { rightVRController = vrController; continue; } } // Load stage objects. stageObj = LoadObject(stageObjName); var intObjs = Pool <List <InteractionBehaviour> > .Spawn(); try { stageObj.GetComponentsInChildren <InteractionBehaviour>(true, intObjs); // Load "simple box" interaction objects. foreach (var simpleBoxObj in intObjs .Query() .Where(o => o.primaryHoverColliders.Count == 1 && o.primaryHoverColliders[0] is BoxCollider && !o.ignoreContact && !o.ignoreGrasping)) { if (box0 == null) { box0 = simpleBoxObj; continue; } if (box1 == null) { box1 = simpleBoxObj; continue; } if (box2 == null) { box2 = simpleBoxObj; continue; } } foreach (var interactionButtonObj in intObjs.Query() .Where(o => o is InteractionButton)) { if (button == null) { button = interactionButtonObj as InteractionButton; } } } finally { intObjs.Clear(); Pool <List <InteractionBehaviour> > .Recycle(intObjs); } }