或等于

作者: 叫我颜先生 | 来源:发表于2019-08-19 14:10 被阅读0次

|=:或等于
例如:
i |= true;
等价于
i = i | true;

    public class GamepadInput : MonoBehaviour, IInput
    {
        public float Acceleration
        {
            get { return m_Acceleration; }
        }
        public float Steering
        {
            get { return m_Steering; }
        }
        public bool BoostPressed
        {
            get { return m_BoostPressed; }
        }
        public bool FirePressed
        {
            get { return m_FirePressed; }
        }
        public bool HopPressed
        {
            get { return m_HopPressed; }
        }
        public bool HopHeld
        {
            get { return m_HopHeld; }
        }

        float m_Acceleration;
        float m_Steering;
        bool m_HopPressed;
        bool m_HopHeld;
        bool m_BoostPressed;
        bool m_FirePressed;

        bool m_FixedUpdateHappened;

        void Update ()
        {
            if (Input.GetButton ("Brake"))
                m_Acceleration = -1f;
            else if (Input.GetButton ("Accelerate"))
                m_Acceleration = 1f;
            else
                m_Acceleration = 0f;

            m_Steering = Input.GetAxis ("Horizontal");

            m_HopHeld = Input.GetButton ("Hop");

            if (m_FixedUpdateHappened)
            {
                m_FixedUpdateHappened = false;

                m_HopPressed = false;
                m_BoostPressed = false;
                m_FirePressed = false;
            }

            m_HopPressed |= Input.GetButtonDown ("Hop");
            m_BoostPressed |= Input.GetButtonDown ("Boost");
            m_FirePressed |= Input.GetButtonDown ("Fire");
        }

        void FixedUpdate ()
        {
            m_FixedUpdateHappened = true;
        }
    }

相关文章

网友评论

      本文标题:或等于

      本文链接:https://www.haomeiwen.com/subject/zhvssctx.html