public string Draw(GUIContent labelContent, string curName, InputRig rig)
        {
            EditorGUILayout.BeginHorizontal();

            if (labelContent.text.Length > 0)
            {
                EditorGUILayout.LabelField(labelContent);         //, GUILayout.Width(40));
            }
            string s = EditorGUILayout.TextField(curName, GUILayout.MinWidth(20), GUILayout.ExpandWidth(true));

            bool buttonPressed = false;

            InputRig.AxisConfig axisConfig = (rig == null) ? null : rig.GetAxisConfig(s, ref this.cachedAxisId);

            float buttonWidth = 16;
            //float buttonHeight = 16;

            GUIContent buttonContent;

            if (rig == null)
            {
                buttonContent = new GUIContent(string.Empty, CFEditorStyles.Inst.texError, "No rig attached!");
            }
            else if (axisConfig == null)
            {
                buttonContent = new GUIContent(string.Empty, CFEditorStyles.Inst.texError, "Axis not found!");         //, CFEditorStyles.Inst.iconError);
            }
            else if (!axisConfig.DoesSupportInputSource(this.inputSource))
            {
                buttonContent = new GUIContent(string.Empty, CFEditorStyles.Inst.texWarning, "Target axis is incompatible!");         //, CFEditorStyles.Inst.iconOkWarning);
            }
            else
            {
                buttonContent = new GUIContent(string.Empty, CFEditorStyles.Inst.texOk, "Axis name is ok!");                    //, CFEditorStyles.Inst.iconOk);
            }
            buttonPressed = GUILayout.Button(buttonContent, CFEditorStyles.Inst.iconButtonStyle, GUILayout.Width(buttonWidth)); //, GUILayout.Height(buttonHeight));


            EditorGUILayout.EndHorizontal();

            // Show context menu...

            if (buttonPressed)
            {
                this.ShowContextMenu(s, rig);
            }

            // Apply the name selected via context menu..

            if (this.menuSelectedName != null)
            {
                s = this.menuSelectedName;
                this.menuSelectedName = null;

                EditorGUI.FocusTextInControl("");
            }

            return(s);
        }
Ejemplo n.º 2
0
            // -----------------
            public void ApplyToRig(InputRig rig, bool skipIfTargetIsMuted)
            {
                InputRig.AxisConfig a = rig.GetAxisConfig(this.axisName, ref this.cachedAxisId);
                if (a == null)
                {
                    return;
                }

                if (!skipIfTargetIsMuted || !a.IsMuted())
                {
                    a.SetSignedDigital(this.axisPositiveSide);
                }
                //rig.SetAxisDigital(this.axisName, ref this.cachedAxisId, !this.axisPositiveSide);
            }
Ejemplo n.º 3
0
        void XXX()
        {
            InputRig rig = CF2Input.activeRig;

            if (rig != null)
            {
                InputRig.AxisConfig config = rig.GetAxisConfig("YourAxisName");
                if (config != null)
                {
                    config.keyboardPositive     = KeyCode.A;
                    config.keyboardPositiveAlt0 = KeyCode.B;
                    config.keyboardPositiveAlt1 = KeyCode.C;
                    config.keyboardPositiveAlt2 = KeyCode.D;

                    config.keyboardPositive     = KeyCode.E;
                    config.keyboardPositiveAlt0 = KeyCode.F;
                    config.keyboardPositiveAlt1 = KeyCode.G;
                    config.keyboardPositiveAlt2 = KeyCode.H;
                }
            }
        }
        // ------------------
        private void ShowContextMenu(string curName, InputRig rig)
        {
            if (rig == null)
            {
                return;
            }


            GenericMenu menu = new GenericMenu();

            menu.AddItem(new GUIContent("Select rig"), false, this.OnMenuSelectRig, rig);

            //menu.AddDisabledItem(new GUIContent("Available axes:"));


            InputRig.AxisConfig axisConfig = rig.GetAxisConfig(curName, ref this.cachedAxisId);
            if ((curName.Length > 0) && (axisConfig == null))
            {
                menu.AddSeparator("");
                menu.AddItem(new GUIContent("Create \"" + curName + "\" Digital Axis"), false, this.OnMenuCreateAxis, new AxisCreationParams(rig, curName, InputRig.AxisType.Digital));
                menu.AddItem(new GUIContent("Create \"" + curName + "\" Unsigned Analog Axis"), false, this.OnMenuCreateAxis, new AxisCreationParams(rig, curName, InputRig.AxisType.UnsignedAnalog));
                menu.AddItem(new GUIContent("Create \"" + curName + "\" Signed Analog Axis"), false, this.OnMenuCreateAxis, new AxisCreationParams(rig, curName, InputRig.AxisType.SignedAnalog));
                menu.AddItem(new GUIContent("Create \"" + curName + "\" Delta"), false, this.OnMenuCreateAxis, new AxisCreationParams(rig, curName, InputRig.AxisType.Delta));
                menu.AddItem(new GUIContent("Create \"" + curName + "\" Scroll"), false, this.OnMenuCreateAxis, new AxisCreationParams(rig, curName, InputRig.AxisType.ScrollWheel));
            }


            menu.AddSeparator("");
            for (int i = 0; i < rig.axes.list.Count; ++i)
            {
                InputRig.AxisConfig axis = rig.axes.list[i];

                if (axis.DoesSupportInputSource(this.inputSource))
                {
                    menu.AddItem(new GUIContent("Use \"" + axis.name + "\""), (axis.name == curName), this.OnMenuNameSelected, axis.name);
                }
            }

            menu.ShowAsContext();
        }
Ejemplo n.º 5
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();
        }