internal PlayerHandle(int index)
        {
            this.index = index;

            treeNode = new InputEventTree
            {
                name         = "Player " + index,
                processInput = ProcessEvent,
                beginFrame   = BeginFrameEvent,
                endFrame     = EndFrameEvent
            };
            currentInputConsumer.children.Add(treeNode);

            if (onChange != null)
            {
                onChange.Invoke();
            }
        }
Beispiel #2
0
        // For now, initialize prototype stuff here.
        // This should not be included here in final code.
        static InputSystem()
        {
            s_Devices = new InputDeviceManager();

            GameObject go = new GameObject("Input Prototype Controller");

            go.hideFlags = HideFlags.HideAndDontSave;

            go.AddComponent <InputManager>();
            go.AddComponent <InputManagerEndFrame>();
            go.AddComponent <JoystickInputToEvents>();
            go.AddComponent <MouseInputToEvents>();
            go.AddComponent <KeyboardInputToEvents>();
            go.AddComponent <TouchInputToEvents>();
            go.AddComponent <ExecuteAllEvents>();

            InputDeviceProfile[] profiles = new InputDeviceProfile[]
            {
                new Xbox360MacProfile(),
                new Xbox360WinProfile()
            };
            s_EventQueue = new InputEventQueue();
            s_EventPool  = new InputEventPool();

            foreach (var profile in profiles)
            {
                RegisterProfile(profile);
            }

            s_Devices.InitAfterProfiles();

            // Set up event tree.
            s_EventTree = new InputEventTree {
                name = "Root"
            };

            var remap = new InputEventTree
            {
                name         = "Remap",
                processInput = s_Devices.RemapEvent
            };

            s_EventTree.children.Add(remap);

            rewriterStack = new InputEventTree
            {
                name    = "Rewriters",
                isStack = true
            };
            s_EventTree.children.Add(rewriterStack);

            var state = new InputEventTree
            {
                name         = "State",
                processInput = s_Devices.ProcessEvent,
                beginFrame   = s_Devices.BeginFrameEvent
            };

            s_EventTree.children.Add(state);

            consumerStack = new InputEventTree
            {
                name    = "Consumers",
                isStack = true
            };
            s_EventTree.children.Add(consumerStack);

            // Global consumer stack should come first in stack so it's processed last.
            globalPlayers = new InputEventTree
            {
                name    = "Global Players",
                isStack = true
            };
            consumerStack.children.Add(globalPlayers);

            assignedPlayers = new InputEventTree
            {
                name    = "Assigned Players",
                isStack = true
            };
            consumerStack.children.Add(assignedPlayers);

            simulateMouseWithTouches = true;
        }