Exemple #1
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.DontSaveInEditor;            //HideFlags.HideAndDontSave;

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

            InputDeviceProfile[] profiles = new InputDeviceProfile[]
            {
                new Xbox360MacProfile(),
                new Xbox360WinProfile(),
                new OpenVRProfile(),
            };
            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 InputConsumerNode();

            s_EventTree.children.Add(new InputConsumerCallback {
                processEvent = s_Devices.RemapEvent
            });

            rewriters = new InputConsumerNode();
            s_EventTree.children.Add(rewriters);

            s_EventTree.children.Add(s_Devices);

            consumers = new InputConsumerNode();
            s_EventTree.children.Add(consumers);

            assignedPlayers = new InputConsumerNode();
            consumers.children.Add(assignedPlayers);

            // Global consumers should be processed last.
            globalPlayers = new InputConsumerNode();
            consumers.children.Add(globalPlayers);

            simulateMouseWithTouches = true;
        }
Exemple #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;
        }