Exemplo n.º 1
0
        // ------------------
        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:"));



            if ((curName.Length > 0) && !rig.IsJoystickDefined(curName, ref this.cachedJoyId))
            {
                menu.AddSeparator("");
                menu.AddItem(new GUIContent("Create \"" + curName + "\" joy config"), false, this.OnMenuCreateJoy, new JoyCreationParams(rig, curName));
            }



            menu.AddSeparator("");

            foreach (InputRig.VirtualJoystickConfig joy in rig.joysticks.list)
            {
                menu.AddItem(new GUIContent("Use \"" + joy.name + "\""), (joy.name == curName), this.OnMenuNameSelected, joy.name);
            }


            menu.ShowAsContext();
        }
Exemplo n.º 2
0
        // ------------------
        public string Draw(string label, string curName, InputRig rig)
        {
            EditorGUILayout.BeginHorizontal();

            string s = EditorGUILayout.TextField(label, curName, GUILayout.MinWidth(30));

            bool buttonPressed = false;

            if (rig == null)
            {
                GUILayout.Button(new GUIContent(string.Empty, "No rig attached!"), CFEditorStyles.Inst.iconError);
            }
            else if (!rig.IsJoystickDefined(s, ref this.cachedJoyId))
            {
                buttonPressed = GUILayout.Button(new GUIContent(string.Empty, "Joystick not found!"), CFEditorStyles.Inst.iconError);
            }
            else
            {
                buttonPressed = GUILayout.Button(new GUIContent(string.Empty, "Joystick name is ok!"), CFEditorStyles.Inst.iconOk);
            }

            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);
        }