Beispiel #1
0
        static public void MenuCreateTotalPackage()
        {
            UnityEngine.EventSystems.EventSystem
                sys = CreateEventSystem("CF2-Event-System", CreationMode.AskIfPresent, null);

            InputRig
                rig = TouchControlWizardUtils.CreateRig("CF2-Rig");

            Canvas
                canvas = TouchControlWizardUtils.CreateCanvas(rig, "CF2-Canvas");

            TouchControlWizardUtils.CreatePanel(rig, canvas, "CF2-Panel", new Rect(0, 0, 1, 1));

            GamepadManager
                gm = CreateGamepadManager(true, CreationMode.AskIfPresent, null);


            string undoLabel = "Create CF2 Total Package";

            if (sys != null)
            {
                Undo.RegisterCreatedObjectUndo(sys.gameObject, undoLabel);
            }
            if (gm != null)
            {
                Undo.RegisterCreatedObjectUndo(gm.gameObject, undoLabel);
            }

            Undo.RegisterCreatedObjectUndo(rig.gameObject, undoLabel);

            Selection.activeObject = rig;

            UnityInputManagerToRigDialog.ShowDialog(rig);
        }
Beispiel #2
0
        static public void MenuCreateInputRigWithPanel()
        {
            InputRig rig = TouchControlWizardUtils.CreateRig("CF2-Rig");

            Canvas canvas = TouchControlWizardUtils.CreateCanvas(rig, "CF2-Canvas");

            TouchControlWizardUtils.CreatePanel(rig, canvas, "CF2-Panel", new Rect(0, 0, 1, 1));

            Undo.RegisterCreatedObjectUndo(rig.gameObject, "Create CF2 Rig with Panel");

            Selection.activeObject = rig;

            UnityInputManagerToRigDialog.ShowDialog(rig);
        }
Beispiel #3
0
        // ----------------------------------
        static public UnityEngine.EventSystems.EventSystem CreateEventSystem(
            string name,
            CreationMode creationMode,
            string undoName = null)
        {
            int eventSysPresence = IsThereEventSystemInTheScene();

            if ((eventSysPresence != 0) && (creationMode == CreationMode.OnlyIfNotPresent))
            {
                return(null);
            }

            if ((eventSysPresence != 0) && (creationMode == CreationMode.AskIfPresent))
            {
                if (!EditorUtility.DisplayDialog("Control Freak 2 - Create Event System", (eventSysPresence == 1) ?
                                                 "There's a CF2 Event System in the scene already. Do you want to create a new one anyway?" :
                                                 "There's an Event System in the scene, but it isn't using CF2 Input Module. Do you want to create a new one anyway?", "Yes", "No"))
                {
                    return(null);
                }
            }

            UnityEngine.EventSystems.EventSystem eventSys =
                (UnityEngine.EventSystems.EventSystem)TouchControlWizardUtils.CreateObjectWithComponent(name, typeof(UnityEngine.EventSystems.EventSystem));

            eventSys.gameObject.AddComponent(typeof(ControlFreak2.GamepadInputModule));
            //eventSys.gameObject.AddComponent(typeof(ControlFreak2.MouseInputModule));

#if UNITY_PRE_5_3
            eventSys.gameObject.AddComponent(typeof(UnityEngine.EventSystems.TouchInputModule));
#endif

            UnityEngine.EventSystems.StandaloneInputModule standaloneModule =
                (UnityEngine.EventSystems.StandaloneInputModule)eventSys.gameObject.AddComponent(typeof(UnityEngine.EventSystems.StandaloneInputModule));

            standaloneModule.horizontalAxis = InputRig.CF_EMPTY_AXIS;
            standaloneModule.verticalAxis   = InputRig.CF_EMPTY_AXIS;
            standaloneModule.submitButton   = InputRig.CF_EMPTY_AXIS;
            standaloneModule.cancelButton   = InputRig.CF_EMPTY_AXIS;


            if (undoName != null)
            {
                Undo.RegisterCreatedObjectUndo(eventSys.gameObject, undoName);
            }

            return(eventSys);
        }
Beispiel #4
0
        // -------------------
        private InputRig GetCurrentlySelectedRig()
        {
            InputRig rig = TouchControlWizardUtils.GetRigFromSelection(this.selectedRig, true);

            if (rig == null)
            {
                rig = CF2Input.activeRig;
            }

            return(rig);

            //if (Selection.activeTransform == null)
            //	return null;

            //return Selection.activeTransform.GetComponent<InputRig>();
        }
Beispiel #5
0
        // ----------------------
        static public ControlFreak2.GamepadManager CreateGamepadManager(
            bool withNotifier,
            CreationMode creationMode,
            string undoLabel = null)
        {
            int gmPresence = IsThereGamepadManagerInTheScene();

            if ((gmPresence != 0) && (creationMode == CreationMode.OnlyIfNotPresent))
            {
                return(null);
            }

            if ((gmPresence != 0) && (creationMode == CreationMode.AskIfPresent))
            {
                string msg = null;
                msg = "There's a CF2 Gamepad Manager in the scene already. Do you want to create a new one anyway?";
                if (!EditorUtility.DisplayDialog("Control Freak 2 - Create Gamepad Manager", msg, "Yes", "No"))
                {
                    return(null);
                }
            }

            GamepadManager gm = null;

            gm = (GamepadManager)TouchControlWizardUtils.CreateObjectWithComponent("CF2-Gamepad-Manager", typeof(ControlFreak2.GamepadManager));
            if (gm == null)
            {
                return(null);
            }

            if (withNotifier)
            {
                ControlFreak2.GamepadNotifier gn = CreateGamepadNotifer("CF2-Gamepad-Notifier", null);
                if (gn != null)
                {
                    gn.transform.SetParent(gm.transform, false);
                }
            }

            if (undoLabel != null)
            {
                Undo.RegisterCreatedObjectUndo(gm.gameObject, undoLabel);
            }

            return(gm);
        }
Beispiel #6
0
        // ------------------------
        static public void CreateContextMenuForKeyBinding(Object panelOrRig, KeyCode key, System.Action onRefreshCallback = null)
        {
            InputRig          rig   = (panelOrRig as InputRig);
            TouchControlPanel panel = (panelOrRig as TouchControlPanel);

            string axisName = null;

            //bool displayPanelName = false;

            if (panel != null)
            {
                rig = panel.rig;
            }

            else if (rig != null)
            {
                // Auto Select panel...

                panel = TouchControlWizardUtils.GetRigPanel(rig);
                //displayPanelName = true;
            }
            else
            {
                return;
            }


            List <TouchControl> controlList = rig.GetTouchControls();


            GenericMenu menu = new GenericMenu();

            string commandName = (string.IsNullOrEmpty(axisName) ? ("\"" + key.ToString() + "\" keycode ") : ("\"" + axisName + "\" axis "));

            menu.AddDisabledItem(new GUIContent("Actions for : " + commandName));
            menu.AddSeparator("");



            {
                UniversalBindingAssignment.AddBindingContainerToMenu(menu, rig, onRefreshCallback, BindingDescription.BindingType.Digital, commandName,
                                                                     "Bind to Input Rig/", rig, key, null); //, null);


                menu.AddSeparator("");

                if (panel == null)
                {
                    menu.AddDisabledItem(new GUIContent("Add a Touch Control Panel to this rig to create and bind commands to Touch Controls!"));
                }
                else
                {
                    UniversalBindingAssignment.AddControlListBindingsToMenu(menu, controlList, onRefreshCallback,
                                                                            BindingDescription.BindingType.Digital, commandName, "Bind to Touch Controls/", key, null); // true); //, null);


                    menu.AddSeparator("");


                    AddTouchControlCreationItemsToMenuForAxisOrKey(menu, panel, null, key, onRefreshCallback);
                }
            }

            menu.ShowAsContext();
        }
Beispiel #7
0
        // ------------------------
        static public void CreateContextMenuForEmuTouchBinding(Object panelOrRig, System.Action onRefreshCallback = null)
        {
            InputRig          rig   = (panelOrRig as InputRig);
            TouchControlPanel panel = (panelOrRig as TouchControlPanel);

            //bool displayPanelName = false;

            if (panel != null)
            {
                rig = panel.rig;
            }

            else if (rig != null)
            {
                // Auto Select panel...

                panel = TouchControlWizardUtils.GetRigPanel(rig);
                //displayPanelName = true;
            }
            else
            {
                return;
            }


            List <TouchControl> controlList = rig.GetTouchControls();


            GenericMenu menu = new GenericMenu();


            string commandName = ("Emuulated Touch ");

            menu.AddDisabledItem(new GUIContent("Actions for : " + commandName));
            menu.AddSeparator("");

            UniversalBindingAssignment.AddBindingContainerToMenu(menu, rig, onRefreshCallback, BindingDescription.BindingType.EmuTouch, commandName,
                                                                 "Bind to Input Rig/", rig);

            menu.AddSeparator("");

            if (panel == null)
            {
                menu.AddDisabledItem(new GUIContent("Add a Touch Control Panel to this rig to create and bind commands to Touch Controls!"));
            }
            else
            {
                UniversalBindingAssignment.AddControlListBindingsToMenu(menu, controlList, onRefreshCallback,
                                                                        BindingDescription.BindingType.EmuTouch, commandName, "Bind to Touch Controls/");

                menu.AddSeparator("");



                WizardMenuItem.AddToMenu(menu, "Create a Super Touch Zone/Super Touch Zone with " + commandName + "bound to [Single-finger Touch]...", panel,
                                         typeof(SuperTouchZoneCreationWizard), SuperTouchZoneCreationWizard.BindingSetup.EmuTouch(1), onRefreshCallback);
                WizardMenuItem.AddToMenu(menu, "Create a Super Touch Zone/Super Touch Zone with " + commandName + "bound to [Two-finger Touch]...", panel,
                                         typeof(SuperTouchZoneCreationWizard), SuperTouchZoneCreationWizard.BindingSetup.EmuTouch(2), onRefreshCallback);


                menu.AddSeparator("Create a Super Touch Zone/");

                WizardMenuItem.AddToMenu(menu, "Create a Super Touch Zone/Super Touch Zone...", panel,
                                         typeof(SuperTouchZoneCreationWizard), null, onRefreshCallback);
            }

            menu.ShowAsContext();
        }
Beispiel #8
0
        // ------------------------
        static public void CreateContextMenuForMousePositionBinding(Object panelOrRig, System.Action onRefreshCallback = null)
        {
            InputRig          rig   = (panelOrRig as InputRig);
            TouchControlPanel panel = (panelOrRig as TouchControlPanel);

            //bool displayPanelName = false;

            if (panel != null)
            {
                rig = panel.rig;
            }

            else if (rig != null)
            {
                // Auto Select panel...

                panel = TouchControlWizardUtils.GetRigPanel(rig);
                //displayPanelName = true;
            }
            else
            {
                return;
            }


            List <TouchControl> controlList = rig.GetTouchControls();


            GenericMenu menu = new GenericMenu();


            string commandName = ("Mouse Position ");

            menu.AddDisabledItem(new GUIContent("Actions for : " + commandName));
            menu.AddSeparator("");

            UniversalBindingAssignment.AddBindingContainerToMenu(menu, rig, onRefreshCallback, BindingDescription.BindingType.MousePos, commandName,
                                                                 "Bind to Input Rig/", rig);

            menu.AddSeparator("");

            if (panel == null)
            {
                menu.AddDisabledItem(new GUIContent("Add a Touch Control Panel to this rig to create and bind commands to Touch Controls!"));
            }
            else
            {
                UniversalBindingAssignment.AddControlListBindingsToMenu(menu, controlList, onRefreshCallback,
                                                                        BindingDescription.BindingType.MousePos, commandName, "Bind to Touch Controls/");

                menu.AddSeparator("");



                int mouseTargetMaxId = CFUtils.GetEnumMaxValue(typeof(SuperTouchZoneCreationWizard.BindingSetup.MouseBindingTarget));

                for (int i = 1; i <= 2; ++i)
                {
                    for (int j = 1; j <= mouseTargetMaxId; ++j)
                    {
                        SuperTouchZoneCreationWizard.BindingSetup.MouseBindingTarget
                            mouseTarget = (SuperTouchZoneCreationWizard.BindingSetup.MouseBindingTarget)j;

                        WizardMenuItem.AddToMenu(menu, "Create a Super Touch Zone/Super Touch Zone with " + commandName + "bound to [" +
                                                 ((i == 1) ? "Single-finger" : "Two-finger") + mouseTarget.ToString() + "]...", panel, typeof(SuperTouchZoneCreationWizard),
                                                 SuperTouchZoneCreationWizard.BindingSetup.MousePos(i, mouseTarget), onRefreshCallback);
                    }
                }

                menu.AddSeparator("Create a Super Touch Zone/");

                WizardMenuItem.AddToMenu(menu, "Create a Super Touch Zone/Super Touch Zone...", panel,
                                         typeof(SuperTouchZoneCreationWizard), null, onRefreshCallback);
            }

            menu.ShowAsContext();
        }
Beispiel #9
0
        // ------------------------
        static public void CreateContextMenuForAxisBinding(Object panelOrRig, string axisName, /*InputRig.InputSource sourceType, */ System.Action onRefreshCallback = null)
        {
            InputRig          rig   = (panelOrRig as InputRig);
            TouchControlPanel panel = (panelOrRig as TouchControlPanel);

            //bool displayPanelName = false;

            if (panel != null)
            {
                rig = panel.rig;
            }

            else if (rig != null)
            {
                // Auto Select panel...

                panel = TouchControlWizardUtils.GetRigPanel(rig);
                //displayPanelName = true;
            }
            else
            {
                return;
            }


            List <TouchControl> controlList = rig.GetTouchControls();


            GenericMenu menu = new GenericMenu();


            string commandName = ("\"" + axisName + "\" axis ");

            menu.AddDisabledItem(new GUIContent("Actions for : " + commandName));
            menu.AddSeparator("");


            InputRig.AxisConfig axisConfig = rig.GetAxisConfig(axisName);
            if (axisConfig == null)
            {
                AxisCreationMenuItem.AddAllMenuItems(menu, axisName, "", rig, onRefreshCallback);
            }

            else
            {
                int
                    axisSourceTypeMask = axisConfig.GetSupportedInputSourceMask();
                BindingDescription.BindingType
                    bindingTypeMask = BindingDescription.BindingType.Axis | BindingDescription.BindingType.Digital;


                UniversalBindingAssignment.AddBindingContainerToMenu(menu, rig, onRefreshCallback, bindingTypeMask, commandName,
                                                                     "Bind to Input Rig/", rig, KeyCode.None, axisName, axisSourceTypeMask); //, true); //, null);

                menu.AddSeparator("");

                if (panel == null)
                {
                    menu.AddDisabledItem(new GUIContent("Add a Touch Control Panel to this rig to create and bind commands to Touch Controls!"));
                }
                else
                {
                    UniversalBindingAssignment.AddControlListBindingsToMenu(menu, controlList, onRefreshCallback,
                                                                            bindingTypeMask, commandName, "Bind to Touch Controls/", KeyCode.None, axisName); //, true); //, null);

                    menu.AddSeparator("");

                    AddTouchControlCreationItemsToMenuForAxisOrKey(menu, panel, axisName, KeyCode.None, onRefreshCallback);
                }
            }

            menu.ShowAsContext();
        }