Exemple #1
0
        protected virtual void OnEnable()
        {
            currentAxis      = Vector2.zero;
            storedAxis       = Vector2.zero;
            controllerEvents = (controller != null ? controller : GetComponentInParent <VRTK_ControllerEvents>());
            if (!controllerEvents)
            {
                VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_NOT_INJECTED, "VRTK_ObjectControl", "VRTK_ControllerEvents", "controller", "the same"));
                return;
            }
            SetControlledObject();
            bodyPhysics = (!controlOverrideObject ? (bodyPhysics != null ? bodyPhysics : FindObjectOfType <VRTK_BodyPhysics>()) : null);

            directionDevice = GetDirectionDevice();
            SetListeners(true);
            otherObjectControl = GetOtherControl();
        }
        protected virtual void OnEnable()
        {
            currentAxis      = Vector2.zero;
            storedAxis       = Vector2.zero;
            controllerEvents = (controller != null ? controller : GetComponent <VRTK_ControllerEvents>());
            if (!controllerEvents)
            {
                Debug.LogError("A `VRTK_ControllerEvents` script is required for the `VRTK_ObjectControl` script to work. Either the `controller` parameter is not set or no `VRTK_ControllerEvents` is attached to this GameObject.");
                return;
            }
            SetControlledObject();
            bodyPhysics = (!controlOverrideObject ? FindObjectOfType <VRTK_BodyPhysics>() : null);

            directionDevice = GetDirectionDevice();
            SetListeners(true);
            otherObjectControl = GetOtherControl();
        }