コード例 #1
0
        internal void Register(AbstractUIInput inputHandler)
        {
            AbstractUIInput existingRegistered;

            if (m_AllInputs.TryGetValue(inputHandler.InputNameKey, out existingRegistered))
            {
                if (existingRegistered != inputHandler)
                {
                    StringBuilder pathBuilder = new StringBuilder();
                    string        input1Path  = inputHandler.PrintDebugHierarchy(pathBuilder).ToString();

                    pathBuilder.Length = 0;
                    string input2Path = existingRegistered.PrintDebugHierarchy(pathBuilder).ToString();

                    throw new InvalidOperationException(String.Format("Duplicate inputs registered for key: {0}. Input 1: {1} Input 2: {2}", inputHandler.InputNameKey, input1Path, input2Path));
                }
                return;
            }

            m_AllInputs.Add(inputHandler.InputNameKey, inputHandler);

            m_Axies.AddIfImplements(inputHandler.InputNameKey, inputHandler);
            m_Buttons.AddIfImplements(inputHandler.InputNameKey, inputHandler);

            IInputButton btn = inputHandler as IInputButton;

            if (btn != null)
            {
                btn.OnPress -= HandleOnInputButtonPressed;
                btn.OnPress += HandleOnInputButtonPressed;
            }
        }
コード例 #2
0
        internal void Unregister(AbstractUIInput inputHandler)
        {
            m_AllInputs.RemoveIfExists(inputHandler.InputNameKey, inputHandler);

            m_Axies.RemoveIfExistsAndImplements(inputHandler.InputNameKey, inputHandler);
            m_Buttons.RemoveIfExistsAndImplements(inputHandler.InputNameKey, inputHandler);

            IInputButton btn = inputHandler as IInputButton;

            if (btn != null)
            {
                btn.OnPress -= HandleOnInputButtonPressed;
                btn.OnPress += HandleOnInputButtonPressed;
            }
        }