コード例 #1
0
        public static ActionMapInput Create(ActionMap actionMap)
        {
            ActionMapInput map =
                (ActionMapInput)Activator.CreateInstance(actionMap.mapType, new object[] { actionMap });

            return(map);
        }
コード例 #2
0
        void DrawActionMapInput(ActionMapInput map)
        {
            EditorGUI.BeginDisabledGroup(!map.active);
            GUIContent mapContent = new GUIContent(map.actionMap.name);

            GUILayout.BeginVertical(mapContent, Styles.mapStyle);
            {
                LabelField("Block Subsequent", map.blockSubsequent.ToString());

                string schemeString = "-";
                if (map.active && map.controlScheme != null)
                {
                    schemeString = map.controlScheme.name;
                }
                LabelField("Current Control Scheme", schemeString);

                string devicesString = "";
                if (map.active)
                {
                    devicesString = string.Join(", ", map.GetCurrentlyUsedDevices().Select(e => e.name).ToArray());
                }
                if (string.IsNullOrEmpty(devicesString))
                {
                    devicesString = "-";
                }
                LabelField("Currently Used Devices", devicesString);
            }
            EditorGUILayout.EndVertical();
            EditorGUI.EndDisabledGroup();
        }
コード例 #3
0
        bool ProcessEventInMap(ActionMapInput map, InputEvent inputEvent)
        {
            if (map.ProcessEvent(inputEvent))
            {
                return(true);
            }

            if (!map.autoReinitialize)
            {
                return(false);
            }

            if (map.CurrentlyUsesDevice(inputEvent.device))
            {
                return(false);
            }

            // Only switch control scheme if devices in existing scheme weren't used for a little while,
            // to avoid rapid switching.
            if (inputEvent.time < map.GetLastDeviceInputTime() + m_AutoReinitializeMinDelay)
            {
                return(false);
            }

            // If this event uses a different device than the current control scheme
            // then try and initialize a control scheme that has that device.
            // Otherwise, leave the current current control scheme state alone
            // as a re-initialization of the same control scheme will cause a reset in the process.
            if (!map.TryInitializeWithDevices(GetApplicableDevices(), new List <InputDevice>()
            {
                inputEvent.device
            }))
            {
                return(false);
            }

            m_FirstMapToReceiveEvents = maps.IndexOf(map) + 1;
            map.SendControlResetEvents();
            m_FirstMapToReceiveEvents = 0;

            // When changing control scheme, we do not want to init control scheme to device states
            // like we normally want, so do a hard reset here, before processing the new event.
            map.Reset(false);

            return(map.ProcessEvent(inputEvent));
        }