Beispiel #1
0
        // Token: 0x06001216 RID: 4630 RVA: 0x00068528 File Offset: 0x00066728
        protected virtual void SetSnapDropZoneJoint(Rigidbody snapTo)
        {
            Joint component = base.GetComponent <Joint>();

            if (component == null)
            {
                VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_FROM_GAMEOBJECT, new object[]
                {
                    "SnapDropZone:" + base.name,
                    "Joint",
                    "the same",
                    " because the `Snap Type` is set to `Use Joint`"
                }));
                return;
            }
            if (snapTo == null)
            {
                VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_FROM_GAMEOBJECT, new object[]
                {
                    "VRTK_SnapDropZone",
                    "Rigidbody",
                    "the `VRTK_InteractableObject`"
                }));
                return;
            }
            component.connectedBody          = snapTo;
            this.originalJointCollisionState = component.enableCollision;
            component.enableCollision        = true;
        }
Beispiel #2
0
        // Token: 0x06001140 RID: 4416 RVA: 0x00064FE4 File Offset: 0x000631E4
        public virtual void UpdateEventsManager()
        {
            VRTK_InteractableObject componentInParent = base.transform.GetComponentInParent <VRTK_InteractableObject>();

            if (componentInParent == null)
            {
                VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_NOT_INJECTED, new object[]
                {
                    "VRTK_IndependentRadialMenuController",
                    "VRTK_InteractableObject",
                    "eventsManager",
                    "the parent"
                }));
                return;
            }
            if (componentInParent != this.eventsManager)
            {
                if (this.eventsManager != null)
                {
                    this.OnDisable();
                }
                this.eventsManager = componentInParent;
                this.OnEnable();
                Object.Destroy(this.menuCollider);
                this.Initialize();
            }
        }
Beispiel #3
0
 protected virtual void CreateTouchCollider()
 {
     if (customColliderContainer == null)
     {
         if (!defaultColliderPrefab)
         {
             VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.SDK_OBJECT_NOT_FOUND, "default collider prefab", "Controller SDK"));
             return;
         }
         controllerCollisionDetector = Instantiate(defaultColliderPrefab, transform.position, transform.rotation) as GameObject;
         controllerCollisionDetector.transform.SetParent(transform);
         controllerCollisionDetector.transform.localScale = transform.localScale;
         controllerCollisionDetector.name = VRTK_SharedMethods.GenerateVRTKObjectName(true, "Controller", "CollidersContainer");
         destroyColliderOnDisable         = true;
     }
     else
     {
         if (CustomRigidBodyIsChild())
         {
             controllerCollisionDetector = customColliderContainer;
             destroyColliderOnDisable    = false;
         }
         else
         {
             controllerCollisionDetector = Instantiate(customColliderContainer, transform.position, transform.rotation) as GameObject;
             controllerCollisionDetector.transform.SetParent(transform);
             controllerCollisionDetector.transform.localScale = transform.localScale;
             destroyColliderOnDisable = true;
         }
     }
     controllerCollisionDetector.AddComponent <VRTK_PlayerObject>().objectType = VRTK_PlayerObject.ObjectTypes.Collider;
 }
        /// <summary>
        /// The UpdateEventsManager method is used to update the events within the menu controller.
        /// </summary>
        public virtual void UpdateEventsManager()
        {
            VRTK_InteractableObject newEventsManager = transform.GetComponentInParent <VRTK_InteractableObject>();

            if (newEventsManager == null)
            {
                VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_NOT_INJECTED, "VRTK_IndependentRadialMenuController", "VRTK_InteractableObject", "eventsManager", "the parent"));
                return;
            }
            else if (newEventsManager != eventsManager) // Changed managers
            {
                if (eventsManager != null)
                { // Unsubscribe from the old events
                    OnDisable();
                }

                eventsManager = newEventsManager;

                // Subscribe to new events
                OnEnable();

                Destroy(menuCollider);

                // Reset to initial state
                Initialize();
            }
        }
Beispiel #5
0
        protected virtual Vector3 GetObjectCenter(Transform checkObject)
        {
            if (centerCollider == null || checkObject != controlledTransform)
            {
                controlledTransform = checkObject;

                if (checkObject == playArea)
                {
                    CapsuleCollider playAreaCollider = playArea.GetComponentInChildren <CapsuleCollider>();
                    centerCollider = playAreaCollider;
                    if (playAreaCollider != null)
                    {
                        colliderRadius = playAreaCollider.radius;
                        colliderHeight = playAreaCollider.height;
                        colliderCenter = playAreaCollider.center;
                    }
                    else
                    {
                        VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_FROM_GAMEOBJECT, "PlayArea", "CapsuleCollider", "the same or child"));
                    }
                }
                else
                {
                    centerCollider = checkObject.GetComponentInChildren <Collider>();
                    if (centerCollider == null)
                    {
                        VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_FROM_GAMEOBJECT, "CheckObject", "Collider", "the same or child"));
                    }
                    colliderRadius = 0.1f;
                    colliderHeight = 0.1f;
                }
            }

            return(colliderCenter);
        }
Beispiel #6
0
        protected virtual void OnEnable()
        {
            desktopCamera = desktopCamera == null?GetComponentInChildren <Camera>() : desktopCamera;

            followScript = followScript == null?GetComponentInChildren <VRTK_ObjectFollow>() : followScript;

            if (desktopCamera == null)
            {
                VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_NOT_INJECTED, "VRTK_DesktopCamera", "Camera", "desktopCamera", "the same", " or any child of it"));
                return;
            }

            if (followScript == null)
            {
                VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_NOT_INJECTED, "VRTK_DesktopCamera", "VRTK_ObjectFollow", "followScript", "the same", " or any child of it"));
                return;
            }

            headsetCameraTransformFollow        = gameObject.AddComponent <VRTK_TransformFollow>();
            headsetCameraTransformFollow.moment = VRTK_TransformFollow.FollowMoment.OnLateUpdate;

            if (VRTK_SDKManager.SubscribeLoadedSetupChanged(LoadedSetupChanged) && VRTK_SDKManager.GetLoadedSDKSetup() != null)
            {
                ConfigureForCurrentSDKSetup();
            }
        }
Beispiel #7
0
 // Token: 0x060017E0 RID: 6112 RVA: 0x0007F3A0 File Offset: 0x0007D5A0
 protected virtual void OnEnable()
 {
     this.trackedObjects       = new List <Transform>();
     this.movementList         = new Dictionary <Transform, List <float> >();
     this.previousYPositions   = new Dictionary <Transform, float>();
     this.initalGaze           = Vector3.zero;
     this.direction            = Vector3.zero;
     this.previousDirection    = Vector3.zero;
     this.averagePeriod        = 60;
     this.currentSpeed         = 0f;
     this.active               = false;
     this.previousEngageButton = this.engageButton;
     this.bodyPhysics          = ((this.bodyPhysics != null) ? this.bodyPhysics : base.GetComponentInChildren <VRTK_BodyPhysics>());
     this.controllerLeftHand   = VRTK_DeviceFinder.GetControllerLeftHand(false);
     this.controllerRightHand  = VRTK_DeviceFinder.GetControllerRightHand(false);
     this.SetControllerListeners(this.controllerLeftHand, this.leftController, ref this.leftSubscribed, false);
     this.SetControllerListeners(this.controllerRightHand, this.rightController, ref this.rightSubscribed, false);
     this.headset = VRTK_DeviceFinder.HeadsetTransform();
     this.SetControlOptions(this.controlOptions);
     this.playArea = VRTK_DeviceFinder.PlayAreaTransform();
     for (int i = 0; i < this.trackedObjects.Count; i++)
     {
         Transform transform = this.trackedObjects[i];
         this.movementList.Add(transform, new List <float>());
         this.previousYPositions.Add(transform, transform.transform.localPosition.y);
     }
     if (this.playArea == null)
     {
         VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.SDK_OBJECT_NOT_FOUND, new object[]
         {
             "PlayArea",
             "Boundaries SDK"
         }));
     }
 }
Beispiel #8
0
        protected virtual void InitPlayAreaCursor()
        {
            if (playArea == null)
            {
                VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.SDK_OBJECT_NOT_FOUND, "PlayArea", "Boundaries SDK"));
                return;
            }

            Vector3[] cursorDrawVertices = VRTK_SDK_Bridge.GetPlayAreaVertices();
            if (validLocationObject != null)
            {
                GeneratePlayAreaCursorFromPrefab(cursorDrawVertices);
            }
            else
            {
                GeneratePlayAreaCursor(cursorDrawVertices);
            }

            if (playAreaCursor != null)
            {
                playAreaCursor.SetActive(false);
                VRTK_PlayerObject.SetPlayerObject(playAreaCursor, VRTK_PlayerObject.ObjectTypes.Pointer);
                CreateCursorCollider(playAreaCursor);
                playAreaCursor.AddComponent <Rigidbody>().isKinematic = true;

                VRTK_PlayAreaCollider playAreaCursorScript = playAreaCursor.AddComponent <VRTK_PlayAreaCollider>();
                playAreaCursorScript.SetParent(this);
                playAreaCursorScript.SetIgnoreTarget(targetListPolicy);
                playAreaCursor.layer = LayerMask.NameToLayer("Ignore Raycast");
            }
        }
 protected virtual void OnEnable()
 {
     if (!GetComponent <VRTK_InteractableObject>())
     {
         VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_FROM_GAMEOBJECT, "VRTK_InteractControllerAppearance", "VRTK_InteractableObject", "the same"));
     }
 }
        protected virtual void SetupColliders()
        {
            createColliders = false;
            Collider[] foundColliders = VRTK_SharedMethods.GetCollidersInGameObjects(new GameObject[] { gameObject }, true, true);
            if (foundColliders.Length == 0)
            {
                Object defaultColliderPrefab = Resources.Load(VRTK_SDK_Bridge.GetControllerDefaultColliderPath(controllerReference.hand));
                if (defaultColliderPrefab == null)
                {
                    VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.SDK_OBJECT_NOT_FOUND, "default collider prefab", "Controller SDK"));
                    return;
                }
                createColliders         = true;
                customColliderContainer = Instantiate(defaultColliderPrefab) as GameObject;
                customColliderContainer.transform.SetParent(transform);
                customColliderContainer.transform.localPosition = Vector3.zero;
                customColliderContainer.transform.localRotation = Quaternion.identity;
                customColliderContainer.transform.localScale    = Vector3.one;
                customColliderContainer.name = VRTK_SharedMethods.GenerateVRTKObjectName(true, "Controller", "TrackedCollidersContainer");
                foundColliders = VRTK_SharedMethods.GetCollidersInGameObjects(new GameObject[] { gameObject }, true, true);
            }
            trackedColliders = foundColliders;

            Collider[] touchColliders = interactTouch.ControllerColliders();

            for (int touchColliderIndex = 0; touchColliderIndex < touchColliders.Length; touchColliderIndex++)
            {
                for (int trackedColliderIndex = 0; trackedColliderIndex < trackedColliders.Length; trackedColliderIndex++)
                {
                    Physics.IgnoreCollision(touchColliders[touchColliderIndex], trackedColliders[trackedColliderIndex], true);
                }
            }
        }
Beispiel #11
0
        protected virtual void SetupCanvas()
        {
            Canvas canvas = GetComponent <Canvas>();

            if (canvas == null || canvas.renderMode != RenderMode.WorldSpace)
            {
                VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_FROM_GAMEOBJECT, "VRTK_UICanvas", "Canvas", "the same", " that is set to `Render Mode = World Space`"));
                return;
            }

            RectTransform canvasRectTransform = canvas.GetComponent <RectTransform>();
            Vector2       canvasSize          = canvasRectTransform.rect.size;
            //copy public params then disable existing graphic raycaster
            GraphicRaycaster        defaultRaycaster = canvas.gameObject.GetComponent <GraphicRaycaster>();
            VRTK_UIGraphicRaycaster customRaycaster  = canvas.gameObject.GetComponent <VRTK_UIGraphicRaycaster>();

            //if it doesn't already exist, add the custom raycaster
            if (customRaycaster == null)
            {
                customRaycaster = canvas.gameObject.AddComponent <VRTK_UIGraphicRaycaster>();
            }

            if (defaultRaycaster != null && defaultRaycaster.enabled)
            {
                customRaycaster.ignoreReversedGraphics = defaultRaycaster.ignoreReversedGraphics;
                customRaycaster.blockingObjects        = defaultRaycaster.blockingObjects;

                //Use Reflection to transfer the BlockingMask
                customRaycaster.GetType().GetField("m_BlockingMask", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(customRaycaster, defaultRaycaster.GetType().GetField("m_BlockingMask", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(defaultRaycaster));

                defaultRaycaster.enabled = false;
            }

            //add a box collider and background image to ensure the rays always hit
            if (canvas.gameObject.GetComponent <BoxCollider>() == null)
            {
                Vector2 pivot  = canvasRectTransform.pivot;
                float   zSize  = 0.1f;
                float   zScale = zSize / canvasRectTransform.localScale.z;

                canvasBoxCollider           = canvas.gameObject.AddComponent <BoxCollider>();
                canvasBoxCollider.size      = new Vector3(canvasSize.x, canvasSize.y, zScale);
                canvasBoxCollider.center    = new Vector3(canvasSize.x / 2 - canvasSize.x * pivot.x, canvasSize.y / 2 - canvasSize.y * pivot.y, zScale / 2f);
                canvasBoxCollider.isTrigger = true;
            }

            if (canvas.gameObject.GetComponent <Rigidbody>() == null)
            {
                canvasRigidBody             = canvas.gameObject.AddComponent <Rigidbody>();
                canvasRigidBody.isKinematic = true;
            }

            if (CREATE_DRAGGABLE_PANEL)
            {
                draggablePanelCreation = StartCoroutine(CreateDraggablePanel(canvas, canvasSize));
            }

            CreateActivator(canvas, canvasSize);
        }
Beispiel #12
0
 protected virtual void Start()
 {
     bodyCollider = playArea.GetComponentInChildren <CapsuleCollider>();
     if (!bodyCollider)
     {
         VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_FROM_GAMEOBJECT, "VRTK_TouchpadMovement", "CapsuleCollider", "the PlayArea"));
     }
 }
Beispiel #13
0
        // Token: 0x06001B22 RID: 6946 RVA: 0x0008E028 File Offset: 0x0008C228
        private void SetUp(Type baseType, Type fallbackType, string actualTypeName, int descriptionIndex)
        {
            if (baseType == null || fallbackType == null)
            {
                return;
            }
            if (!baseType.IsSubclassOf(typeof(SDK_Base)))
            {
                VRTK_Logger.Fatal(new ArgumentOutOfRangeException("baseType", baseType, string.Format("'{0}' is not a subclass of the SDK base type '{1}'.", baseType.Name, typeof(SDK_Base).Name)));
                return;
            }
            if (!fallbackType.IsSubclassOf(baseType))
            {
                VRTK_Logger.Fatal(new ArgumentOutOfRangeException("fallbackType", fallbackType, string.Format("'{0}' is not a subclass of the SDK base type '{1}'.", fallbackType.Name, baseType.Name)));
                return;
            }
            this.baseTypeName     = baseType.FullName;
            this.fallbackTypeName = fallbackType.FullName;
            this.typeName         = actualTypeName;
            if (string.IsNullOrEmpty(actualTypeName))
            {
                this.type = fallbackType;
                this.originalTypeNameWhenFallbackIsUsed = null;
                this.descriptionIndex = -1;
                this.description      = new SDK_DescriptionAttribute(typeof(SDK_FallbackSystem), 0);
                return;
            }
            Type type = Type.GetType(actualTypeName);

            if (type == null)
            {
                this.type = fallbackType;
                this.originalTypeNameWhenFallbackIsUsed = actualTypeName;
                this.descriptionIndex = -1;
                this.description      = new SDK_DescriptionAttribute(typeof(SDK_FallbackSystem), 0);
                VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.SDK_NOT_FOUND, new object[]
                {
                    actualTypeName,
                    fallbackType.Name
                }));
                return;
            }
            if (!type.IsSubclassOf(baseType))
            {
                VRTK_Logger.Fatal(new ArgumentOutOfRangeException("actualTypeName", actualTypeName, string.Format("'{0}' is not a subclass of the SDK base type '{1}'.", actualTypeName, baseType.Name)));
                return;
            }
            SDK_DescriptionAttribute[] descriptions = SDK_DescriptionAttribute.GetDescriptions(type);
            if (descriptions.Length <= descriptionIndex)
            {
                VRTK_Logger.Fatal(new ArgumentOutOfRangeException("descriptionIndex", descriptionIndex, string.Format("'{0}' has no '{1}' at that index.", actualTypeName, typeof(SDK_DescriptionAttribute).Name)));
                return;
            }
            this.type = type;
            this.originalTypeNameWhenFallbackIsUsed = null;
            this.descriptionIndex = descriptionIndex;
            this.description      = descriptions[descriptionIndex];
        }
Beispiel #14
0
 protected virtual void OnEnable()
 {
     canvasGroup = GetComponent <CanvasGroup>();
     if (restrictToDropZone && GetComponentInParent <VRTK_UIDropZone>() == null)
     {
         enabled = false;
         VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_FROM_GAMEOBJECT, "VRTK_UIDraggableItem", "VRTK_UIDropZone", "the parent", " if `freeDrop = false`"));
     }
 }
Beispiel #15
0
 /// <summary>
 /// The FindInScene method is used to find the `[VRSimulator_CameraRig]` GameObject within the current scene.
 /// </summary>
 /// <returns>Returns the found `[VRSimulator_CameraRig]` GameObject if it is found. If it is not found then it prints a debug log error.</returns>
 public static GameObject FindInScene()
 {
     if (cachedCameraRig == null && !destroyed)
     {
         cachedCameraRig = VRTK_SharedMethods.FindEvenInactiveGameObject <SDK_InputSimulator>();
         if (!cachedCameraRig)
         {
             VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_FROM_SCENE, "[VRSimulator_CameraRig]", "SDK_InputSimulator", ". check that the `VRTK/Prefabs/CameraRigs/[VRSimulator_CameraRig]` prefab been added to the scene."));
         }
     }
     return(cachedCameraRig);
 }
Beispiel #16
0
 protected virtual void OnEnable()
 {
     if (events == null)
     {
         VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_NOT_INJECTED, "RadialMenuController", "VRTK_ControllerEvents", "events", "the parent"));
         return;
     }
     else
     {
         events.ButtonOnePressed += new ControllerInteractionEventHandler(DoButtonOnePressed);
     }
 }
Beispiel #17
0
 // Token: 0x060015C5 RID: 5573 RVA: 0x0007746D File Offset: 0x0007566D
 protected virtual void OnEnable()
 {
     if (!base.GetComponent <VRTK_InteractableObject>())
     {
         VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_FROM_GAMEOBJECT, new object[]
         {
             "VRTK_InteractHaptics",
             "VRTK_InteractableObject",
             "the same"
         }));
     }
 }
Beispiel #18
0
        protected virtual void Awake()
        {
            originalControllerAttachPoint = controllerAttachPoint;
            controllerEvents = (controllerEvents != null ? controllerEvents : GetComponentInParent <VRTK_ControllerEvents>());
            interactTouch    = (interactTouch != null ? interactTouch : GetComponentInParent <VRTK_InteractTouch>());
            if (interactTouch == null)
            {
                VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_NOT_INJECTED, "VRTK_InteractGrab", "VRTK_InteractTouch", "interactTouch", "the same or parent"));
            }

            VRTK_SDKManager.instance.AddBehaviourToToggleOnLoadedSetupChange(this);
        }
Beispiel #19
0
        /// <summary>
        /// The RemoveEventSystem resets the Unity EventSystem back to the original state before the VRTK_VRInputModule was swapped for it.
        /// </summary>
        public virtual void RemoveEventSystem()
        {
            VRTK_EventSystem vrtkEventSystem = FindObjectOfType <VRTK_EventSystem>();

            if (vrtkEventSystem == null)
            {
                VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_FROM_SCENE, "VRTK_UIPointer", "EventSystem"));
                return;
            }

            Destroy(vrtkEventSystem);
        }
 protected override void OnEnable()
 {
     if (interactTouch == null)
     {
         VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_FROM_PARAMETER, "VRTK_ControllerTrackedCollider", "VRTK_InteractTouch", "Interact Touch"));
     }
     else
     {
         VRTK_SharedMethods.AddDictionaryValue(VRTK_ObjectCache.registeredTrackedColliderToInteractTouches, interactTouch, this);
     }
     base.OnEnable();
 }
Beispiel #21
0
        protected virtual void SetupCanvas()
        {
            var canvas = GetComponent <Canvas>();

            if (!canvas || canvas.renderMode != RenderMode.WorldSpace)
            {
                VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_FROM_GAMEOBJECT, "VRTK_UICanvas", "Canvas", "the same", " that is set to `Render Mode = World Space`"));
                return;
            }

            var canvasRectTransform = canvas.GetComponent <RectTransform>();
            var canvasSize          = canvasRectTransform.sizeDelta;
            //copy public params then disable existing graphic raycaster
            var defaultRaycaster = canvas.gameObject.GetComponent <GraphicRaycaster>();
            var customRaycaster  = canvas.gameObject.GetComponent <VRTK_UIGraphicRaycaster>();


            //if it doesn't already exist, add the custom raycaster
            if (!customRaycaster)
            {
                customRaycaster = canvas.gameObject.AddComponent <VRTK_UIGraphicRaycaster>();
            }

            if (defaultRaycaster && defaultRaycaster.enabled)
            {
                customRaycaster.ignoreReversedGraphics = defaultRaycaster.ignoreReversedGraphics;
                customRaycaster.blockingObjects        = defaultRaycaster.blockingObjects;
                defaultRaycaster.enabled = false;
            }

            //add a box collider and background image to ensure the rays always hit
            if (!canvas.gameObject.GetComponent <BoxCollider>())
            {
                Vector2 pivot  = canvasRectTransform.pivot;
                float   zSize  = 0.1f;
                float   zScale = zSize / canvasRectTransform.localScale.z;

                canvasBoxCollider           = canvas.gameObject.AddComponent <BoxCollider>();
                canvasBoxCollider.size      = new Vector3(canvasSize.x, canvasSize.y, zScale);
                canvasBoxCollider.center    = new Vector3(canvasSize.x / 2 - canvasSize.x * pivot.x, canvasSize.y / 2 - canvasSize.y * pivot.y, zScale / 2f);
                canvasBoxCollider.isTrigger = true;
            }

            if (!canvas.gameObject.GetComponent <Rigidbody>())
            {
                canvasRigidBody             = canvas.gameObject.AddComponent <Rigidbody>();
                canvasRigidBody.isKinematic = true;
            }

            draggablePanelCreation = StartCoroutine(CreateDraggablePanel(canvas, canvasSize));
            CreateActivator(canvas, canvasSize);
        }
Beispiel #22
0
        protected virtual void OnEnable()
        {
            controllerEvents = (controllerEvents != null ? controllerEvents : GetComponentInParent <VRTK_ControllerEvents>());
            interactTouch    = (interactTouch != null ? interactTouch : GetComponentInParent <VRTK_InteractTouch>());
            interactGrab     = (interactGrab != null ? interactGrab : GetComponentInParent <VRTK_InteractGrab>());

            if (interactTouch == null)
            {
                VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_NOT_INJECTED, "VRTK_InteractUse", "VRTK_InteractTouch", "interactTouch", "the same or parent"));
            }

            ManageUseListener(true);
        }
 protected virtual void OnEnable()
 {
     if (rightController == null)
     {
         VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_NOT_INJECTED, "RadialMenuController", "VRTK_ControllerEvents", "events", "the parent"));
         return;
     }
     else
     {
         rightController.TriggerClicked   += RightController_TriggerClicked;
         rightController.TriggerUnclicked += RightController_TriggerUnclicked;
     }
 }
Beispiel #24
0
        private void SetupController()
        {
            if (controller == null)
            {
                controller = GetComponent <VRTK_ControllerEvents>();
                AttemptSetController();
            }

            if (controller == null)
            {
                VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_NOT_INJECTED, "VRTK_BasePointer", "VRTK_ControllerEvents", "controller", "the same"));
            }
        }
Beispiel #25
0
        // Token: 0x06001B6A RID: 7018 RVA: 0x0008F540 File Offset: 0x0008D740
        private static void HandleSDKGetter <BaseType>(string prettyName, VRTK_SDKInfo info, IEnumerable <VRTK_SDKInfo> installedInfos) where BaseType : SDK_Base
        {
            if (VRTK_SharedMethods.IsEditTime())
            {
                return;
            }
            string sdkerrorDescription = VRTK_SDKSetup.GetSDKErrorDescription <BaseType>(prettyName, info, installedInfos);

            if (!string.IsNullOrEmpty(sdkerrorDescription))
            {
                VRTK_Logger.Error(sdkerrorDescription);
            }
        }
Beispiel #26
0
        protected virtual void CreateTouchCollider()
        {
            SDK_BaseController.ControllerHand controllerHand = VRTK_DeviceFinder.GetControllerHand(gameObject);
            string colliderPath = VRTK_SDK_Bridge.GetControllerDefaultColliderPath(controllerHand);

            if (colliderPath == "")
            {
                return;
            }
            Object defaultColliderPrefab = Resources.Load(colliderPath);

            if (customColliderContainer == null)
            {
                if (defaultColliderPrefab == null)
                {
                    VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.SDK_OBJECT_NOT_FOUND, "default collider prefab", "Controller SDK"));
                    return;
                }
                if (destroyColliderOnDisable)
                {
                    Destroy(controllerCollisionDetector);
                }
                controllerCollisionDetector = Instantiate(defaultColliderPrefab, transform.position, transform.rotation) as GameObject;
                controllerCollisionDetector.transform.SetParent(transform);
                controllerCollisionDetector.transform.localScale = transform.localScale;
                controllerCollisionDetector.name = VRTK_SharedMethods.GenerateVRTKObjectName(true, "Controller", "CollidersContainer");
                destroyColliderOnDisable         = true;
            }
            else
            {
                if (destroyColliderOnDisable)
                {
                    Destroy(controllerCollisionDetector);
                }

                if (CustomRigidBodyIsChild())
                {
                    controllerCollisionDetector = customColliderContainer;
                    destroyColliderOnDisable    = false;
                }
                else
                {
                    controllerCollisionDetector = Instantiate(customColliderContainer, transform.position, transform.rotation) as GameObject;
                    controllerCollisionDetector.transform.SetParent(transform);
                    controllerCollisionDetector.transform.localScale = transform.localScale;
                    destroyColliderOnDisable = true;
                }
            }
            controllerCollisionDetector.AddComponent <VRTK_PlayerObject>().objectType = VRTK_PlayerObject.ObjectTypes.Collider;
        }
Beispiel #27
0
 protected virtual void OnEnable()
 {
     lastGoodPositionSet = false;
     headset             = VRTK_DeviceFinder.HeadsetTransform();
     playArea            = VRTK_DeviceFinder.PlayAreaTransform();
     bodyPhysics         = FindObjectOfType <VRTK_BodyPhysics>();
     playareaRigidbody   = playArea.GetComponent <Rigidbody>();
     headsetCollision    = GetComponent <VRTK_HeadsetCollision>();
     ManageHeadsetListeners(true);
     if (!playArea)
     {
         VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.SDK_OBJECT_NOT_FOUND, "PlayArea", "Boundaries SDK"));
     }
 }
Beispiel #28
0
        protected virtual void Awake()
        {
            touchpadAxisChanged = new ControllerInteractionEventHandler(DoTouchpadAxisChanged);
            touchpadUntouched   = new ControllerInteractionEventHandler(DoTouchpadTouchEnd);
            playArea            = VRTK_DeviceFinder.PlayAreaTransform();
            controllerLeftHand  = VRTK_DeviceFinder.GetControllerLeftHand();
            controllerRightHand = VRTK_DeviceFinder.GetControllerRightHand();
            if (!playArea)
            {
                VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.SDK_OBJECT_NOT_FOUND, "PlayArea", "Boundaries SDK"));
            }

            VRTK_PlayerObject.SetPlayerObject(gameObject, VRTK_PlayerObject.ObjectTypes.CameraRig);
        }
Beispiel #29
0
        protected virtual void OnEnable()
        {
            lastGoodPositionSet = false;
            headset             = VRTK_DeviceFinder.HeadsetTransform();
            playArea            = VRTK_DeviceFinder.PlayAreaTransform();
            if (playArea == null)
            {
                VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.SDK_OBJECT_NOT_FOUND, "PlayArea", "Boundaries SDK"));
            }

            bodyPhysics      = (bodyPhysics != null ? bodyPhysics : FindObjectOfType <VRTK_BodyPhysics>());
            headsetCollision = (headsetCollision != null ? headsetCollision : GetComponentInChildren <VRTK_HeadsetCollision>());
            ManageListeners(true);
        }
Beispiel #30
0
        /// <summary>
        /// The SetEventSystem method is used to set up the global Unity event system for the UI pointer. It also handles disabling the existing Standalone Input Module that exists on the EventSystem and adds a custom VRTK Event System VR Input component that is required for interacting with the UI with VR inputs.
        /// </summary>
        /// <param name="eventSystem">The global Unity event system to be used by the UI pointers.</param>
        /// <returns>A custom input module that is used to detect input from VR pointers.</returns>
        public virtual VRTK_VRInputModule SetEventSystem(EventSystem eventSystem)
        {
            if (eventSystem == null)
            {
                VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_FROM_SCENE, "VRTK_UIPointer", "EventSystem"));
                return(null);
            }

            if (!(eventSystem is VRTK_EventSystem))
            {
                eventSystem = eventSystem.gameObject.AddComponent <VRTK_EventSystem>();
            }

            return(eventSystem.GetComponent <VRTK_VRInputModule>());
        }