示例#1
0
 // Token: 0x060011D3 RID: 4563 RVA: 0x000674E8 File Offset: 0x000656E8
 protected virtual void OnEnable()
 {
     if (this.events == null)
     {
         VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_NOT_INJECTED, new object[]
         {
             "RadialMenuController",
             "VRTK_ControllerEvents",
             "events",
             "the parent"
         }));
         return;
     }
     this.events.TouchpadPressed     += this.DoTouchpadClicked;
     this.events.TouchpadReleased    += this.DoTouchpadUnclicked;
     this.events.TouchpadTouchStart  += this.DoTouchpadTouched;
     this.events.TouchpadTouchEnd    += this.DoTouchpadUntouched;
     this.events.TouchpadAxisChanged += this.DoTouchpadAxisChanged;
     this.menu.FireHapticPulse       += this.AttemptHapticPulse;
 }
        protected virtual void SetSnapDropZoneJoint(Rigidbody snapTo)
        {
            Joint snapDropZoneJoint = GetComponent <Joint>();

            if (snapDropZoneJoint == null)
            {
                VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_FROM_GAMEOBJECT, "SnapDropZone:" + 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, "VRTK_SnapDropZone", "Rigidbody", "the `VRTK_InteractableObject`"));
                return;
            }

            snapDropZoneJoint.connectedBody = snapTo;
            originalJointCollisionState     = snapDropZoneJoint.enableCollision;
            //need to set this to true otherwise highlighting doesn't work again on grab
            snapDropZoneJoint.enableCollision = true;
        }
示例#3
0
 // Token: 0x0600182F RID: 6191 RVA: 0x00080AC0 File Offset: 0x0007ECC0
 protected virtual void OnEnable()
 {
     this.movementTransform = VRTK_DeviceFinder.HeadsetTransform();
     if (this.movementTransform == null)
     {
         VRTK_Logger.Warn(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_FROM_SCENE, new object[]
         {
             "VRTK_RoomExtender",
             "Headset Transform"
         }));
     }
     this.playArea = VRTK_DeviceFinder.PlayAreaTransform();
     this.additionalMovementEnabled = !this.additionalMovementEnabledOnButtonPress;
     if (this.debugTransform)
     {
         this.debugTransform.localScale = new Vector3(this.headZoneRadius * 2f, 0.01f, this.headZoneRadius * 2f);
     }
     this.MoveHeadCircleNonLinearDrift();
     this.lastPosition = this.movementTransform.localPosition;
 }
示例#4
0
        /// <summary>
        /// Removes scripting define symbols used by previous VRTK versions.
        /// </summary>
        private static void RemoveLegacyScriptingDefineSymbols()
        {
            string[] currentSymbols = PlayerSettings.GetScriptingDefineSymbolsForGroup(BuildTargetGroup.Standalone)
                                      .Split(';')
                                      .Distinct()
                                      .OrderBy(symbol => symbol, StringComparer.Ordinal)
                                      .ToArray();
            string[] newSymbols = currentSymbols.Where(symbol => !symbol.StartsWith("VRTK_SDK_", StringComparison.Ordinal)).ToArray();

            if (!currentSymbols.SequenceEqual(newSymbols))
            {
                PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.Standalone, string.Join(";", newSymbols));

                string[] removedSymbols = currentSymbols.Except(newSymbols).ToArray();
                if (removedSymbols.Length > 0)
                {
                    VRTK_Logger.Info("Legacy (i.e. used by previous VRTK versions only) Scripting Define Symbols removed from [Project Settings->Player]: " + string.Join(", ", removedSymbols));
                }
            }
        }
示例#5
0
 protected virtual void OnEnable()
 {
     scriptControllerAlias = (controllerAlias != null ? controllerAlias : gameObject);
     actualController      = VRTK_DeviceFinder.GetActualController(scriptControllerAlias);
     if (actualController != null)
     {
         trackedController = actualController.GetComponent <VRTK_TrackedController>();
         if (trackedController != null)
         {
             trackedController.ControllerModelAvailable += DoControllerModelAvailable;
         }
         if (trackedControllerReady)
         {
             ControllerAvailable();
         }
     }
     else
     {
         VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_NOT_INJECTED, "VRTK_ControllerHighlighter", "Controller Alias GameObject", "controllerAlias", "the same"));
     }
 }
示例#6
0
 // Token: 0x0600154B RID: 5451 RVA: 0x0007588C File Offset: 0x00073A8C
 protected virtual Transform GetElementTransform(string path)
 {
     if (this.cachedElements == null || path == null)
     {
         return(null);
     }
     if (!this.cachedElements.ContainsKey(path) || this.cachedElements[path] == null)
     {
         if (!this.modelContainer)
         {
             VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.SDK_OBJECT_NOT_FOUND, new object[]
             {
                 "Controller Model",
                 "Controller SDK"
             }));
             return(null);
         }
         this.cachedElements[path] = this.modelContainer.transform.Find(path);
     }
     return(this.cachedElements[path]);
 }
示例#7
0
 // Token: 0x06001276 RID: 4726 RVA: 0x00069208 File Offset: 0x00067408
 public SDK_DescriptionAttribute(string prettyName, string symbol, string vrDeviceName, string buildTargetGroupName, int index = 0)
 {
     if (prettyName == null)
     {
         VRTK_Logger.Fatal(new ArgumentNullException("prettyName"));
         return;
     }
     if (prettyName == string.Empty)
     {
         VRTK_Logger.Fatal(new ArgumentOutOfRangeException("prettyName", prettyName, "An empty string isn't allowed."));
         return;
     }
     this.prettyName   = prettyName;
     this.symbol       = symbol;
     this.vrDeviceName = (string.IsNullOrEmpty(vrDeviceName) ? "None" : vrDeviceName);
     this.index        = index;
     if (string.IsNullOrEmpty(buildTargetGroupName))
     {
         buildTargetGroupName = "Unknown";
     }
 }
示例#8
0
        protected virtual void OnEnable()
        {
            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);

            SetControllerListeners(controllerLeftHand, leftController, ref leftSubscribed);
            SetControllerListeners(controllerRightHand, rightController, ref rightSubscribed);
            bodyPhysics   = GetComponent <VRTK_BodyPhysics>();
            movementSpeed = 0f;
            strafeSpeed   = 0f;
            multiplySpeed = false;
        }
        /// <summary>
        /// Check if the Mixed (Virtual) Reality Settings are properly set.
        /// </summary>
        /// <returns>Are the settings set.</returns>
        protected virtual bool CheckForMixedRealitySupport()
        {
            if (XRSettings.enabled == false)
            {
                VRTK_Logger.Error("XRSettings are not enabled. Enable in PlayerSettings. Do not forget to add Windows Mixed Reality to Virtual Reality SDKs.");
                return(false);
            }
            else
            {
                foreach (string device in XRSettings.supportedDevices)
                {
                    if (device.Equals("WindowsMR"))
                    {
                        return(true);
                    }
                }
                VRTK_Logger.Error("Windows Mixed Reality is not supported in XRSettings, add in PlayerSettings.");
            }

            return(false);
        }
示例#10
0
        protected virtual void OnEnable()
        {
            touchpadAxisChanged = new ControllerInteractionEventHandler(DoTouchpadAxisChanged);
            touchpadUntouched   = new ControllerInteractionEventHandler(DoTouchpadTouchEnd);

            controllerLeftHand  = VRTK_DeviceFinder.GetControllerLeftHand();
            controllerRightHand = VRTK_DeviceFinder.GetControllerRightHand();

            playArea = VRTK_DeviceFinder.PlayAreaTransform();
            if (!playArea)
            {
                VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.SDK_OBJECT_NOT_FOUND, "PlayArea", "Boundaries SDK"));
            }

            headset = VRTK_DeviceFinder.HeadsetTransform();
            if (!headset)
            {
                VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.SDK_OBJECT_NOT_FOUND, "HeadsetTransform", "Headset SDK"));
            }

            VRTK_PlayerObject.SetPlayerObject(gameObject, VRTK_PlayerObject.ObjectTypes.CameraRig);

            SetControllerListeners(controllerLeftHand, leftController, ref leftSubscribed);
            SetControllerListeners(controllerRightHand, rightController, ref rightSubscribed);
            bodyPhysics = GetComponent <VRTK_BodyPhysics>();

            movementSpeed    = 0f;
            strafeSpeed      = 0f;
            blinkFadeInTime  = 0f;
            lastWarp         = 0f;
            lastFlip         = 0f;
            lastSnapRotate   = 0f;
            multiplyMovement = false;

            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"));
            }
        }
示例#11
0
        protected virtual void Awake()
        {
            touchpadAxisChanged = new ControllerInteractionEventHandler(DoTouchpadAxisChanged);
            touchpadUntouched   = new ControllerInteractionEventHandler(DoTouchpadTouchEnd);

            controllerLeftHand  = VRTK_DeviceFinder.GetControllerLeftHand();
            controllerRightHand = VRTK_DeviceFinder.GetControllerRightHand();

            playArea = VRTK_DeviceFinder.PlayAreaTransform();
            if (!playArea)
            {
                VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.SDK_OBJECT_NOT_FOUND, "PlayArea", "Boundaries SDK"));
            }

            headset = VRTK_DeviceFinder.HeadsetTransform();
            if (!headset)
            {
                VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.SDK_OBJECT_NOT_FOUND, "HeadsetTransform", "Headset SDK"));
            }

            VRTK_PlayerObject.SetPlayerObject(gameObject, VRTK_PlayerObject.ObjectTypes.CameraRig);
        }
示例#12
0
        /// <summary>
        /// Creates new SDK infos for a type.
        /// </summary>
        /// <typeparam name="BaseType">The SDK base type. Must be a subclass of SDK_Base.</typeparam>
        /// <typeparam name="FallbackType">The SDK type to fall back on if problems occur. Must be a subclass of `BaseType.</typeparam>
        /// <param name="actualType">The SDK type to use. Must be a subclass of `BaseType.</param>
        /// <returns>Multiple newly created instances.</returns>
        public static VRTK_SDKInfo[] Create <BaseType, FallbackType>(Type actualType) where BaseType : SDK_Base where FallbackType : BaseType
        {
            string actualTypeName = actualType.FullName;

            SDK_DescriptionAttribute[] descriptions = SDK_DescriptionAttribute.GetDescriptions(actualType);
            if (descriptions.Length == 0)
            {
                VRTK_Logger.Fatal(string.Format("'{0}' doesn't specify any SDK descriptions via '{1}'.", actualTypeName, typeof(SDK_DescriptionAttribute).Name));
                return(new VRTK_SDKInfo[0]);
            }

            HashSet <VRTK_SDKInfo> sdkInfos = new HashSet <VRTK_SDKInfo>();

            foreach (SDK_DescriptionAttribute description in descriptions)
            {
                VRTK_SDKInfo sdkInfo = new VRTK_SDKInfo();
                sdkInfo.SetUp(typeof(BaseType), typeof(FallbackType), actualTypeName, description.index);
                sdkInfos.Add(sdkInfo);
            }

            return(sdkInfos.ToArray());
        }
示例#13
0
 // Token: 0x06001804 RID: 6148 RVA: 0x00080010 File Offset: 0x0007E210
 protected virtual void OnEnable()
 {
     this.currentAxis      = Vector2.zero;
     this.storedAxis       = Vector2.zero;
     this.controllerEvents = ((this.controller != null) ? this.controller : base.GetComponent <VRTK_ControllerEvents>());
     if (!this.controllerEvents)
     {
         VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_NOT_INJECTED, new object[]
         {
             "VRTK_ObjectControl",
             "VRTK_ControllerEvents",
             "controller",
             "the same"
         }));
         return;
     }
     this.SetControlledObject();
     this.bodyPhysics     = ((!this.controlOverrideObject) ? Object.FindObjectOfType <VRTK_BodyPhysics>() : null);
     this.directionDevice = this.GetDirectionDevice();
     this.SetListeners(true);
     this.otherObjectControl = this.GetOtherControl();
 }
示例#14
0
 protected virtual void Start()
 {
     if (movementTransform == null)
     {
         if (VRTK_DeviceFinder.HeadsetTransform() != null)
         {
             movementTransform = VRTK_DeviceFinder.HeadsetTransform();
         }
         else
         {
             VRTK_Logger.Warn(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_FROM_SCENE, "VRTK_RoomExtender", "Headset Transform"));
         }
     }
     playArea = VRTK_DeviceFinder.PlayAreaTransform();
     additionalMovementEnabled = !additionalMovementEnabledOnButtonPress;
     if (debugTransform)
     {
         debugTransform.localScale = new Vector3(headZoneRadius * 2, 0.01f, headZoneRadius * 2);
     }
     MoveHeadCircleNonLinearDrift();
     lastPosition = movementTransform.localPosition;
 }
        protected override bool SetupListeners(bool throwError)
        {
            objectToAffect = (objectToAffect != null ? objectToAffect : GetComponentInParent <VRTK_InteractableObject>());
            if (objectToAffect != null)
            {
                objectToAffect.SubscribeToInteractionEvent(VRTK_InteractableObject.InteractionType.NearTouch, CancelNearTouchHaptics);
                objectToAffect.SubscribeToInteractionEvent(VRTK_InteractableObject.InteractionType.Touch, CancelTouchHaptics);
                objectToAffect.SubscribeToInteractionEvent(VRTK_InteractableObject.InteractionType.Grab, CancelGrabHaptics);
                objectToAffect.SubscribeToInteractionEvent(VRTK_InteractableObject.InteractionType.Use, CancelUseHaptics);

                objectToAffect.SubscribeToInteractionEvent(VRTK_InteractableObject.InteractionType.NearUntouch, NearTouchHaptics);
                objectToAffect.SubscribeToInteractionEvent(VRTK_InteractableObject.InteractionType.Untouch, TouchHaptics);
                objectToAffect.SubscribeToInteractionEvent(VRTK_InteractableObject.InteractionType.Ungrab, GrabHaptics);
                objectToAffect.SubscribeToInteractionEvent(VRTK_InteractableObject.InteractionType.Unuse, UseHaptics);
                return(true);
            }
            else if (throwError)
            {
                VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_FROM_GAMEOBJECT, "VRTK_InteractHaptics", "VRTK_InteractableObject", "the same or parent"));
            }
            return(false);
        }
示例#16
0
        // Token: 0x06001B4E RID: 6990 RVA: 0x0008E9F0 File Offset: 0x0008CBF0
        private void ToggleBehaviours(bool state)
        {
            List <Behaviour> list = this._behavioursToToggleOnLoadedSetupChange.ToList <Behaviour>();

            if (!state)
            {
                list.Reverse();
            }
            for (int i = 0; i < list.Count; i++)
            {
                Behaviour behaviour = list[i];
                if (behaviour == null)
                {
                    VRTK_Logger.Error(string.Format("A behaviour to toggle has been destroyed. Have you forgot the corresponding call `VRTK_SDKManager.instance.RemoveBehaviourToToggleOnLoadedSetupChange(this)` in the `OnDestroy` method of `{0}`?", behaviour.GetType()));
                    this._behavioursToToggleOnLoadedSetupChange.RemoveAt(state ? i : (this._behavioursToToggleOnLoadedSetupChange.Count - 1 - i));
                }
                else
                {
                    behaviour.enabled = ((state && this._behavioursInitialState.ContainsKey(behaviour)) ? this._behavioursInitialState[behaviour] : state);
                }
            }
        }
            private static void FixOpenAndUnsavedScenes()
            {
                List <VRTK_SDKSetup> setups = Enumerable.Range(0, EditorSceneManager.loadedSceneCount)
                                              .SelectMany(sceneIndex => SceneManager.GetSceneAt(sceneIndex).GetRootGameObjects())
                                              .SelectMany(rootObject => rootObject.GetComponentsInChildren <VRTK_SDKManager>())
                                              .Select(manager => manager.setups.Where(setup => setup != null).ToArray())
                                              .Where(sdkSetups => sdkSetups.Length > 1)
                                              .SelectMany(sdkSetups => sdkSetups)
                                              .Where(setup => setup.gameObject.activeSelf)
                                              .ToList();

                if (setups.Count == 0)
                {
                    return;
                }

                setups.ForEach(setup => setup.gameObject.SetActive(false));

                string infoMessage = string.Format(
                    "The following game objects have been set inactive to allow for SDK loading and switching using the SDK Setups on them:\n{0}",
                    string.Join(", ", setups.Select(setup => setup.name).ToArray()));

                if (EditorApplication.isPlayingOrWillChangePlaymode)
                {
#if UNITY_5_6_OR_NEWER
                    SessionState.SetString(
#else
                    EditorPrefs.SetString(
#endif
                        PreferencesKey,
                        infoMessage
                        );
                }
                else
                {
                    VRTK_Logger.Info(infoMessage);
                }
            }
示例#18
0
        protected virtual void OnEnable()
        {
            trackedObjects       = new List <Transform>();
            movementList         = new Dictionary <Transform, List <float> >();
            previousYPositions   = new Dictionary <Transform, float>();
            initalGaze           = Vector3.zero;
            direction            = Vector3.zero;
            previousDirection    = Vector3.zero;
            averagePeriod        = 60;
            currentSpeed         = 0f;
            active               = false;
            previousEngageButton = engageButton;

            bodyPhysics         = (bodyPhysics != null ? bodyPhysics : GetComponentInChildren <VRTK_BodyPhysics>());
            controllerLeftHand  = VRTK_DeviceFinder.GetControllerLeftHand();
            controllerRightHand = VRTK_DeviceFinder.GetControllerRightHand();

            SetControllerListeners(controllerLeftHand, leftController, ref leftSubscribed);
            SetControllerListeners(controllerRightHand, rightController, ref rightSubscribed);

            headset = VRTK_DeviceFinder.HeadsetTransform();

            SetControlOptions(controlOptions);

            playArea = VRTK_DeviceFinder.PlayAreaTransform();

            // Initialize the lists.
            for (int i = 0; i < trackedObjects.Count; i++)
            {
                Transform trackedObj = trackedObjects[i];
                movementList.Add(trackedObj, new List <float>());
                previousYPositions.Add(trackedObj, trackedObj.transform.localPosition.y);
            }
            if (playArea == null)
            {
                VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.SDK_OBJECT_NOT_FOUND, "PlayArea", "Boundaries SDK"));
            }
        }
示例#19
0
 protected override void OnEnable()
 {
     base.OnEnable();
     VRTK_PlayerObject.SetPlayerObject(gameObject, VRTK_PlayerObject.ObjectTypes.Pointer);
     customOrigin = (customOrigin == null ? VRTK_SDK_Bridge.GenerateControllerPointerOrigin(gameObject) : customOrigin);
     SetupController();
     SetupRenderer();
     activateDelayTimer     = 0f;
     selectDelayTimer       = 0f;
     hoverDurationTimer     = 0f;
     currentActivationState = 0;
     wasActivated           = false;
     willDeactivate         = false;
     canClickOnHover        = false;
     if (NoPointerRenderer())
     {
         VRTK_Logger.Warn(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_FROM_PARAMETER, "VRTK_Pointer", "VRTK_BasePointerRenderer", "Pointer Renderer"));
     }
     if (activateOnEnable)
     {
         Toggle(true);
     }
 }
示例#20
0
 // Token: 0x0600186C RID: 6252 RVA: 0x00081F84 File Offset: 0x00080184
 protected virtual void OnEnable()
 {
     this.touchpadAxisChanged = new ControllerInteractionEventHandler(this.DoTouchpadAxisChanged);
     this.touchpadUntouched   = new ControllerInteractionEventHandler(this.DoTouchpadTouchEnd);
     this.playArea            = VRTK_DeviceFinder.PlayAreaTransform();
     this.controllerLeftHand  = VRTK_DeviceFinder.GetControllerLeftHand(false);
     this.controllerRightHand = VRTK_DeviceFinder.GetControllerRightHand(false);
     if (!this.playArea)
     {
         VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.SDK_OBJECT_NOT_FOUND, new object[]
         {
             "PlayArea",
             "Boundaries SDK"
         }));
     }
     VRTK_PlayerObject.SetPlayerObject(base.gameObject, VRTK_PlayerObject.ObjectTypes.CameraRig);
     this.SetControllerListeners(this.controllerLeftHand, this.leftController, ref this.leftSubscribed, false);
     this.SetControllerListeners(this.controllerRightHand, this.rightController, ref this.rightSubscribed, false);
     this.bodyPhysics   = base.GetComponent <VRTK_BodyPhysics>();
     this.movementSpeed = 0f;
     this.strafeSpeed   = 0f;
     this.multiplySpeed = false;
 }
示例#21
0
        protected override bool SetupListeners(bool throwError)
        {
            objectToMonitor = (objectToMonitor == null ? GetComponentInParent <VRTK_InteractableObject>() : objectToMonitor);
            if (objectToMonitor != null)
            {
                objectToMonitor.InteractableObjectDisabled += InteractableObjectDisabled;

                objectToMonitor.SubscribeToInteractionEvent(VRTK_InteractableObject.InteractionType.NearTouch, InteractableObjectNearTouched);
                objectToMonitor.SubscribeToInteractionEvent(VRTK_InteractableObject.InteractionType.NearUntouch, InteractableObjectNearUntouched);
                objectToMonitor.SubscribeToInteractionEvent(VRTK_InteractableObject.InteractionType.Touch, InteractableObjectTouched);
                objectToMonitor.SubscribeToInteractionEvent(VRTK_InteractableObject.InteractionType.Untouch, InteractableObjectUntouched);
                objectToMonitor.SubscribeToInteractionEvent(VRTK_InteractableObject.InteractionType.Grab, InteractableObjectGrabbed);
                objectToMonitor.SubscribeToInteractionEvent(VRTK_InteractableObject.InteractionType.Ungrab, InteractableObjectUngrabbed);
                objectToMonitor.SubscribeToInteractionEvent(VRTK_InteractableObject.InteractionType.Use, InteractableObjectUsed);
                objectToMonitor.SubscribeToInteractionEvent(VRTK_InteractableObject.InteractionType.Unuse, InteractableObjectUnused);
                return(true);
            }
            else if (throwError)
            {
                VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_NOT_INJECTED, "VRTK_InteractObjectAppearance", "VRTK_InteractableObject", "objectToMonitor", "current or parent"));
            }
            return(false);
        }
示例#22
0
 // Token: 0x06001207 RID: 4615 RVA: 0x00067D34 File Offset: 0x00065F34
 protected virtual void CreateHighlightersInEditor()
 {
     if (VRTK_SharedMethods.IsEditTime())
     {
         this.GenerateHighlightObject();
         if (this.snapType == VRTK_SnapDropZone.SnapTypes.UseJoint && base.GetComponent <Joint>() == null)
         {
             VRTK_Logger.Warn(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`"
             }));
         }
         this.GenerateEditorHighlightObject();
         this.ForceSetObjects();
         if (this.highlightEditorObject != null)
         {
             this.highlightEditorObject.SetActive(this.displayDropZoneInEditor);
         }
     }
 }
示例#23
0
        public static void CreateIfNotExists()
        {
            if (instance == null)
            {
                GameObject loggerObject = new GameObject(VRTK_SharedMethods.GenerateVRTKObjectName(true, "Logger"))
                {
                    hideFlags = HideFlags.DontSaveInEditor | HideFlags.HideInHierarchy
                };
                instance = loggerObject.AddComponent <VRTK_Logger>();
            }

            if (commonMessageParts.Count != commonMessages.Count)
            {
                commonMessageParts.Clear();
                foreach (KeyValuePair <CommonMessageKeys, string> commonMessage in commonMessages)
                {
                    int bitCount = Regex.Matches(commonMessage.Value, @"(?<!\{)\{([0-9]+).*?\}(?!})")
                                   .Cast <Match>().DefaultIfEmpty()
                                   .Max(m => m == null ? -1 : int.Parse(m.Groups[1].Value)) + 1;
                    commonMessageParts.Add(commonMessage.Key, bitCount);
                }
            }
        }
示例#24
0
 // Token: 0x06001B79 RID: 7033 RVA: 0x0008F88C File Offset: 0x0008DA8C
 protected virtual void Show(VRTK_SDKSetupSwitcher.ViewingState viewingState)
 {
     if (viewingState != VRTK_SDKSetupSwitcher.ViewingState.Status)
     {
         if (viewingState != VRTK_SDKSetupSwitcher.ViewingState.Selection)
         {
             VRTK_Logger.Fatal(new ArgumentOutOfRangeException("viewingState", viewingState, null));
             return;
         }
         this.AddSelectionButtons();
         this.selectionPanel.gameObject.SetActive(true);
         this.statusPanel.gameObject.SetActive(false);
     }
     else
     {
         this.RemoveCreatedChooseButtons();
         this.UpdateCurrentText();
         this.selectionPanel.gameObject.SetActive(false);
         this.statusPanel.gameObject.SetActive(true);
     }
     this.fallbackCamera.gameObject.SetActive(VRTK_DeviceFinder.HeadsetCamera() == null);
     this.eventSystem.gameObject.SetActive(EventSystem.current == null || EventSystem.current == this.eventSystem);
 }
示例#25
0
        private void ToggleBehaviours(bool state)
        {
            List <Behaviour> listCopy = _behavioursToToggleOnLoadedSetupChange.ToList();

            if (!state)
            {
                listCopy.Reverse();
            }

            for (int index = 0; index < listCopy.Count; index++)
            {
                Behaviour behaviour = listCopy[index];
                if (behaviour == null)
                {
                    VRTK_Logger.Error(string.Format("A behaviour to toggle has been destroyed. Have you forgot the corresponding call `VRTK_SDKManager.instance.RemoveBehaviourToToggleOnLoadedSetupChange(this)` in the `OnDestroy` method of `{0}`?", behaviour.GetType()));
                    _behavioursToToggleOnLoadedSetupChange.RemoveAt(state ? index : _behavioursToToggleOnLoadedSetupChange.Count - 1 - index);

                    continue;
                }

                behaviour.enabled = (state && _behavioursInitialState.ContainsKey(behaviour) ? _behavioursInitialState[behaviour] : state);
            }
        }
示例#26
0
 // Token: 0x0600153E RID: 5438 RVA: 0x0007532C File Offset: 0x0007352C
 protected virtual void OnEnable()
 {
     this.controllerAlias = this.originalControllerAlias;
     if (this.controllerAlias == null)
     {
         VRTK_TrackedController componentInParent = base.GetComponentInParent <VRTK_TrackedController>();
         this.controllerAlias = ((componentInParent != null) ? componentInParent.gameObject : null);
     }
     if (this.controllerAlias == null)
     {
         VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_NOT_INJECTED, new object[]
         {
             "VRTK_ControllerHighlighter",
             "Controller Alias GameObject",
             "controllerAlias",
             "the same"
         }));
         return;
     }
     this.ConfigureControllerPaths();
     this.modelContainer          = ((this.modelContainer != null) ? this.modelContainer : VRTK_DeviceFinder.GetModelAliasController(this.controllerAlias));
     this.initHighlightersRoutine = base.StartCoroutine(this.WaitForModel());
 }
示例#27
0
        private void SetBuildTarget(string groupName)
        {
            buildTargetGroupName = groupName;

#if UNITY_EDITOR
            Type buildTargetGroupType = typeof(BuildTargetGroup);
            try
            {
                buildTargetGroup = (BuildTargetGroup)Enum.Parse(buildTargetGroupType, groupName);
            }
            catch (Exception exception)
            {
                VRTK_Logger.Fatal(new ArgumentOutOfRangeException(string.Format("'{0}' isn't a valid constant name of '{1}'.", groupName, buildTargetGroupType.Name), exception));
                return;
            }

            if (buildTargetGroup == BuildTargetGroup.Unknown)
            {
                VRTK_Logger.Fatal(new ArgumentOutOfRangeException("groupName", groupName, string.Format("'{0}' isn't allowed.", groupName)));
                return;
            }
#endif
        }
示例#28
0
 // Token: 0x060015FF RID: 5631 RVA: 0x00077ED0 File Offset: 0x000760D0
 protected virtual void CreateTouchCollider()
 {
     if (this.customColliderContainer == null)
     {
         if (this.defaultColliderPrefab == null)
         {
             VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.SDK_OBJECT_NOT_FOUND, new object[]
             {
                 "default collider prefab",
                 "Controller SDK"
             }));
             return;
         }
         this.controllerCollisionDetector = (Object.Instantiate(this.defaultColliderPrefab, base.transform.position, base.transform.rotation) as GameObject);
         this.controllerCollisionDetector.transform.SetParent(base.transform);
         this.controllerCollisionDetector.transform.localScale = base.transform.localScale;
         this.controllerCollisionDetector.name = VRTK_SharedMethods.GenerateVRTKObjectName(true, new object[]
         {
             "Controller",
             "CollidersContainer"
         });
         this.destroyColliderOnDisable = true;
     }
     else if (this.CustomRigidBodyIsChild())
     {
         this.controllerCollisionDetector = this.customColliderContainer;
         this.destroyColliderOnDisable    = false;
     }
     else
     {
         this.controllerCollisionDetector = Object.Instantiate <GameObject>(this.customColliderContainer, base.transform.position, base.transform.rotation);
         this.controllerCollisionDetector.transform.SetParent(base.transform);
         this.controllerCollisionDetector.transform.localScale = base.transform.localScale;
         this.destroyColliderOnDisable = true;
     }
     this.controllerCollisionDetector.AddComponent <VRTK_PlayerObject>().objectType = VRTK_PlayerObject.ObjectTypes.Collider;
 }
示例#29
0
        protected override bool SetupListeners(bool throwError)
        {
            objectToMonitor = (objectToMonitor != null ? objectToMonitor : GetComponentInParent <VRTK_InteractableObject>());
            if (objectToMonitor != null)
            {
                objectToMonitor.SubscribeToInteractionEvent(VRTK_InteractableObject.InteractionType.NearTouch, NearTouchHighlightObject);
                objectToMonitor.SubscribeToInteractionEvent(VRTK_InteractableObject.InteractionType.NearUntouch, NearTouchUnHighlightObject);

                objectToMonitor.SubscribeToInteractionEvent(VRTK_InteractableObject.InteractionType.Touch, TouchHighlightObject);
                objectToMonitor.SubscribeToInteractionEvent(VRTK_InteractableObject.InteractionType.Untouch, TouchUnHighlightObject);

                objectToMonitor.SubscribeToInteractionEvent(VRTK_InteractableObject.InteractionType.Grab, GrabHighlightObject);
                objectToMonitor.SubscribeToInteractionEvent(VRTK_InteractableObject.InteractionType.Ungrab, GrabUnHighlightObject);

                objectToMonitor.SubscribeToInteractionEvent(VRTK_InteractableObject.InteractionType.Use, UseHighlightObject);
                objectToMonitor.SubscribeToInteractionEvent(VRTK_InteractableObject.InteractionType.Unuse, UseUnHighlightObject);
                return(true);
            }
            else if (throwError)
            {
                VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_FROM_GAMEOBJECT, "VRTK_InteractObjectHighlighter", "VRTK_InteractableObject", "the same or parent"));
            }
            return(false);
        }
示例#30
0
        private void CreateInstance()
        {
            if (_instance == null)
            {
                _instance = this;
                VRTK_SDK_Bridge.InvalidateCaches();

                string sdkErrorDescriptions = string.Join("\n- ", GetSimplifiedSDKErrorDescriptions());
                if (!string.IsNullOrEmpty(sdkErrorDescriptions))
                {
                    sdkErrorDescriptions = "- " + sdkErrorDescriptions;
                    VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.SDK_MANAGER_ERRORS, new string[] { sdkErrorDescriptions }));
                }

                if (persistOnLoad && !VRTK_SharedMethods.IsEditTime())
                {
                    DontDestroyOnLoad(gameObject);
                }
            }
            else if (_instance != this)
            {
                Destroy(gameObject);
            }
        }