コード例 #1
0
 private void AttemptSetGrabMechanic()
 {
     if (isGrabbable && grabAttachMechanicScript == null)
     {
         var setGrabMechanic = GetComponent <VRTK_BaseGrabAttach>();
         if (!setGrabMechanic)
         {
             setGrabMechanic = gameObject.AddComponent <VRTK_FixedJointGrabAttach>();
         }
         grabAttachMechanicScript = setGrabMechanic;
     }
 }
コード例 #2
0
ファイル: VRTK_ObjectSetup.cs プロジェクト: emmacp/test2
        private void SetupPrimaryGrab(VRTK_InteractableObject givenObject)
        {
            VRTK_BaseGrabAttach grab = givenObject.GetComponentInChildren <VRTK_BaseGrabAttach>();

            if (grab != null)
            {
                DestroyImmediate(grab);
            }
            switch (primGrab)
            {
            case PrimaryGrab.ChildOfController:
                grab = givenObject.gameObject.AddComponent <VRTK_ChildOfControllerGrabAttach>();
                break;

            case PrimaryGrab.FixedJoint:
                grab = givenObject.gameObject.AddComponent <VRTK_FixedJointGrabAttach>();
                break;

            case PrimaryGrab.Climbable:
                grab = givenObject.gameObject.AddComponent <VRTK_ClimbableGrabAttach>();
                break;

            case PrimaryGrab.CustomJoint:
                grab = givenObject.gameObject.AddComponent <VRTK_CustomJointGrabAttach>();
                break;

            case PrimaryGrab.RotatorTrack:
                grab = givenObject.gameObject.AddComponent <VRTK_RotatorTrackGrabAttach>();
                break;

            case PrimaryGrab.SpringJoint:
                grab = givenObject.gameObject.AddComponent <VRTK_SpringJointGrabAttach>();
                break;

            case PrimaryGrab.TrackObject:
                grab = givenObject.gameObject.AddComponent <VRTK_TrackObjectGrabAttach>();
                break;

            default:
                grab = givenObject.gameObject.AddComponent <VRTK_ChildOfControllerGrabAttach>();
                break;
            }
            givenObject.grabAttachMechanicScript = grab;
        }
コード例 #3
0
ファイル: VRTK_ObjectSetup.cs プロジェクト: 20kyler00/VRGAME
        private void SetupObject()
        {
            Transform[] transforms = Selection.transforms;
            foreach (Transform transform in transforms)
            {
                GameObject go = transform.gameObject;
                VRTK_InteractableObject intObj = go.GetComponent <VRTK_InteractableObject>();
                if (intObj == null)
                {
                    intObj = go.AddComponent <VRTK_InteractableObject>();
                }
                intObj.touchHighlightColor = touchColor;
                intObj.isGrabbable         = useGrab;
                intObj.holdButtonToGrab    = holdGrab;
                intObj.isUsable            = useUse;
                intObj.disableWhenIdle     = disableIdle;
                intObj.grabOverrideButton  = VRTK_ControllerEvents.ButtonAlias.Undefined;
                intObj.useOverrideButton   = VRTK_ControllerEvents.ButtonAlias.Undefined;
                VRTK_BaseGrabAttach grab = go.GetComponent <VRTK_BaseGrabAttach>();
                if (grab != null)
                {
                    DestroyImmediate(grab);
                }
                switch (primGrab)
                {
                case PrimaryGrab.ChildOfController:
                    grab = go.AddComponent <VRTK_ChildOfControllerGrabAttach>();
                    break;

                case PrimaryGrab.FixedJoint:
                    grab = go.AddComponent <VRTK_FixedJointGrabAttach>();
                    break;

                case PrimaryGrab.Climbable:
                    grab = go.AddComponent <VRTK_ClimbableGrabAttach>();
                    break;

                case PrimaryGrab.CustomJoint:
                    grab = go.AddComponent <VRTK_CustomJointGrabAttach>();
                    break;

                case PrimaryGrab.RotatorTrack:
                    grab = go.AddComponent <VRTK_RotatorTrackGrabAttach>();
                    break;

                case PrimaryGrab.SpringJoint:
                    grab = go.AddComponent <VRTK_SpringJointGrabAttach>();
                    break;

                case PrimaryGrab.TrackObject:
                    grab = go.AddComponent <VRTK_TrackObjectGrabAttach>();
                    break;

                default:
                    grab = go.AddComponent <VRTK_ChildOfControllerGrabAttach>();
                    break;
                }
                intObj.grabAttachMechanicScript = grab;
                VRTK_BaseGrabAction grab2 = go.GetComponent <VRTK_BaseGrabAction>();
                if (grab2 != null)
                {
                    DestroyImmediate(grab2);
                }
                switch (secGrab)
                {
                case SecondaryGrab.SwapControllers:
                    grab2 = go.AddComponent <VRTK_SwapControllerGrabAction>();
                    break;

                case SecondaryGrab.ControlDirection:
                    grab2 = go.AddComponent <VRTK_ControlDirectionGrabAction>();
                    break;

                case SecondaryGrab.AxisScale:
                    grab2 = go.AddComponent <VRTK_AxisScaleGrabAction>();
                    break;

                default:
                    grab2 = go.AddComponent <VRTK_SwapControllerGrabAction>();
                    break;
                }
                intObj.secondaryGrabActionScript = grab2;
                if (addrb)
                {
                    Rigidbody rb = go.GetComponent <Rigidbody>();
                    if (rb == null)
                    {
                        go.AddComponent <Rigidbody>();
                    }
                }
                if (addHaptics)
                {
                    VRTK_InteractHaptics haptics = go.GetComponent <VRTK_InteractHaptics>();
                    if (haptics == null)
                    {
                        go.AddComponent <VRTK_InteractHaptics>();
                    }
                }
            }
        }