コード例 #1
0
        // Unsubscribes from various events
        void OnDisable()
        {
            if (controllerAdapter != null)
            {
                controllerAdapter.jumpVelocitySet -= m_MovementEffects.Jumped;
                controllerAdapter.landed          -= m_MovementEffects.Landed;
                controllerAdapter.landed          -= OnLanding;
            }

            if (m_Motor != null)
            {
                if (thirdPersonInput != null)
                {
                    ThirdPersonInput userInput = thirdPersonInput as ThirdPersonInput;
                    if (userInput != null)
                    {
                        userInput.jumpPressed   -= m_Motor.OnJumpPressed;
                        userInput.sprintStarted -= m_Motor.ToggleSprint;
                        userInput.sprintEnded   -= m_Motor.StopSprint;
                        userInput.strafeStarted -= OnStrafeStarted;
                        userInput.strafeEnded   -= OnStrafeEnded;
                    }
                }

                m_Motor.jumpStarted -= OnJumpStarted;
                m_Motor.fallStarted -= OnFallStarted;
                m_Motor.Unsubscribe();
            }

            m_MovementEffects.Unsubscribe();
        }
コード例 #2
0
        // Subscribes to various events
        protected override void OnEnable()
        {
            base.OnEnable();
            controllerAdapter.jumpVelocitySet += m_MovementEffects.Jumped;
            controllerAdapter.landed          += m_MovementEffects.Landed;
            controllerAdapter.landed          += OnLanding;

            m_Motor.jumpStarted += OnJumpStarted;
            m_Motor.fallStarted += OnFallStarted;
            m_Motor.Subscribe();

            if (thirdPersonInput != null)
            {
                ThirdPersonInput userInput = thirdPersonInput as ThirdPersonInput;
                if (userInput != null)
                {
                    userInput.jumpPressed   += m_Motor.OnJumpPressed;
                    userInput.sprintStarted += m_Motor.ToggleSprint;
                    userInput.sprintEnded   += m_Motor.StopSprint;
                    userInput.strafeStarted += OnStrafeStarted;
                    userInput.strafeEnded   += OnStrafeEnded;
                }
            }

            m_MovementEffects.Subscribe();
        }