Exemple #1
0
        /// <summary>
        /// 毎フレーム実行される更新処理
        /// </summary>
        void Update()
        {
            if (_keyMap == null)
            {
                return;
            }

            KeyData         keyData;
            PlayerInputData inputData;
            float           unscaledTime = Time.unscaledTime;

            foreach (var pair in _events)
            {
                inputData = pair.Value.InputData;

                if (!_keyMap.TryGetKeyData(inputData.KeyId, out keyData))
                {
                    continue;
                }

                if (!keyData.use)
                {
                    continue;
                }

                inputData.inputState = GetInputState(keyData.code);

                // 押下
                if (inputData.IsPressed)
                {
                    inputData.holding   = false;
                    inputData.pressTime = unscaledTime;

                    pair.Value.Send();

                    inputData.useHoldThreshold = true;
                }

                // 離上
                if (inputData.IsReleased)
                {
                    inputData.holding          = false;
                    inputData.holdTime         = 0;
                    inputData.useHoldThreshold = false;

                    pair.Value.Send();
                }

                // 押下中
                if (inputData.holding)
                {
                    inputData.holdTime = unscaledTime - inputData.pressTime;
                    pair.Value.Send();
                }
                // 押下中に移行する前
                else if (inputData.useHoldThreshold)
                {
                    float delta = unscaledTime - inputData.pressTime;
                    if (delta > _delayHold)
                    {
                        pair.Value.Send();

                        inputData.holding          = true;
                        inputData.holdTime         = 0;
                        inputData.useHoldThreshold = false;
                    }
                }
            }
        }