protected virtual void SetupGrabMechanic() { switch (grabMechanic) { case GrabMechanic.TrackObject: controlGrabAttach = controlInteractableObject.gameObject.AddComponent <VRTK_TrackObjectGrabAttach>(); break; case GrabMechanic.RotatorTrack: controlGrabAttach = controlInteractableObject.gameObject.AddComponent <VRTK_RotatorTrackGrabAttach>(); break; } SetGrabMechanicParameters(); controlInteractableObject.grabAttachMechanicScript = controlGrabAttach; }
/* Initial Setup */ private void Awake() { this.gameObject.layer = LayerMask.NameToLayer("Mass"); this.gameObject.tag = "Mass"; io = this.GetComponent <VRTK_InteractableObject>(); grabAttach = this.GetComponent <VRTK_TrackObjectGrabAttach>(); secGrabAction = this.GetComponent <VRTK_SwapControllerGrabAction>(); highlighter = this.GetComponent <VRTK_InteractObjectHighlighter>(); setupIO(); setupGrabAttach(); setupHighlighter(); setupNetworking(); }
protected virtual void SetupGrabMechanic() { controlGrabAttach = controlInteractableObject.gameObject.AddComponent <VRTK_TrackObjectGrabAttach>(); SetGrabMechanicParameters(); controlInteractableObject.grabAttachMechanicScript = controlGrabAttach; }
private void generate_spheres() { for (int i = sphere_offset; i < sphere_offset + 450; i++) { if (i >= 2448) { m_dropdownList.Sort(); DropDownList.AddOptions(m_dropdownList); return; } //generate spheres according to coord in csv file GameObject sp = GameObject.CreatePrimitive(PrimitiveType.Sphere); sp.transform.parent = transform; sp.transform.position = new Vector3(float.Parse(CSVManager.GetRowList()[i].X), float.Parse(CSVManager.GetRowList()[i].Y), float.Parse(CSVManager.GetRowList()[i].Z)); sp.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f); sp.name = CSVManager.GetRowList()[i].Description; sp.tag = "Sphere"; spheres.Add(sp); //disable shadow MeshRenderer mr = sp.GetComponent(typeof(MeshRenderer)) as MeshRenderer; mr.shadowCastingMode = ShadowCastingMode.Off; //enable sphere collider isTrigger SphereCollider sc = sp.GetComponent(typeof(SphereCollider)) as SphereCollider; sc.isTrigger = false; //add Rigidbody component Rigidbody rb = sp.AddComponent(typeof(Rigidbody)) as Rigidbody; rb.useGravity = false; rb.isKinematic = true; //add VRTK component VRTK_InteractableObject io = sp.AddComponent(typeof(VRTK_InteractableObject)) as VRTK_InteractableObject; VRTK_TrackObjectGrabAttach toga = sp.AddComponent(typeof(VRTK_TrackObjectGrabAttach)) as VRTK_TrackObjectGrabAttach; VRTK_SwapControllerGrabAction scga = sp.AddComponent(typeof(VRTK_SwapControllerGrabAction)) as VRTK_SwapControllerGrabAction; VRTK_InteractHaptics ih = sp.AddComponent(typeof(VRTK_InteractHaptics)) as VRTK_InteractHaptics; io.holdButtonToGrab = false; io.isGrabbable = true; io.touchHighlightColor = Color.yellow; io.grabAttachMechanicScript = toga; //set detach distance toga.detachDistance = 5.0f; //use precision grab toga.precisionGrab = true; io.secondaryGrabActionScript = scga; //show the label in HUD when touched TouchedInput ti = sp.AddComponent(typeof(TouchedInput)) as TouchedInput; ti.input = labelInput; ti.label = CSVManager.GetRowList()[i].Description; ti.sp = sp; ti.labelList = labelList; ti.input_dropdown = DropDownList; ti.m_dropdownList = m_dropdownList; //add connectSphere component ConnectSpheres cs = sp.AddComponent(typeof(ConnectSpheres)) as ConnectSpheres; cs.spheres = spheres; //Add the label to the dropdown list m_dropdownList.Add(CSVManager.GetRowList()[i].Description); } m_dropdownList.Sort(); DropDownList.AddOptions(m_dropdownList); }