public void ClearConnectionMenu()
    {
        GenericMenu menu = new GenericMenu ();

        menu.AddSeparator ("ARE YOU SURE YOU WANT TO CLEAR?");
        menu.AddSeparator ("");
        menu.AddItem(new GUIContent ("Clear"), false, ClearConnections, "");
        menu.AddItem(new GUIContent ("Don't Clear"), false, DontClearConnections, "");

        menu.ShowAsContext ();
    }
    protected override void showContextMenu(Behaviour behaviour)
    {
        CinemaActorClipCurve clipCurve = behaviour as CinemaActorClipCurve;
        if (clipCurve == null) return;

        List<KeyValuePair<string, string>> currentCurves = new List<KeyValuePair<string, string>>();
        foreach (MemberClipCurveData data in clipCurve.CurveData)
        {
            KeyValuePair<string, string> curveStrings = new KeyValuePair<string, string>(data.Type, data.PropertyName);
            currentCurves.Add(curveStrings);
        }

        GenericMenu createMenu = new GenericMenu();

        if (clipCurve.Actor != null)
        {
            Component[] components = DirectorHelper.getValidComponents(clipCurve.Actor.gameObject);

            for (int i = 0; i < components.Length; i++)
            {
                Component component = components[i];
                MemberInfo[] members = DirectorHelper.getValidMembers(component);
                for (int j = 0; j < members.Length; j++)
                {
                    AddCurveContext context = new AddCurveContext();
                    context.clipCurve = clipCurve;
                    context.component = component;
                    context.memberInfo = members[j];
                    if (!currentCurves.Contains(new KeyValuePair<string, string>(component.GetType().Name, members[j].Name)))
                    {
                        createMenu.AddItem(new GUIContent(string.Format("Add Curve/{0}/{1}", component.GetType().Name, DirectorHelper.GetUserFriendlyName(component, members[j]))), false, addCurve, context);
                    }
                }
            }
            createMenu.AddSeparator(string.Empty);
        }
        createMenu.AddItem(new GUIContent("Copy"), false, copyItem, behaviour);
        createMenu.AddSeparator(string.Empty);
        createMenu.AddItem(new GUIContent("Clear"), false, deleteItem, clipCurve);
        createMenu.ShowAsContext();
    }
    protected override void showContextMenu(Behaviour behaviour)
    {
        CinemaShot shot = behaviour as CinemaShot;
        if (shot == null) return;

        Camera[] cameras = GameObject.FindObjectsOfType<Camera>();
        
        GenericMenu createMenu = new GenericMenu();
        createMenu.AddItem(new GUIContent("Focus"), false, focusShot, shot);
        foreach (Camera c in cameras)
        {
            
            ContextSetCamera arg = new ContextSetCamera();
            arg.shot = shot;
            arg.camera = c;
            createMenu.AddItem(new GUIContent(string.Format(MODIFY_CAMERA, c.gameObject.name)), false, setCamera, arg);
        }
        createMenu.AddSeparator(string.Empty);
        createMenu.AddItem(new GUIContent("Copy"), false, copyItem, behaviour);
        createMenu.AddSeparator(string.Empty);
        createMenu.AddItem(new GUIContent("Clear"), false, deleteItem, shot);
        createMenu.ShowAsContext();
    }
예제 #4
0
	void Selector(SerializedProperty property) {
		SpineSlot attrib = (SpineSlot)attribute;
		SkeletonData data = skeletonDataAsset.GetSkeletonData(true);
		if (data == null)
			return;

		GenericMenu menu = new GenericMenu();

		menu.AddDisabledItem(new GUIContent(skeletonDataAsset.name));
		menu.AddSeparator("");

		for (int i = 0; i < data.Slots.Count; i++) {
			string name = data.Slots.Items[i].Name;
			if (name.StartsWith(attrib.startsWith)) {
				if (attrib.containsBoundingBoxes) {

					int slotIndex = i;

					List<Attachment> attachments = new List<Attachment>();
					foreach (var skin in data.Skins) {
						skin.FindAttachmentsForSlot(slotIndex, attachments);
					}

					bool hasBoundingBox = false;
					foreach (var attachment in attachments) {
						if (attachment is BoundingBoxAttachment) {
							menu.AddItem(new GUIContent(name), name == property.stringValue, HandleSelect, new SpineDrawerValuePair(name, property));
							hasBoundingBox = true;
							break;
						}
					}

					if (!hasBoundingBox)
						menu.AddDisabledItem(new GUIContent(name));
					

				} else {
					menu.AddItem(new GUIContent(name), name == property.stringValue, HandleSelect, new SpineDrawerValuePair(name, property));
				}
				
			}
				
		}

		menu.ShowAsContext();
	}
예제 #5
0
        protected virtual void TestContextClickCallback(int id)
        {
            if (id == 0)
            {
                return;
            }

            var m                  = new GenericMenu();
            var testFilters        = GetSelectedTestsAsFilter(m_TestListState.selectedIDs);
            var multilineSelection = m_TestListState.selectedIDs.Count > 1;

            if (!multilineSelection)
            {
                var testNode   = GetSelectedTest();
                var isNotSuite = !testNode.IsGroupNode;
                if (isNotSuite)
                {
                    if (!string.IsNullOrEmpty(m_ResultStacktrace))
                    {
                        m.AddItem(s_GUIOpenErrorLine,
                                  false,
                                  data =>
                        {
                            if (!GuiHelper.OpenScriptInExternalEditor(m_ResultStacktrace))
                            {
                                GuiHelper.OpenScriptInExternalEditor(testNode.type, testNode.method);
                            }
                        },
                                  "");
                    }

                    m.AddItem(s_GUIOpenTest,
                              false,
                              data => GuiHelper.OpenScriptInExternalEditor(testNode.type, testNode.method),
                              "");
                    m.AddSeparator("");
                }
            }

            if (!IsBusy())
            {
                m.AddItem(multilineSelection ? s_GUIRunSelectedTests : s_GUIRun,
                          false,
                          data => RunTests(testFilters),
                          "");

                if (EditorPrefs.GetBool("DeveloperMode", false))
                {
                    m.AddItem(multilineSelection ? s_GUIRunSelectedTests : s_GUIRunUntilFailed,
                              false,
                              data =>
                    {
                        foreach (var filter in testFilters)
                        {
                            filter.testRepetitions = int.MaxValue;
                        }

                        RunTests(testFilters);
                    },
                              "");

                    m.AddItem(multilineSelection ? s_GUIRunSelectedTests : s_GUIRun100Times,
                              false,
                              data =>
                    {
                        foreach (var filter in testFilters)
                        {
                            filter.testRepetitions = 100;
                        }

                        RunTests(testFilters);
                    },
                              "");
                }
            }
            else
            {
                m.AddDisabledItem(multilineSelection ? s_GUIRunSelectedTests : s_GUIRun, false);
            }

            m.ShowAsContext();
        }
예제 #6
0
	private void RenderLayerMenu(Event curEvent)
	{
		GenericMenu menu = new GenericMenu();
		string[] layerArray = GetLayerList();
		
		menu.AddItem(new GUIContent("Nothing"),false,LayerMenuItemCallback,-2);
		
		menu.AddItem(new GUIContent("Everything"),false,LayerMenuItemCallback,-1);
		
		menu.AddSeparator(string.Empty);
		
		bool selected = false;
		for(int i = 0; i < 32; i++)
		{
			if(layerArray[i] != string.Empty)
			{
				selected = false;
				
				if( ((1 << i) & window.liveTemplate.layerIndex) == (1 << i) )
					selected = true;

				menu.AddItem(new GUIContent( layerArray[i] ) ,selected,LayerMenuItemCallback, (1 << i));
			}
		}
		
		menu.ShowAsContext();
		
		curEvent.Use();
	}
예제 #7
0
        public static GenericMenu CreateNodeContextMenu(BTEditorGraphNode targetNode)
        {
            GenericMenu menu        = new GenericMenu();
            bool        canAddChild = false;

            if (targetNode.Node is Composite)
            {
                canAddChild = true;
            }
            else if (targetNode.Node is NodeGroup)
            {
                canAddChild = ((NodeGroup)targetNode.Node).GetChild() == null && targetNode.IsRoot;
            }
            else if (targetNode.Node is Decorator)
            {
                canAddChild = ((Decorator)targetNode.Node).GetChild() == null;
            }

            if (!targetNode.Graph.ReadOnly)
            {
                if (canAddChild)
                {
                    BTNodeFactory.AddChild(menu, targetNode);
                }

                BTConstraintFactory.AddConstraint(menu, targetNode.Node);

                if (!(targetNode.Node is NodeGroup))
                {
                    BTNodeFactory.SwitchType(menu, targetNode);
                }

                if (canAddChild || !(targetNode.Node is NodeGroup))
                {
                    menu.AddSeparator("");
                }

                if (targetNode.IsRoot)
                {
                    menu.AddDisabledItem(new GUIContent("Copy"));
                    menu.AddDisabledItem(new GUIContent("Cut"));
                }
                else
                {
                    menu.AddItem(new GUIContent("Copy"), false, () => targetNode.Graph.OnCopyNode(targetNode));
                    menu.AddItem(new GUIContent("Cut"), false, () =>
                    {
                        targetNode.Graph.OnCopyNode(targetNode);
                        targetNode.Graph.OnNodeDelete(targetNode);
                    });
                }

                if (targetNode.Graph.CanPaste(targetNode))
                {
                    menu.AddItem(new GUIContent("Paste"), false, () => targetNode.Graph.OnPasteNode(targetNode));
                }
                else
                {
                    menu.AddDisabledItem(new GUIContent("Paste"));
                }

                if (targetNode.IsRoot)
                {
                    menu.AddDisabledItem(new GUIContent("Delete"));
                }
                else
                {
                    menu.AddItem(new GUIContent("Delete"), false, () => targetNode.Graph.OnNodeDelete(targetNode));
                }

                if (targetNode.Node is Composite)
                {
                    if (((Composite)targetNode.Node).ChildCount > 0)
                    {
                        menu.AddItem(new GUIContent("Delete Children"), false, () => targetNode.Graph.OnNodeDeleteChildren(targetNode));
                    }
                    else
                    {
                        menu.AddDisabledItem(new GUIContent("Delete Children"));
                    }
                }
                else if (targetNode.Node is NodeGroup)
                {
                    if (targetNode.IsRoot)
                    {
                        if (((NodeGroup)targetNode.Node).GetChild() != null)
                        {
                            menu.AddItem(new GUIContent("Delete Child"), false, () => targetNode.Graph.OnNodeDeleteChildren(targetNode));
                        }
                        else
                        {
                            menu.AddDisabledItem(new GUIContent("Delete Child"));
                        }
                    }
                }
                else if (targetNode.Node is Decorator)
                {
                    if (((Decorator)targetNode.Node).GetChild() != null)
                    {
                        menu.AddItem(new GUIContent("Delete Child"), false, () => targetNode.Graph.OnNodeDeleteChildren(targetNode));
                    }
                    else
                    {
                        menu.AddDisabledItem(new GUIContent("Delete Child"));
                    }
                }

                menu.AddSeparator("");
            }

            foreach (Breakpoint item in Enum.GetValues(typeof(Breakpoint)))
            {
                menu.AddItem(new GUIContent("Breakpoint/" + item.ToString()), targetNode.Node.Breakpoint.Has(item), (obj) =>
                {
                    Breakpoint option = (Breakpoint)obj;
                    if (option == Breakpoint.None)
                    {
                        targetNode.Node.Breakpoint = Breakpoint.None;
                    }
                    else
                    {
                        if (targetNode.Node.Breakpoint.Has(option))
                        {
                            targetNode.Node.Breakpoint = targetNode.Node.Breakpoint.Remove(option);
                        }
                        else
                        {
                            if (targetNode.Node.Breakpoint == Breakpoint.None)
                            {
                                targetNode.Node.Breakpoint = option;
                            }
                            else
                            {
                                targetNode.Node.Breakpoint = targetNode.Node.Breakpoint.Add(option);
                            }
                        }
                    }
                }, item);
            }

            return(menu);
        }
예제 #8
0
    void OnContextMenu()
    {
        Event evt = Event.current;
        if(evt.type == EventType.ContextClick){
            GenericMenu menu = new GenericMenu();
            if(!HasFSM()){
              	menu.AddItem (new GUIContent ("AttachFSM"), false, AttachFSM, evt.mousePosition);
            } else {
                menu.AddItem (new GUIContent ("Add/NewState/ChangeColor"), false, AddState,evt.mousePosition);
           	}
            menu.AddSeparator("");
            menu.AddItem (new GUIContent ("Purge"), false, Purge, evt.mousePosition);
            menu.ShowAsContext ();
            evt.Use();
            Debug.Log("OnContextMenu::ContextClick");
        }

        //menu.AddItem (new GUIContent ("Add/NewTransition/Timer"), false, AddTransition, evt.mousePosition);
    }
예제 #9
0
파일: APPWindow.cs 프로젝트: kinifi/LE_IM
    void OnGUI()
    {
        GUIStyle boldNumberFieldStyle = new GUIStyle(EditorStyles.numberField);
        boldNumberFieldStyle.font = EditorStyles.boldFont;

        GUIStyle boldToggleStyle = new GUIStyle(EditorStyles.toggle);
        boldToggleStyle.font = EditorStyles.boldFont;

        GUI.enabled = !waitTillPlistHasBeenWritten;

        //Toolbar
        EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
        {
            Rect optionsRect = GUILayoutUtility.GetRect(0, 20, GUILayout.ExpandWidth(false));

            if (GUILayout.Button(new GUIContent("Sort   " + (sortAscending ? "▼" : "▲"), "Change sorting to " + (sortAscending ? "descending" : "ascending")), EditorStyles.toolbarButton, GUILayout.ExpandWidth(false)))
            {
                OnChangeSortModeClicked();
            }

            if (GUILayout.Button(new GUIContent("Options", "Contains additional functionality like \"Add new entry\" and \"Delete all entries\" "), EditorStyles.toolbarDropDown, GUILayout.ExpandWidth(false)))
            {
                GenericMenu options = new GenericMenu();
                options.AddItem(new GUIContent("New Entry..."), false, OnNewEntryClicked);
                options.AddSeparator("");
                options.AddItem(new GUIContent("Import..."), false, OnImport);
                options.AddItem(new GUIContent("Export Selected..."), false, OnExportSelected);
                options.AddItem(new GUIContent("Export All Entries"), false, OnExportAllClicked);
                options.AddSeparator("");
                options.AddItem(new GUIContent("Delete Selected Entries"), false, OnDeleteSelectedClicked);
                options.AddItem(new GUIContent("Delete All Entries"), false, OnDeleteAllClicked);
                options.DropDown(optionsRect);
            }

            GUILayout.Space(5);

            //Searchfield
            Rect position = GUILayoutUtility.GetRect(50, 250, 10, 50,EditorStyles.toolbarTextField);
            position.width -= 16;
            position.x += 16;
            SearchString = GUI.TextField(position, SearchString, EditorStyles.toolbarTextField);

            position.x = position.x - 18;
            position.width = 20;
            if (GUI.Button(position, "", ToolbarSeachTextFieldPopup))
            {
                GenericMenu options = new GenericMenu();
                options.AddItem(new GUIContent("All"), SearchFilter == SearchFilterType.All, OnSearchAllClicked);
                options.AddItem(new GUIContent("Key"), SearchFilter == SearchFilterType.Key, OnSearchKeyClicked);
                options.AddItem(new GUIContent("Value (Strings only)"), SearchFilter == SearchFilterType.Value , OnSearchValueClicked);
                options.DropDown(position);
            }

            position = GUILayoutUtility.GetRect(10, 10, ToolbarSeachCancelButton);
            position.x -= 5;
            if (GUI.Button(position, "", ToolbarSeachCancelButton))
            {
                SearchString = string.Empty;
            }

            GUILayout.FlexibleSpace();

            if (Application.platform == RuntimePlatform.WindowsEditor)
            {
                string refreshTooltip = "Should all entries be automaticly refreshed every " + UpdateIntervalInSeconds + " seconds?";
                autoRefresh = GUILayout.Toggle(autoRefresh, new GUIContent("Auto Refresh ", refreshTooltip), EditorStyles.toolbarButton, GUILayout.ExpandWidth(false), GUILayout.MinWidth(75));
            }

            if (GUILayout.Button(new GUIContent(RefreshIcon, "Force a refresh, could take a few seconds."), EditorStyles.toolbarButton, GUILayout.ExpandWidth(false), GUILayout.ExpandHeight(false)))
            {
                RefreshKeys();
            }

            Rect r;
            if (Application.platform == RuntimePlatform.OSXEditor)
                r = GUILayoutUtility.GetRect(16, 16);
            else
                r = GUILayoutUtility.GetRect(9, 16);

            if (waitTillPlistHasBeenWritten)
            {
                Texture2D t = AssetDatabase.LoadAssetAtPath(IconsPath + "loader/" + (Mathf.FloorToInt(rotation % 12) + 1) + ".png", typeof(Texture2D)) as Texture2D;

                GUI.DrawTexture(new Rect(r.x + 3, r.y, 16, 16), t);
            }
        }
        EditorGUILayout.EndHorizontal();

        GUI.enabled = !waitTillPlistHasBeenWritten;

        if (showNewEntryBox)
        {
            GUILayout.BeginHorizontal(GUI.skin.box);
            {
                GUILayout.BeginVertical(GUILayout.ExpandWidth(true));
                {
                    newKey = EditorGUILayout.TextField("Key", newKey);

                    switch (selectedType)
                    {
                        default:
                        case ValueType.String:
                            newValueString = EditorGUILayout.TextField("Value", newValueString);
                            break;
                        case ValueType.Float:
                            newValueFloat = EditorGUILayout.FloatField("Value", newValueFloat);
                            break;
                        case ValueType.Integer:
                            newValueInt = EditorGUILayout.IntField("Value", newValueInt);
                            break;
                    }

                    selectedType = (ValueType)EditorGUILayout.EnumPopup("Type", selectedType);
                }
                GUILayout.EndVertical();

                GUILayout.BeginVertical(GUILayout.Width(1));
                {
                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.FlexibleSpace();

                        if (GUILayout.Button(new GUIContent("X", "Close"), EditorStyles.boldLabel, GUILayout.ExpandWidth(false)))
                        {
                            showNewEntryBox = false;
                        }
                    }
                    GUILayout.EndHorizontal();

                    if (GUILayout.Button(new GUIContent(AddIcon, "Add a new key-value.")))
                    {
                        if (!string.IsNullOrEmpty(newKey))
                        {
                            switch (selectedType)
                            {
                                case ValueType.Integer:
                                    PlayerPrefs.SetInt(newKey, newValueInt);
                                    ppeList.Add(new PlayerPrefsEntry(newKey, newValueInt));
                                    break;
                                case ValueType.Float:
                                    PlayerPrefs.SetFloat(newKey, newValueFloat);
                                    ppeList.Add(new PlayerPrefsEntry(newKey, newValueFloat));
                                    break;
                                default:
                                case ValueType.String:
                                    PlayerPrefs.SetString(newKey, newValueString);
                                    ppeList.Add(new PlayerPrefsEntry(newKey, newValueString));
                                    break;
                            }
                            PlayerPrefs.Save();
                        }

                        newKey = newValueString = "";
                        newValueInt = 0;
                        newValueFloat = 0;
                        GUIUtility.keyboardControl = 0;	//move focus from textfield, else the text won't be cleared
                        showNewEntryBox = false;
                    }
                }
                GUILayout.EndVertical();
            }
            GUILayout.EndHorizontal();
        }

        GUILayout.Space(2);
        
        GUI.backgroundColor = Color.white;
        
        EditorGUI.indentLevel++;

        scrollPos = EditorGUILayout.BeginScrollView(scrollPos);
        {
            EditorGUILayout.BeginVertical();
            {
                for (int i = 0; i < filteredPpeList.Count; i++)
                {
                    if (filteredPpeList[i].Value != null)
                    {
                        EditorGUILayout.BeginHorizontal();
                        {
                            filteredPpeList[i].IsSelected = GUILayout.Toggle(filteredPpeList[i].IsSelected, new GUIContent("", "Toggle selection."), filteredPpeList[i].HasChanged ? boldToggleStyle : EditorStyles.toggle, GUILayout.MaxWidth(20), GUILayout.MinWidth(20), GUILayout.ExpandWidth(false));
                            filteredPpeList[i].Key = GUILayout.TextField(filteredPpeList[i].Key, filteredPpeList[i].HasChanged ? boldNumberFieldStyle : EditorStyles.numberField, GUILayout.MaxWidth(125), GUILayout.MinWidth(40), GUILayout.ExpandWidth(true));

                            GUIStyle numberFieldStyle = filteredPpeList[i].HasChanged ? boldNumberFieldStyle : EditorStyles.numberField;

                            switch (filteredPpeList[i].Type)
                            {
                                default:
                                case ValueType.String:
                                    filteredPpeList[i].Value = EditorGUILayout.TextField("", (string)filteredPpeList[i].Value, numberFieldStyle, GUILayout.MinWidth(40));
                                    break;
                                case ValueType.Float:
                                    filteredPpeList[i].Value = EditorGUILayout.FloatField("", (float)filteredPpeList[i].Value, numberFieldStyle, GUILayout.MinWidth(40));
                                    break;
                                case ValueType.Integer:
                                    filteredPpeList[i].Value = EditorGUILayout.IntField("", (int)filteredPpeList[i].Value, numberFieldStyle, GUILayout.MinWidth(40));
                                    break;
                            }

                            GUILayout.Label(new GUIContent("?", filteredPpeList[i].Type.ToString()), GUILayout.ExpandWidth(false));

                            GUI.enabled = filteredPpeList[i].HasChanged && !waitTillPlistHasBeenWritten;
                            if (GUILayout.Button(new GUIContent(SaveIcon, "Save changes made to this value."), GUILayout.ExpandWidth(false)))
                            {
                                filteredPpeList[i].SaveChanges();
                            }

                            if (GUILayout.Button(new GUIContent(UndoIcon, "Discard changes made to this value."), GUILayout.ExpandWidth(false)))
                            {
                                filteredPpeList[i].RevertChanges();
                            }

                            GUI.enabled = !waitTillPlistHasBeenWritten;

                            if (GUILayout.Button(new GUIContent(DeleteIcon, "Delete this key-value."), GUILayout.ExpandWidth(false)))
                            {
                                PlayerPrefs.DeleteKey(filteredPpeList[i].Key);
                                ppeList.Remove(filteredPpeList[i]);
                                PlayerPrefs.Save();

                                UpdateFilteredList();
                                break;
                            }
                        }
                        EditorGUILayout.EndHorizontal();
                    }
                }
            }
            EditorGUILayout.EndVertical();
        }
        EditorGUILayout.EndScrollView();

        EditorGUI.indentLevel--;
    }
예제 #10
0
    public void OnRightMouseClick(Vector2 mousePos)
    {
        string image = GetClickedImageName (mousePos);
        if(!image.Equals(string.Empty)) {

            selection.Clear();
            selection.Add(image);
            editor.Repaint ();

            GenericMenu menu = new GenericMenu ();
            menu.AddItem (new GUIContent ("Copy Name"), false, SubMenuCallBack,     TexturePackerMenuItem.COPY_TO_CLIPBOARD);
            menu.AddSeparator ("");
            menu.AddItem (new GUIContent ("Documentation"), false, SubMenuCallBack, TexturePackerMenuItem.DOCUMENTATION);
            menu.ShowAsContext ();
        } else {
            selection.Clear();
        }

        editor.Repaint ();
    }
예제 #11
0
		public override void OnFlowCreateMenuGUI(string prefix, GenericMenu menu) {

			if (this.InstallationNeeded() == false) {

				menu.AddSeparator(prefix);

				menu.AddItem(new GUIContent(string.Format("{0}Linker", prefix)), on: false, func: () => {

					this.flowEditor.CreateNewItem(() => {
						
						var window = FlowSystem.CreateWindow(flags:
							UnityEngine.UI.Windows.Plugins.Flow.Data.FlowWindow.Flags.IsSmall |
							UnityEngine.UI.Windows.Plugins.Flow.Data.FlowWindow.Flags.CantCompiled |
							UnityEngine.UI.Windows.Plugins.Flow.Data.FlowWindow.Flags.IsLinker
						);

						window.title = "Linker";
						window.rect.width = 150f;
						window.rect.height = 90f;

						window.smallStyleDefault = "flow node 2";
						window.smallStyleSelected = "flow node 2 on";

						return window;

					});

				});

			}

		}
예제 #12
0
        public override void OnContextualClick(InspectorField field, GenericMenu menu)
        {
            menu.AddItem(new GUIContent("Identity"), false, Identity);

            menu.AddSeparator("");
        }
예제 #13
0
        //---------------------------------------------------------------------
        // Public
        //---------------------------------------------------------------------

        public static void ShowDropDown(Rect position, RainbowFolder folder)
        {
            var menu = new GenericMenu();

            // Colors
            menu.AddItem(COLOR_RED, false, RedCallback, folder);
            menu.AddItem(COLOR_VERMILION, false, VermilionCallback, folder);
            menu.AddItem(COLOR_ORANGE, false, OrangeCallback, folder);
            menu.AddItem(COLOR_AMBER, false, AmberCallback, folder);
            menu.AddItem(COLOR_YELLOW, false, YellowCallback, folder);
            menu.AddItem(COLOR_LIME, false, LimeCallback, folder);
            menu.AddItem(COLOR_CHARTREUSE, false, ChartreuseCallback, folder);
            menu.AddItem(COLOR_HARLEQUIN, false, HarlequinCallback, folder);
            menu.AddSeparator(MENU_COLORIZE);
            menu.AddItem(COLOR_GREEN, false, GreenCallback, folder);
            menu.AddItem(COLOR_EMERALD, false, EmeraldCallback, folder);
            menu.AddItem(COLOR_SPRING_GREEN, false, SpringGreenCallback, folder);
            menu.AddItem(COLOR_AQUAMARINE, false, AquamarineCallback, folder);
            menu.AddItem(COLOR_CYAN, false, CyanCallback, folder);
            menu.AddItem(COLOR_SKY_BLUE, false, SkyBlueCallback, folder);
            menu.AddItem(COLOR_AZURE, false, AzureCallback, folder);
            menu.AddItem(COLOR_CERULEAN, false, CeruleanCallback, folder);
            menu.AddSeparator(MENU_COLORIZE);
            menu.AddItem(COLOR_BLUE, false, BlueCallback, folder);
            menu.AddItem(COLOR_INDIGO, false, IndigoCallback, folder);
            menu.AddItem(COLOR_VIOLET, false, VioletCallback, folder);
            menu.AddItem(COLOR_PURPLE, false, PurpleCallback, folder);
            menu.AddItem(COLOR_MAGENTA, false, MagentaCallback, folder);
            menu.AddItem(COLOR_FUCHSIA, false, FuchsiaCallback, folder);
            menu.AddItem(COLOR_ROSE, false, RoseCallback, folder);
            menu.AddItem(COLOR_CRISMON, false, CrismonCallback, folder);

            // Tags
            menu.AddItem(TAG_RED, false, TagRedCallback, folder);
            menu.AddItem(TAG_VERMILION, false, TagVermilionCallback, folder);
            menu.AddItem(TAG_ORANGE, false, TagOrangeCallback, folder);
            menu.AddItem(TAG_AMBER, false, TagAmberCallback, folder);
            menu.AddItem(TAG_YELLOW, false, TagYellowCallback, folder);
            menu.AddItem(TAG_LIME, false, TagLimeCallback, folder);
            menu.AddItem(TAG_CHARTREUSE, false, TagChartreuseCallback, folder);
            menu.AddItem(TAG_HARLEQUIN, false, TagHarlequinCallback, folder);
            menu.AddSeparator(MENU_TAG);
            menu.AddItem(TAG_GREEN, false, TagGreenCallback, folder);
            menu.AddItem(TAG_EMERALD, false, TagEmeraldCallback, folder);
            menu.AddItem(TAG_SPRING_GREEN, false, TagSpringGreenCallback, folder);
            menu.AddItem(TAG_AQUAMARINE, false, TagAquamarineCallback, folder);
            menu.AddItem(TAG_CYAN, false, TagCyanCallback, folder);
            menu.AddItem(TAG_SKY_BLUE, false, TagSkyBlueCallback, folder);
            menu.AddItem(TAG_AZURE, false, TagAzureCallback, folder);
            menu.AddItem(TAG_CERULEAN, false, TagCeruleanCallback, folder);
            menu.AddSeparator(MENU_TAG);
            menu.AddItem(TAG_BLUE, false, TagBlueCallback, folder);
            menu.AddItem(TAG_INDIGO, false, TagIndigoCallback, folder);
            menu.AddItem(TAG_VIOLET, false, TagVioletCallback, folder);
            menu.AddItem(TAG_PURPLE, false, TagPurpleCallback, folder);
            menu.AddItem(TAG_MAGENTA, false, TagMagentaCallback, folder);
            menu.AddItem(TAG_FUCHSIA, false, TagFuchsiaCallback, folder);
            menu.AddItem(TAG_ROSE, false, TagRoseCallback, folder);
            menu.AddItem(TAG_CRISMON, false, TagCrismonCallback, folder);

            //Types
            menu.AddItem(TYPE_ANIMATIONS, false, AnimationsCallback, folder);
            menu.AddItem(TYPE_AUDIO, false, AudioCallback, folder);
            menu.AddItem(TYPE_EDITOR, false, EditorCallback, folder);
            menu.AddItem(TYPE_EXTENSIONS, false, ExtensionsCallback, folder);
            menu.AddItem(TYPE_FLARES, false, FlaresCallback, folder);
            menu.AddItem(TYPE_FONTS, false, FontsCallback, folder);
            menu.AddItem(TYPE_MATERIALS, false, MaterialsCallback, folder);
            menu.AddItem(TYPE_MESHES, false, MeshesCallback, folder);
            menu.AddItem(TYPE_PLUGINS, false, PluginsCallback, folder);
            menu.AddItem(TYPE_PHYSICS, false, PhysicsCallback, folder);
            menu.AddItem(TYPE_PREFABS, false, PrefabsCallback, folder);
            menu.AddItem(TYPE_PROJECT, false, ProjectCallback, folder);
            menu.AddItem(TYPE_RAINBOW, false, RainbowCallback, folder);
            menu.AddItem(TYPE_RESOURCES, false, ResourcesCallback, folder);
            menu.AddItem(TYPE_SCENES, false, ScenesCallback, folder);
            menu.AddItem(TYPE_SCRIPTS, false, ScriptsCallback, folder);
            menu.AddItem(TYPE_SHADERS, false, ShadersCallback, folder);
            menu.AddItem(TYPE_TERRAINS, false, TerrainsCallback, folder);
            menu.AddItem(TYPE_TEXTURES, false, TexturesCallback, folder);

            //Platfroms
            menu.AddItem(PLATFORM_ANDROID, false, AndroidCallback, folder);
            menu.AddItem(PLATFORM_IOS, false, IosCallback, folder);
            menu.AddItem(PLATFORM_MAC, false, MacCallback, folder);
            menu.AddItem(PLATFORM_WEBGL, false, WebGLCallback, folder);
            menu.AddItem(PLATFORM_WINDOWS, false, WindowsCallback, folder);

            menu.DropDown(position);
        }
예제 #14
0
    /// <summary>
    /// Draw and update the toolbar for the director control
    /// </summary>
    /// <param name="toolbarArea">The area for the toolbar</param>
    private void updateToolbar(Rect toolbarArea)
    {
        EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);

        // If there are no cutscenes, then only give option to create a new cutscene.
        if (GUILayout.Button(CREATE, EditorStyles.toolbarDropDown, GUILayout.Width(60)))
        {
            GenericMenu createMenu = new GenericMenu();
            createMenu.AddItem(new_cutscene, false, openCutsceneCreatorWindow);

            if (cutscene != null)
            {
                createMenu.AddSeparator(string.Empty);

                foreach (Type type in DirectorHelper.GetAllSubTypes(typeof(TrackGroup)))
                {
                    TrackGroupContextData userData = getContextDataFromType(type);
                    string text = string.Format(userData.Label);
                    createMenu.AddItem(new GUIContent(text), false, new GenericMenu.MenuFunction2(AddTrackGroup), userData);
                }
            }

            createMenu.DropDown(new Rect(5, TOOLBAR_HEIGHT, 0, 0));
        }

        // Cutscene selector
        cachedCutscenes = GameObject.FindObjectsOfType <Cutscene>();
        if (cachedCutscenes != null && cachedCutscenes.Length > 0)
        {
            // Get cutscene names
            GUIContent[] cutsceneNames = new GUIContent[cachedCutscenes.Length];
            for (int i = 0; i < cachedCutscenes.Length; i++)
            {
                cutsceneNames[i] = new GUIContent(cachedCutscenes[i].name);
            }

            // Sort alphabetically
            Array.Sort(cutsceneNames, delegate(GUIContent content1, GUIContent content2)
            {
                return(string.Compare(content1.text, content2.text));
            });

            Array.Sort(cachedCutscenes, delegate(Cutscene c1, Cutscene c2)
            {
                return(string.Compare(c1.name, c2.name));
            });

            // Find the currently selected cutscene.
            for (int i = 0; i < cachedCutscenes.Length; i++)
            {
                if (cutscene != null && cutscene.GetInstanceID() == cachedCutscenes[i].GetInstanceID())
                {
                    popupSelection = i;
                }
            }

            // Show the popup
            int tempPopup = EditorGUILayout.Popup(popupSelection, cutsceneNames, EditorStyles.toolbarPopup);
            if (tempPopup != popupSelection)
            {
                popupSelection = tempPopup;
                EditorPrefs.SetInt("DirectorControl.CutsceneID", cachedCutscenes[popupSelection].GetInstanceID());
            }
            popupSelection = Math.Min(popupSelection, cachedCutscenes.Length - 1);
            cutscene       = cachedCutscenes[popupSelection];
        }
        if (cutscene != null)
        {
            if (GUILayout.Button(pickerImage, EditorStyles.toolbarButton, GUILayout.Width(24)))
            {
                Selection.activeObject = cutscene;
            }
            if (GUILayout.Button(refreshImage, EditorStyles.toolbarButton, GUILayout.Width(24)))
            {
                cutscene.Refresh();
            }

            if (Event.current.control && Event.current.keyCode == KeyCode.Space)
            {
                cutscene.Refresh();
                Event.current.Use();
            }
        }
        GUILayout.FlexibleSpace();

        bool tempSnapping = GUILayout.Toggle(isSnappingEnabled, snapImage, EditorStyles.toolbarButton, GUILayout.Width(24));

        if (tempSnapping != isSnappingEnabled)
        {
            isSnappingEnabled = tempSnapping;
            directorControl.IsSnappingEnabled = isSnappingEnabled;
        }
        GUILayout.Button(rippleEditImage, EditorStyles.toolbarButton, GUILayout.Width(24));
        GUILayout.Button(rollingEditImage, EditorStyles.toolbarButton, GUILayout.Width(24));
        GUILayout.Space(10f);

        if (GUILayout.Button(rescaleImage, EditorStyles.toolbarButton, GUILayout.Width(24)))
        {
            directorControl.Rescale();
        }
        if (GUILayout.Button(new GUIContent(zoomInImage, "Zoom In"), EditorStyles.toolbarButton, GUILayout.Width(24)))
        {
            directorControl.ZoomIn();
        }
        if (GUILayout.Button(zoomOutImage, EditorStyles.toolbarButton, GUILayout.Width(24)))
        {
            directorControl.ZoomOut();
        }
        GUILayout.Space(10f);

        Color temp = GUI.color;

        GUI.color = directorControl.InPreviewMode ? Color.red : temp;
        directorControl.InPreviewMode = GUILayout.Toggle(directorControl.InPreviewMode, PREVIEW_MODE, EditorStyles.toolbarButton, GUILayout.Width(150));
        GUI.color = temp;
        GUILayout.Space(10);

        if (GUILayout.Button("?", EditorStyles.toolbarButton))
        {
            EditorWindow.GetWindow <DirectorHelpWindow>();
        }
        EditorGUILayout.EndHorizontal();
    }
예제 #15
0
        public static GenericMenu QuickAccessMenu(SceneView sceneview)
        {
            GenericMenu menu = new GenericMenu();

            if (linkMainCamera)
            {
                menu.AddItem(new GUIContent("Unlock MainCamera from SceneView"), false, () => linkMainCamera = false);
                menu.AddSeparator("");
            }

            foreach (Viewpoint v in Instance.builtin_viewpoints)
            {
                menu.AddItem(new GUIContent(v.name), false, () => v.Load(sceneview));
            }

            menu.AddSeparator("");

            //foreach (Camera c in Object.FindObjectsOfType<Camera>()) // TODO : add the includeInactive parameter when possible
            foreach (Camera c in FindObjectsOfTypeAll <Camera>())
            {
                menu.AddItem(new GUIContent("Cameras/" + c.name), false, () =>
                {
                    sceneview.in2DMode = false;
                    if (sceneview.orthographic = c.orthographic)
                    {
                        sceneview.size = c.orthographicSize; // FIXME not working as expected
                    }
                    else
                    {
                        sceneview.cameraSettings.fieldOfView = c.fieldOfView;
                    }
                    sceneview.AlignViewToObject(c.transform);
                });
            }

#if CINEMACHINE
            //foreach (CinemachineVirtualCamera c in Object.FindObjectsOfType<CinemachineVirtualCamera>()) // TODO : add the includeInactive parameter when possible
            foreach (CinemachineVirtualCamera c in FindObjectsOfTypeAll <CinemachineVirtualCamera>())
            {
                menu.AddItem(new GUIContent("Virtual Cameras/" + c.name), false, () =>
                {
                    sceneview.in2DMode = false;
                    if (sceneview.orthographic = c.m_Lens.Orthographic)
                    {
                        sceneview.size = c.m_Lens.OrthographicSize; // FIXME not working as expected
                    }
                    else
                    {
                        sceneview.cameraSettings.fieldOfView = c.m_Lens.FieldOfView;
                    }
                    sceneview.AlignViewToObject(c.transform);
                    if (soloVirtualCamerasOnSelection || linkMainCamera)
                    {
                        Selection.activeGameObject  = c.gameObject;
                        CinemachineBrain.SoloCamera = c;
                    }
                });
            }
#endif

            menu.AddSeparator("");

            foreach (Viewpoint v in Instance.viewpoints)
            {
                menu.AddItem(new GUIContent(v.name), false, () => v.Load(sceneview));
            }

            menu.AddSeparator("");
            menu.AddItem(new GUIContent("Bookmark View", "Saves the current view as a Bookmark."), false, () => SavePopup.Open(sceneview));
            menu.AddSeparator("");
            //menu.AddItem(new GUIContent("Filter/LOD", "Filters View."), false, () => SceneModeUtility.SearchForType(typeof(LODGroup)));
            menu.AddItem(new GUIContent("Filter/LOD Groups", "Filters View."), false, () => sceneview.SetSearchFilter("LODGroup", 2));
            menu.AddItem(new GUIContent("Filter/Colliders", "Filters View."), false, () => sceneview.SetSearchFilter("Collider", 2));
            menu.AddItem(new GUIContent("Filter/Renderer", "Filters View."), false, () => sceneview.SetSearchFilter("Renderer", 2));
            menu.AddItem(new GUIContent("Filter/Metadata", "Filters View."), false, () => sceneview.SetSearchFilter("Metadata", 2));
            menu.AddSeparator("");
            menu.AddItem(new GUIContent("Frame All"), false, () => { sceneview.FrameAll(); });
            menu.AddItem(new GUIContent("Frame Visible Layers"), false, () => { sceneview.FrameLayers(Tools.visibleLayers); });
            menu.AddItem(new GUIContent("Align to Selection"), false, () => AlignToSelection(sceneview));
            menu.AddItem(new GUIContent("Snap Main Camera"), false, () => SnapCamera(Camera.main, sceneview, linkFOV, true));

            // TODO : experiment with sceneview.rootVisualElement
            //menu.AddItem(new GUIContent("Options/Show as UIElements"), false, () =>
            //{
            //    sceneview.rootVisualElement.Add(new Button(() => Debug.Log("TEST")) { text = "TEST" });
            //});

            menu.AddItem(new GUIContent("Options/Show as GUI"), showAsSceneViewGUI, () => showAsSceneViewGUI          = !showAsSceneViewGUI);
            menu.AddItem(new GUIContent("Options/Lock MainCamera to SceneView"), linkMainCamera, () => linkMainCamera = !linkMainCamera);
            menu.AddItem(new GUIContent("Options/Link FOV"), linkFOV, () => linkFOV = !linkFOV);
#if CINEMACHINE
            menu.AddItem(new GUIContent("Options/Solo Virtual Cameras"), soloVirtualCamerasOnSelection, () => soloVirtualCamerasOnSelection = !soloVirtualCamerasOnSelection);
#endif
            menu.AddSeparator("Options/");
            menu.AddItem(new GUIContent("Options/Bookmarks Editor"), false, () => BookmarkEditorWindow.Open());
            menu.AddItem(new GUIContent("Options/Clear All Bookmarks"), false, () => Instance.viewpoints.Clear());
            menu.AddItem(new GUIContent("Options/Save to Disk"), false, () => Instance?.SaveToJson(path));
            //menu.AddSeparator("Options/");
            //menu.AddItem(new GUIContent("Options/Enable AA"), false, () => { sceneview.antiAlias = 8; });
            return(menu);
        }
예제 #16
0
    private void updateToolbar()
    {
        EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);

        // If there are no cutscenes, then only give option to create a new cutscene.
        if (GUILayout.Button(CREATE, EditorStyles.toolbarDropDown, GUILayout.Width(60)))
        {
            GenericMenu createMenu = new GenericMenu();
            createMenu.AddItem(new_cutscene, false, openCutsceneCreatorWindow);

            if (cutscene != null)
            {
                createMenu.AddSeparator(string.Empty);

                foreach (Type type in DirectorHelper.GetAllSubTypes(typeof(TrackGroup)))
                {
                    TrackGroupContextData userData = getContextDataFromType(type);
                    string text = string.Format(userData.Label);
                    createMenu.AddItem(new GUIContent(text), false, AddTrackGroup, userData);
                }
            }

            createMenu.DropDown(new Rect(5, TOOLBAR_HEIGHT, 0, 0));
        }

        // Cutscene selector
        cachedCutscenes = FindObjectsOfType <Cutscene>();
        if (cachedCutscenes != null && cachedCutscenes.Length > 0)
        {
            // Get cutscene names
            GUIContent[] cutsceneNames = new GUIContent[cachedCutscenes.Length];
            for (int i = 0; i < cachedCutscenes.Length; i++)
            {
                cutsceneNames[i] = new GUIContent(cachedCutscenes[i].name);
            }

            // Sort alphabetically
            Array.Sort(cutsceneNames, delegate(GUIContent content1, GUIContent content2)
            {
                return(string.Compare(content1.text, content2.text));
            });

            int count = 1;
            // Resolve duplicate names
            for (int i = 0; i < cutsceneNames.Length - 1; i++)
            {
                int next = i + 1;
                while (next < cutsceneNames.Length && string.Compare(cutsceneNames[i].text, cutsceneNames[next].text) == 0)
                {
                    cutsceneNames[next].text = string.Format("{0} (duplicate {1})", cutsceneNames[next].text, count++);
                    next++;
                }
                count = 1;
            }

            Array.Sort(cachedCutscenes, delegate(Cutscene c1, Cutscene c2)
            {
                return(string.Compare(c1.name, c2.name));
            });

            // Find the currently selected cutscene.
            for (int i = 0; i < cachedCutscenes.Length; i++)
            {
                if (cutscene != null && cutscene.GetInstanceID() == cachedCutscenes[i].GetInstanceID())
                {
                    popupSelection = i;
                }
            }

            // Show the popup
            int tempPopup = EditorGUILayout.Popup(popupSelection, cutsceneNames, EditorStyles.toolbarPopup);
            if (cutscene == null || tempPopup != popupSelection || cutsceneInstanceID != cachedCutscenes[Math.Min(tempPopup, cachedCutscenes.Length - 1)].GetInstanceID())
            {
                popupSelection = tempPopup;
                popupSelection = Math.Min(popupSelection, cachedCutscenes.Length - 1);
                FocusCutscene(cachedCutscenes[popupSelection]);
            }
        }
        if (cutscene != null)
        {
            if (GUILayout.Button(pickerImage, EditorStyles.toolbarButton, GUILayout.Width(24)))
            {
                Selection.activeObject = cutscene;
            }
            if (GUILayout.Button(refreshImage, EditorStyles.toolbarButton, GUILayout.Width(24)))
            {
                cutscene.Refresh();
            }

            if (Event.current.control && Event.current.keyCode == KeyCode.Space)
            {
                cutscene.Refresh();
                Event.current.Use();
            }
        }
        GUILayout.FlexibleSpace();
        GUILayout.Label(Cutscene.frame.ToString());
        if (betaFeaturesEnabled)
        {
            Texture resizeTexture = cropImage;
            if (directorControl.ResizeOption == DirectorEditor.ResizeOption.Scale)
            {
                resizeTexture = scaleImage;
            }
            Rect resizeRect = GUILayoutUtility.GetRect(new GUIContent(resizeTexture), EditorStyles.toolbarDropDown, GUILayout.Width(32));
            if (GUI.Button(resizeRect, new GUIContent(resizeTexture, "Resize Option"), EditorStyles.toolbarDropDown))
            {
                GenericMenu resizeMenu = new GenericMenu();

                string[] names = Enum.GetNames(typeof(DirectorEditor.ResizeOption));

                for (int i = 0; i < names.Length; i++)
                {
                    resizeMenu.AddItem(new GUIContent(names[i]), directorControl.ResizeOption == (DirectorEditor.ResizeOption)i, chooseResizeOption, i);
                }

                resizeMenu.DropDown(new Rect(resizeRect.x, TOOLBAR_HEIGHT, 0, 0));
            }
        }

        bool tempSnapping = GUILayout.Toggle(isSnappingEnabled, snapImage, EditorStyles.toolbarButton, GUILayout.Width(24));

        if (tempSnapping != isSnappingEnabled)
        {
            isSnappingEnabled = tempSnapping;
            directorControl.IsSnappingEnabled = isSnappingEnabled;
        }

        GUILayout.Space(10f);

        if (GUILayout.Button(rescaleImage, EditorStyles.toolbarButton, GUILayout.Width(24)))
        {
            directorControl.Rescale();
        }
        if (GUILayout.Button(new GUIContent(zoomInImage, "Zoom In"), EditorStyles.toolbarButton, GUILayout.Width(24)))
        {
            directorControl.ZoomIn();
        }
        if (GUILayout.Button(zoomOutImage, EditorStyles.toolbarButton, GUILayout.Width(24)))
        {
            directorControl.ZoomOut();
        }
        GUILayout.Space(10f);

        Color temp = GUI.color;

        GUI.color = directorControl.InPreviewMode ? Color.red : temp;

        directorControl.InPreviewMode = GUILayout.Toggle(directorControl.InPreviewMode, string.Format("{0} {1}", PREVIEW_MODE, Cutscene.frameRate), EditorStyles.toolbarButton, GUILayout.Width(150));
        GUI.color = temp;
        GUILayout.Space(10);

        if (GUILayout.Button(settingsImage, EditorStyles.toolbarButton, GUILayout.Width(30)))
        {
            GetWindow <DirectorSettingsWindow>();
        }
        var helpWindowType = Type.GetType("CinemaSuite.CinemaSuiteWelcome");

        if (helpWindowType != null)
        {
            if (GUILayout.Button(new GUIContent("?", "Help"), EditorStyles.toolbarButton))
            {
                GetWindow(helpWindowType);
            }
        }
        EditorGUILayout.EndHorizontal();
    }
예제 #17
0
	private void RenderTemplateMenu(Event curEvent, int tabIndex)
	{
		UpdateTemplateSignatures();

		// Now create the menu, add items and show it
		GenericMenu menu = new GenericMenu ();

		menu.AddItem(new GUIContent("New Template"), false, TemplateMenuItemCallback, new KeyValuePair<int,int>(-1,tabIndex));
		
		menu.AddSeparator(string.Empty);
		
		for(int i = 0; i < templateSignatures.Length; i++)
		{
			menu.AddItem(new GUIContent(templateSignatures[i].name), false, TemplateMenuItemCallback, new KeyValuePair<int,int>(i,tabIndex));
		}
	
		menu.ShowAsContext();

        curEvent.Use();
	}
예제 #18
0
	private void RenderGroupMenu(Event curEvent)
	{
		UpdateGroups();
		
		int curIndex = GetGroupIndex(liveTemplate.groupName);
		
		GenericMenu menu = new GenericMenu();
		bool isSelected = false;
		
		if(curIndex == -1)
			isSelected = true;
			
		menu.AddItem(new GUIContent("Nothing"),isSelected,GroupMenuItemCallback,-1);
		
		menu.AddSeparator(string.Empty);
			
		for(int i = 0; i < groupNames.Count; i++)
		{
			isSelected = false;
			
			if(curIndex == i)
				isSelected = true;
				
			menu.AddItem(new GUIContent(groupNames[i]),isSelected, GroupMenuItemCallback, i);
		}
		
		menu.ShowAsContext();
		
		curEvent.Use();
	}
예제 #19
0
    protected override void OnContext(AudioNode node)
    {
        var menu = new GenericMenu();

        #region Duplicate
        if (!node.IsRoot)
        {
            menu.AddItem(new GUIContent("Duplicate"), false, data => AudioNodeWorker.Duplicate(node), node);
        }
        else
        {
            menu.AddDisabledItem(new GUIContent("Duplicate"));
        }
        #endregion

        menu.AddSeparator("");

        #region Create child

        if (node.Type == AudioNodeType.Audio || node.Type == AudioNodeType.Voice) //If it is a an audio source, it cannot have any children
        {
            menu.AddDisabledItem(new GUIContent(@"Create Child/Folder"));
            menu.AddDisabledItem(new GUIContent(@"Create Child/Audio"));
            menu.AddDisabledItem(new GUIContent(@"Create Child/Random"));
            menu.AddDisabledItem(new GUIContent(@"Create Child/Sequence"));
            menu.AddDisabledItem(new GUIContent(@"Create Child/Multi"));
            //menu.AddDisabledItem(new GUIContent(@"Create Child/Track"));
            //menu.AddDisabledItem(new GUIContent(@"Create Child/Voice"));
        }
        else
        {
            if (node.Type == AudioNodeType.Root || node.Type == AudioNodeType.Folder)
            {
                menu.AddItem(new GUIContent(@"Create Child/Folder"), false, (obj) => CreateChild(node, AudioNodeType.Folder), node);
            }
            else
            {
                menu.AddDisabledItem(new GUIContent(@"Create Child/Folder"));
            }
            menu.AddItem(new GUIContent(@"Create Child/Audio"), false, (obj) => CreateChild(node, AudioNodeType.Audio), node);
            menu.AddItem(new GUIContent(@"Create Child/Random"), false, (obj) => CreateChild(node, AudioNodeType.Random), node);
            menu.AddItem(new GUIContent(@"Create Child/Sequence"), false, (obj) => CreateChild(node, AudioNodeType.Sequence), node);
            menu.AddItem(new GUIContent(@"Create Child/Multi"), false, (obj) => CreateChild(node, AudioNodeType.Multi), node);
            //menu.AddItem(new GUIContent(@"Create Child/Track"), false,      (obj) => CreateChild(node, AudioNodeType.Track), node);
            //menu.AddItem(new GUIContent(@"Create Child/Voice"), false,      (obj) => CreateChild(node, AudioNodeType.Voice), node);
        }

        #endregion

        menu.AddSeparator("");

        #region Add new parent

        if (node.Parent != null && (node.Parent.Type == AudioNodeType.Folder || node.Parent.Type == AudioNodeType.Root))
        {
            menu.AddItem(new GUIContent(@"Add Parent/Folder"), false, (obj) => AudioNodeWorker.AddNewParent(node, AudioNodeType.Folder), node);
        }
        else
        {
            menu.AddDisabledItem(new GUIContent(@"Add Parent/Folder"));
        }
        menu.AddDisabledItem(new GUIContent(@"Add Parent/Audio"));
        if (node.Parent != null && node.Type != AudioNodeType.Folder)
        {
            menu.AddItem(new GUIContent(@"Add Parent/Random"), false, (obj) => AudioNodeWorker.AddNewParent(node, AudioNodeType.Random), node);
            menu.AddItem(new GUIContent(@"Add Parent/Sequence"), false, (obj) => AudioNodeWorker.AddNewParent(node, AudioNodeType.Sequence), node);
            menu.AddItem(new GUIContent(@"Add Parent/Multi"), false, (obj) => AudioNodeWorker.AddNewParent(node, AudioNodeType.Multi), node);
            //menu.AddItem(new GUIContent(@"Add Parent/Track"), false, (obj) =>       AudioNodeWorker.AddNewParent(node, AudioNodeType.Track), node);
        }
        else
        {
            menu.AddDisabledItem(new GUIContent(@"Add Parent/Random"));
            menu.AddDisabledItem(new GUIContent(@"Add Parent/Sequence"));
            menu.AddDisabledItem(new GUIContent(@"Add Parent/Multi"));
            //menu.AddDisabledItem(new GUIContent(@"Add Parent/Track"));
        }
        //menu.AddDisabledItem(new GUIContent(@"Add Parent/Voice"));

        #endregion

        menu.AddSeparator("");

        #region Convert to

        if (node.Children.Count == 0)
        {
            menu.AddItem(new GUIContent(@"Convert To/Audio"), false, (obj) => AudioNodeWorker.ConvertNodeType(node, AudioNodeType.Audio), node);
        }
        else
        {
            menu.AddDisabledItem(new GUIContent(@"Convert To/Audio"));
        }
        if (node.Type != AudioNodeType.Root)
        {
            menu.AddItem(new GUIContent(@"Convert To/Random"), false, (obj) => AudioNodeWorker.ConvertNodeType(node, AudioNodeType.Random), node);
            menu.AddItem(new GUIContent(@"Convert To/Sequence"), false, (obj) => AudioNodeWorker.ConvertNodeType(node, AudioNodeType.Sequence), node);
            menu.AddItem(new GUIContent(@"Convert To/Multi"), false, (obj) => AudioNodeWorker.ConvertNodeType(node, AudioNodeType.Multi), node);
            //menu.AddItem(new GUIContent(@"Convert To/Track"), false, (obj) =>       AudioNodeWorker.ConvertNodeType(node, AudioNodeType.Track), node);
        }
        else
        {
            menu.AddDisabledItem(new GUIContent(@"Convert To/Random"));
            menu.AddDisabledItem(new GUIContent(@"Convert To/Sequence"));
            menu.AddDisabledItem(new GUIContent(@"Convert To/Multi"));
            //menu.AddDisabledItem(new GUIContent(@"Add Parent/Track"));
        }

        /*if (node.Children.Count == 0)
         *  menu.AddItem(new GUIContent(@"Convert To/Voice"), false, (obj) => AudioNodeWorker.ConvertNodeType(node, AudioNodeType.Audio), node);
         * else
         *  menu.AddDisabledItem(new GUIContent(@"Convert To/Voice"));*/

        #endregion

        menu.AddSeparator("");

        #region Delete
        if (node.Type != AudioNodeType.Root)
        {
            menu.AddItem(new GUIContent("Delete"), false, obj => AudioNodeWorker.DeleteNode(node), node);
        }
        else
        {
            menu.AddDisabledItem(new GUIContent("Delete"));
        }
        #endregion

        menu.ShowAsContext();
    }
        private GenericMenu GenerateMenu(List <AnimationWindowHierarchyNode> interactedNodes, bool enabled)
        {
            List <AnimationWindowCurve> curves = GetCurvesAffectedByNodes(interactedNodes, false);
            // Linked curves are like regular affected curves but always include transform siblings
            List <AnimationWindowCurve> linkedCurves = GetCurvesAffectedByNodes(interactedNodes, true);

            bool forceGroupRemove = curves.Count == 1 ? AnimationWindowUtility.ForceGrouping(curves[0].binding) : false;

            GenericMenu menu = new GenericMenu();

            // Remove curves
            GUIContent removePropertyContent = new GUIContent(curves.Count > 1 || forceGroupRemove ? "Remove Properties" : "Remove Property");

            if (!enabled)
            {
                menu.AddDisabledItem(removePropertyContent);
            }
            else
            {
                menu.AddItem(removePropertyContent, false, RemoveCurvesFromSelectedNodes);
            }

            // Change rotation interpolation
            bool showInterpolation = true;

            EditorCurveBinding[] curveBindings = new EditorCurveBinding[linkedCurves.Count];
            for (int i = 0; i < linkedCurves.Count; i++)
            {
                curveBindings[i] = linkedCurves[i].binding;
            }
            RotationCurveInterpolation.Mode rotationInterpolation = GetRotationInterpolationMode(curveBindings);
            if (rotationInterpolation == RotationCurveInterpolation.Mode.Undefined)
            {
                showInterpolation = false;
            }
            else
            {
                foreach (var node in interactedNodes)
                {
                    if (!(node is AnimationWindowHierarchyPropertyGroupNode))
                    {
                        showInterpolation = false;
                    }
                }
            }
            if (showInterpolation)
            {
                string legacyWarning = state.activeAnimationClip.legacy ? " (Not fully supported in Legacy)" : "";
                GenericMenu.MenuFunction2 nullMenuFunction2 = null;
                menu.AddItem(EditorGUIUtility.TrTextContent("Interpolation/Euler Angles" + legacyWarning), rotationInterpolation == RotationCurveInterpolation.Mode.RawEuler, enabled ? ChangeRotationInterpolation : nullMenuFunction2, RotationCurveInterpolation.Mode.RawEuler);
                menu.AddItem(EditorGUIUtility.TrTextContent("Interpolation/Euler Angles (Quaternion)"), rotationInterpolation == RotationCurveInterpolation.Mode.Baked, enabled ? ChangeRotationInterpolation : nullMenuFunction2, RotationCurveInterpolation.Mode.Baked);
                menu.AddItem(EditorGUIUtility.TrTextContent("Interpolation/Quaternion"), rotationInterpolation == RotationCurveInterpolation.Mode.NonBaked, enabled ? ChangeRotationInterpolation : nullMenuFunction2, RotationCurveInterpolation.Mode.NonBaked);
            }

            // Menu items that are only applicaple when in animation mode:
            if (state.previewing)
            {
                menu.AddSeparator("");

                bool allHaveKeys  = true;
                bool noneHaveKeys = true;
                foreach (AnimationWindowCurve curve in curves)
                {
                    bool curveHasKey = curve.HasKeyframe(state.time);
                    if (!curveHasKey)
                    {
                        allHaveKeys = false;
                    }
                    else
                    {
                        noneHaveKeys = false;
                    }
                }

                string str;

                str = "Add Key";
                if (allHaveKeys || !enabled)
                {
                    menu.AddDisabledItem(new GUIContent(str));
                }
                else
                {
                    menu.AddItem(new GUIContent(str), false, AddKeysAtCurrentTime, curves);
                }

                str = "Delete Key";
                if (noneHaveKeys || !enabled)
                {
                    menu.AddDisabledItem(new GUIContent(str));
                }
                else
                {
                    menu.AddItem(new GUIContent(str), false, DeleteKeysAtCurrentTime, curves);
                }
            }

            return(menu);
        }
        //...
        void OnGUI()
        {
            GUI.skin.label.richText = true;
            EditorGUILayout.HelpBox("Here you can specify frequently used types for your project and for easier access wherever you need to select a type, like for example when you create a new blackboard variable or using any refelection based actions. Furthermore, it is essential when working with AOT platforms like iOS or WebGL, that you generate an AOT Classes and link.xml files with the relevant button bellow. To add types in the list quicker, you can also Drag&Drop an object, or a Script file in this editor window.\n\nIf you save a preset in your 'Editor Default Resources/" + TypePrefs.SYNC_FILE_NAME + "' it will automatically sync with the list. Useful when working with others on source control.", MessageType.Info);

            if (GUILayout.Button("Add New Type", EditorStyles.miniButton))
            {
                GenericMenu.MenuFunction2 Selected = delegate(object o)
                {
                    if (o is System.Type)
                    {
                        AddType((System.Type)o);
                    }
                    if (o is string)     //namespace
                    {
                        foreach (var type in alltypes)
                        {
                            if (type.Namespace == (string)o)
                            {
                                AddType(type);
                            }
                        }
                    }
                };

                var menu       = new GenericMenu();
                var namespaces = new List <string>();
                menu.AddItem(new GUIContent("Classes/System/Object"), false, Selected, typeof(object));
                foreach (var t in alltypes)
                {
                    var friendlyName = (string.IsNullOrEmpty(t.Namespace) ? "No Namespace/" : t.Namespace.Replace(".", "/") + "/") + t.FriendlyName();
                    var category     = "Classes/";
                    if (t.IsValueType)
                    {
                        category = "Structs/";
                    }
                    if (t.IsInterface)
                    {
                        category = "Interfaces/";
                    }
                    if (t.IsEnum)
                    {
                        category = "Enumerations/";
                    }
                    menu.AddItem(new GUIContent(category + friendlyName), typeList.Contains(t), Selected, t);
                    if (t.Namespace != null && !namespaces.Contains(t.Namespace))
                    {
                        namespaces.Add(t.Namespace);
                    }
                }

                menu.AddSeparator("/");
                foreach (var ns in namespaces)
                {
                    var path = "Whole Namespaces/" + ns.Replace(".", "/") + "/Add " + ns;
                    menu.AddItem(new GUIContent(path), false, Selected, ns);
                }

                menu.ShowAsBrowser("Add Preferred Type");
            }


            if (GUILayout.Button("Generate AOTClasses.cs and link.xml Files", EditorStyles.miniButton))
            {
                if (EditorUtility.DisplayDialog("Generate AOT Classes", "A script relevant to AOT compatibility for certain platforms will now be generated.", "OK"))
                {
                    var path = EditorUtility.SaveFilePanelInProject("AOT Classes File", "AOTClasses", "cs", "");
                    if (!string.IsNullOrEmpty(path))
                    {
                        AOTClassesGenerator.GenerateAOTClasses(path, TypePrefs.GetPreferedTypesList(true).ToArray());
                    }
                }

                if (EditorUtility.DisplayDialog("Generate link.xml File", "A file relevant to 'code stripping' for platforms that have code stripping enabled will now be generated.", "OK"))
                {
                    var path = EditorUtility.SaveFilePanelInProject("AOT link.xml", "link", "xml", "");
                    if (!string.IsNullOrEmpty(path))
                    {
                        AOTClassesGenerator.GenerateLinkXML(path, TypePrefs.GetPreferedTypesList().ToArray());
                    }
                }

                AssetDatabase.Refresh();
            }

            GUILayout.BeginHorizontal();

            if (GUILayout.Button("Reset Defaults", EditorStyles.miniButtonLeft))
            {
                if (EditorUtility.DisplayDialog("Reset Preferred Types", "Are you sure?", "Yes", "NO!"))
                {
                    TypePrefs.ResetTypeConfiguration();
                    typeList = TypePrefs.GetPreferedTypesList();
                    Save();
                }
            }

            if (GUILayout.Button("Save Preset", EditorStyles.miniButtonMid))
            {
                var path = EditorUtility.SaveFilePanelInProject("Save Types Preset", "PreferredTypes", "typePrefs", "");
                if (!string.IsNullOrEmpty(path))
                {
                    System.IO.File.WriteAllText(path, JSONSerializer.Serialize(typeof(List <System.Type>), typeList, null, true));
                    AssetDatabase.Refresh();
                }
            }

            if (GUILayout.Button("Load Preset", EditorStyles.miniButtonRight))
            {
                var path = EditorUtility.OpenFilePanel("Load Types Preset", "Assets", "typePrefs");
                if (!string.IsNullOrEmpty(path))
                {
                    var json = System.IO.File.ReadAllText(path);
                    typeList = JSONSerializer.Deserialize <List <System.Type> >(json);
                    Save();
                }
            }

            GUILayout.EndHorizontal();
            GUILayout.Space(5);
            var syncPath = TypePrefs.SyncFilePath();

            EditorGUILayout.HelpBox(syncPath != null ? "List synced with file: " + syncPath.Replace(Application.dataPath, ".../Assets") : "No sync file found in '.../Assets/Editor Default Resources'. Types are currently saved in Unity EditorPrefs only.", MessageType.None);
            GUILayout.Space(5);

            scrollPos = GUILayout.BeginScrollView(scrollPos);
            for (int i = 0; i < typeList.Count; i++)
            {
                if (EditorGUIUtility.isProSkin)
                {
                    GUI.color = Color.black.WithAlpha(i % 2 == 0 ? 0.3f : 0);
                }
                if (!EditorGUIUtility.isProSkin)
                {
                    GUI.color = Color.white.WithAlpha(i % 2 == 0 ? 0.3f : 0);
                }
                GUILayout.BeginHorizontal("box");
                GUI.color = Color.white;
                var type = typeList[i];
                if (type == null)
                {
                    GUILayout.Label("MISSING TYPE", GUILayout.Width(300));
                    GUILayout.Label("---");
                }
                else
                {
                    var name = type.FriendlyName();
                    var icon = TypePrefs.GetTypeIcon(type);
                    GUILayout.Label(icon, GUILayout.Width(16), GUILayout.Height(16));
                    GUILayout.Label(name, GUILayout.Width(300));
                    GUILayout.Label(type.Namespace);
                }
                if (GUILayout.Button("X", GUILayout.Width(18)))
                {
                    RemoveType(type);
                }
                GUILayout.EndHorizontal();
            }
            GUILayout.EndScrollView();

            AcceptDrops();
            Repaint();
        }
예제 #22
0
        static void ShowDataGUI(Variable data, IBlackboard bb, UnityEngine.Object contextParent, GUILayoutOption[] layoutOptions)
        {
            //Bind info or value GUI control
            if (data.hasBinding)
            {
                var idx        = data.propertyPath.LastIndexOf('.');
                var typeName   = data.propertyPath.Substring(0, idx);
                var memberName = data.propertyPath.Substring(idx + 1);
                GUI.color = new Color(0.8f, 0.8f, 1);
                GUILayout.Label(string.Format(".{0} ({1})", memberName, typeName.Split('.').Last()), layoutOptions);
                GUI.color = Color.white;
            }
            else
            {
                GUI.enabled         = !data.isProtected;
                data.value          = VariableField(data, contextParent, layoutOptions);
                GUI.enabled         = true;
                GUI.backgroundColor = Color.white;
            }

            //Variable options menu
            if (!Application.isPlaying && GUILayout.Button(" ", GUILayout.Width(8), GUILayout.Height(16)))
            {
                System.Action <PropertyInfo> SelectProp = (p) => {
                    data.BindProperty(p);
                };

                System.Action <FieldInfo> SelectField = (f) => {
                    data.BindProperty(f);
                };

                var menu = new GenericMenu();

                if (bb.propertiesBindTarget != null)
                {
                    foreach (var comp in bb.propertiesBindTarget.GetComponents(typeof(Component)).Where(c => c.hideFlags != HideFlags.HideInInspector))
                    {
                        menu = EditorUtils.GetPropertySelectionMenu(comp.GetType(), data.varType, SelectProp, false, false, menu, "Bind (Self)/Property");
                        menu = EditorUtils.GetFieldSelectionMenu(comp.GetType(), data.varType, SelectField, menu, "Bind (Self)/Field");
                    }
                }

                foreach (var type in UserTypePrefs.GetPreferedTypesList(typeof(object), true))
                {
                    menu = EditorUtils.GetStaticPropertySelectionMenu(type, data.varType, SelectProp, false, false, menu, "Bind (Static)/Property");
                    menu = EditorUtils.GetStaticFieldSelectionMenu(type, data.varType, SelectField, menu, "Bind (Static)/Field");
                }


                menu.AddItem(new GUIContent("Protected"), data.isProtected, () => { data.isProtected = !data.isProtected; });

                if (bb.propertiesBindTarget != null)
                {
                    menu.AddSeparator("/");
                    if (data.hasBinding)
                    {
                        menu.AddItem(new GUIContent("UnBind"), false, () => { data.UnBindProperty(); });
                    }
                    else
                    {
                        menu.AddDisabledItem(new GUIContent("UnBind"));
                    }
                }

                menu.ShowAsContext();
                Event.current.Use();
            }
        }
예제 #23
0
    public void ShowNodeCreationMenu()
    {
        if (NodifyEditorUtilities.currentSelectedGroup == null) { return; }

        GenericMenu menu = new GenericMenu();

        InitializeCreateNodeMenu();
        foreach(CreateMenu menuItem in createNodeMenuItems)
        {
            object[] argArray = new object[] { menuItem.type, menuItem.name, Event.current.mousePosition - NodifyEditorUtilities.currentSelectedGroup.editorWindowOffset, menuItem.iconResourcePath };

            menu.AddItem(new GUIContent(menuItem.path), false, delegate(object args)
            {
                object[] argToArray = (object[])args;

                System.Type type = (System.Type)argToArray[0];
                GameObject nodeObj = new GameObject((string)argToArray[1]);

                #if UNITY_5
                    Node nodeClass = (Node)nodeObj.AddComponent(type);
                #else
                    Node nodeClass = (Node)nodeObj.AddComponent(type.Name);
                #endif
                nodeClass.editorPosition = (Vector2)argToArray[2];
                nodeClass.editorResourceIcon = (string)argToArray[3];
                nodeClass.OnEditorNodeCreated();
                nodeObj.transform.parent = NodifyEditorUtilities.currentSelectedGroup.transform;

            }, argArray);
        }

        menu.AddSeparator("");

        menu.AddItem(new GUIContent("New Group"), false, delegate(object args)
        {
            GameObject nGroup = new GameObject("NewGroup");
            NodeGroup nGroupClass = nGroup.AddComponent<NodeGroup>();
            nGroupClass.transform.parent = NodifyEditorUtilities.currentSelectedGroup.transform;
            nGroupClass.editorPosition = (Vector2)args;
            nGroupClass.OnEditorNodeCreated();
        }, Event.current.mousePosition - NodifyEditorUtilities.currentSelectedGroup.editorWindowOffset);

        if(Selection.objects.Length > 0)
        {
            if(Selection.objects.Length > 1 || (Selection.objects.Length == 1 && !Selection.Contains(NodifyEditorUtilities.currentSelectedGroup.gameObject)))
            {
                menu.AddItem(new GUIContent("New Group [with selected]"), false, delegate(object args)
                {
                    GameObject nGroup = new GameObject("NewGroup");
                    NodeGroup nGroupClass = nGroup.AddComponent<NodeGroup>();
                    nGroupClass.transform.parent = NodifyEditorUtilities.currentSelectedGroup.transform;
                    nGroupClass.editorPosition = (Vector2)args;
                    nGroupClass.OnEditorNodeCreated();

                    foreach(GameObject obj in Selection.gameObjects)
                    {
                        if(obj != NodifyEditorUtilities.currentSelectedGroup.gameObject && obj.GetComponent<Node>())
                        {
                            obj.transform.parent = nGroupClass.transform;
                        }
                    }

                }, Event.current.mousePosition - NodifyEditorUtilities.currentSelectedGroup.editorWindowOffset);
            }
        }

        menu.ShowAsContext();
    }
예제 #24
0
        public static void ShowVariables(IBlackboard bb, UnityEngine.Object contextParent)
        {
            GUI.skin.label.richText = true;
            var e             = Event.current;
            var layoutOptions = new GUILayoutOption[] { GUILayout.MaxWidth(100), GUILayout.ExpandWidth(true), GUILayout.Height(16) };

            //Begin undo check
            UndoManager.CheckUndo(contextParent, "Blackboard Inspector");

            //Add variable button
            GUI.backgroundColor = new Color(0.8f, 0.8f, 1);
            if (GUILayout.Button("Add Variable"))
            {
                System.Action <System.Type> SelectVar = (t) =>
                {
                    var name = "my" + t.FriendlyName();
                    while (bb.GetVariable(name) != null)
                    {
                        name += ".";
                    }
                    bb.AddVariable(name, t);
                };

                System.Action <PropertyInfo> SelectBoundProp = (p) =>
                {
                    var newVar = bb.AddVariable(p.Name, p.PropertyType);
                    newVar.BindProperty(p);
                };

                System.Action <FieldInfo> SelectBoundField = (f) =>
                {
                    var newVar = bb.AddVariable(f.Name, f.FieldType);
                    newVar.BindProperty(f);
                };

                var menu = new GenericMenu();
                menu = EditorUtils.GetPreferedTypesSelectionMenu(typeof(object), SelectVar, true, menu, "New");

                if (bb.propertiesBindTarget != null)
                {
                    foreach (var comp in bb.propertiesBindTarget.GetComponents(typeof(Component)).Where(c => c.hideFlags != HideFlags.HideInInspector))
                    {
                        menu = EditorUtils.GetPropertySelectionMenu(comp.GetType(), typeof(object), SelectBoundProp, false, false, menu, "Bound (Self)/Property");
                        menu = EditorUtils.GetFieldSelectionMenu(comp.GetType(), typeof(object), SelectBoundField, menu, "Bound (Self)/Field");
                    }
                }

                foreach (var type in UserTypePrefs.GetPreferedTypesList(typeof(object), true))
                {
                    menu = EditorUtils.GetStaticPropertySelectionMenu(type, typeof(object), SelectBoundProp, false, false, menu, "Bound (Static)/Property");
                    menu = EditorUtils.GetStaticFieldSelectionMenu(type, typeof(object), SelectBoundField, menu, "Bound (Static)/Field");
                }


                menu.AddSeparator("/");
                menu.AddItem(new GUIContent("Add Header Separator"), false, () => { SelectVar(typeof(VariableSeperator)); });

                menu.ShowAsContext();
                e.Use();
            }


            GUI.backgroundColor = Color.white;

            //Simple column header info
            if (bb.variables.Keys.Count != 0)
            {
                GUILayout.BeginHorizontal();
                GUI.color = Color.yellow;
                GUILayout.Label("Name", layoutOptions);
                GUILayout.Label("Value", layoutOptions);
                GUI.color = Color.white;
                GUILayout.EndHorizontal();
            }
            else
            {
                EditorGUILayout.HelpBox("Blackboard has no variables", MessageType.Info);
            }

            if (!tempStates.ContainsKey(bb))
            {
                tempStates.Add(bb, new ReorderingState(bb.variables.Values.ToList()));
            }

            //Make temporary list for editing variables
            if (!tempStates[bb].isReordering)
            {
                tempStates[bb].list = bb.variables.Values.ToList();
            }

            //store the names of the variables being used by current graph selection.
            var usedVariables = GetUsedVariablesBySelectionParameters();

            //The actual variables reorderable list
            EditorUtils.ReorderableList(tempStates[bb].list, delegate(int i){
                var data = tempStates[bb].list[i];
                if (data == null)
                {
                    GUILayout.Label("NULL Variable!");
                    return;
                }

                var isUsed = usedVariables.Contains(data.name);

                GUILayout.Space(data.varType == typeof(VariableSeperator)? 5 : 0);

                GUILayout.BeginHorizontal();

                //Name of the variable GUI control
                if (!Application.isPlaying)
                {
                    //The small box on the left to re-order variables
                    GUI.backgroundColor = new Color(1, 1, 1, 0.8f);
                    GUILayout.Box("", GUILayout.Width(6));
                    GUI.backgroundColor = new Color(0.7f, 0.7f, 0.7f, 0.3f);

                    if (e.type == EventType.MouseDown && e.button == 0 && GUILayoutUtility.GetLastRect().Contains(e.mousePosition))
                    {
                        tempStates[bb].isReordering = true;
                        if (data.varType != typeof(VariableSeperator))
                        {
                            pickedVariable           = data;
                            pickedVariableBlackboard = bb;
                        }
                    }

                    //Make name field red if same name exists
                    if (tempStates[bb].list.Where(v => v != data).Select(v => v.name).Contains(data.name))
                    {
                        GUI.backgroundColor = Color.red;
                    }

                    GUI.enabled = !data.isProtected;
                    if (data.varType != typeof(VariableSeperator))
                    {
                        data.name             = EditorGUILayout.TextField(data.name, layoutOptions);
                        EditorGUI.indentLevel = 0;
                    }
                    else
                    {
                        var separator = (VariableSeperator)data.value;

                        GUI.color = Color.yellow;
                        if (separator.isEditingName)
                        {
                            data.name = EditorGUILayout.TextField(data.name, layoutOptions);
                        }
                        else
                        {
                            GUILayout.Label(string.Format("<b>{0}</b>", data.name).ToUpper(), layoutOptions);
                        }
                        GUI.color = Color.white;

                        if (!separator.isEditingName)
                        {
                            if (e.type == EventType.MouseDown && e.button == 0 && e.clickCount == 2 && GUILayoutUtility.GetLastRect().Contains(e.mousePosition))
                            {
                                separator.isEditingName    = true;
                                GUIUtility.keyboardControl = 0;
                            }
                        }

                        if (separator.isEditingName)
                        {
                            if ((e.isKey && e.keyCode == KeyCode.Return) || (e.rawType == EventType.MouseUp && !GUILayoutUtility.GetLastRect().Contains(e.mousePosition)))
                            {
                                separator.isEditingName    = false;
                                GUIUtility.keyboardControl = 0;
                            }
                        }

                        data.value = separator;
                    }

                    GUI.enabled         = true;
                    GUI.backgroundColor = Color.white;
                }
                else
                {
                    //Don't allow name edits in play mode. Instead show just a label
                    if (data.varType != typeof(VariableSeperator))
                    {
                        GUI.backgroundColor = new Color(0.7f, 0.7f, 0.7f);
                        GUI.color           = new Color(0.8f, 0.8f, 1f);
                        GUILayout.Label(data.name, layoutOptions);
                    }
                    else
                    {
                        GUI.color = Color.yellow;
                        GUILayout.Label(string.Format("<b>{0}</b>", data.name.ToUpper()), layoutOptions);
                        GUI.color = Color.white;
                    }
                }

                //reset coloring
                GUI.color           = Color.white;
                GUI.backgroundColor = Color.white;

                //Highlight used variable by selection?
                if (isUsed)
                {
                    var r   = GUILayoutUtility.GetLastRect();
                    r.xMin += 2;
                    r.xMax -= 2;
                    r.yMax -= 4;
                    GUI.Box(r, "", (GUIStyle)"LightmapEditorSelectedHighlight");
                }

                //Show the respective data GUI
                if (data.varType != typeof(VariableSeperator))
                {
                    ShowDataGUI(data, bb, contextParent, layoutOptions);
                }
                else
                {
                    GUILayout.Space(0);
                    GUILayout.Space(0);
                }

                //reset coloring
                GUI.color           = Color.white;
                GUI.backgroundColor = Color.white;

                //'X' to delete data
                if (!Application.isPlaying && GUILayout.Button("X", GUILayout.Width(20), GUILayout.Height(16)))
                {
                    if (EditorUtility.DisplayDialog("Delete Variable '" + data.name + "'", "Are you sure?", "Yes", "No!"))
                    {
                        tempStates[bb].list.Remove(data);
                        bb.RemoveVariable(data.name);
                        GUIUtility.hotControl      = 0;
                        GUIUtility.keyboardControl = 0;
                    }
                }

                GUILayout.EndHorizontal();
            }, contextParent);

            //reset coloring
            GUI.backgroundColor = Color.white;
            GUI.color           = Color.white;

            if ((GUI.changed && !tempStates[bb].isReordering) || e.rawType == EventType.MouseUp)
            {
                tempStates[bb].isReordering  = false;
                EditorApplication.delayCall += () => { pickedVariable = null; pickedVariableBlackboard = null; };
                //reconstruct the dictionary
                try { bb.variables = tempStates[bb].list.ToDictionary(d => d.name, d => d); }
                catch { Debug.LogError("Blackboard has duplicate names!"); }
            }

            //Check dirty
            UndoManager.CheckDirty(contextParent);
        }
예제 #25
0
		public override void OnFlowCreateMenuGUI(string prefix, GenericMenu menu) {

			if (this.InstallationNeeded() == false) {

				menu.AddSeparator(prefix);

				menu.AddItem(new GUIContent(prefix + "Functions/Definition"), on: false, func: () => {
					
					this.flowEditor.CreateNewItem(() => {
						
						var window = FlowSystem.CreateWindow(flags: FlowWindow.Flags.IsContainer | FlowWindow.Flags.IsFunction);
						window.title = "Function Definition";

						return window;
						
					});

				});

				menu.AddItem(new GUIContent(prefix + "Functions/Call"), on: false, func: () => {
					
					this.flowEditor.CreateNewItem(() => {
						
						var window = FlowSystem.CreateWindow(flags: FlowWindow.Flags.IsFunction | FlowWindow.Flags.IsSmall | FlowWindow.Flags.CantCompiled);
						window.smallStyleDefault = "flow node 3";
						window.smallStyleSelected = "flow node 3 on";
						window.title = "Function Call";

						window.rect.width = 150f;
						window.rect.height = 100f;

						return window;
						
					});

				});

			}

		}
예제 #26
0
        void ShowButton(Rect position)
        {
            Event e = Event.current;

            if (GUI.Button(position, EditorPlus.EditorPlusIcon, new GUIStyle(GUI.skin.label)))
            {
                if (e.button != 0)
                {
                    return;
                }
                GenericMenu menu = new GenericMenu();

                foreach (string def in ShortcutsDefaults)
                {
                    string[] name = def.Split('/');
                    if (!Shortcuts.Contains(def))
                    {
                        menu.AddItem(new GUIContent("Add Item/Defaults/" + name[name.Length - 1]), false, AddToActive, def);
                    }
                    else
                    {
                        menu.AddDisabledItem(new GUIContent("Add Item/Defaults/" + name[name.Length - 1]));
                    }
                }

                if (ShortcutsDefaults.Count > 0)
                {
                    menu.AddSeparator("Add Item/Defaults/");
                    menu.AddItem(new GUIContent("Add Item/Defaults/Add All"), false, AddAllDefaults);
                }

                foreach (string def in ShortcutsDefaultsUI)
                {
                    string[] name = def.Split('/');
                    if (!Shortcuts.Contains(def))
                    {
                        menu.AddItem(new GUIContent("Add Item/DefaultsUI/" + name[name.Length - 1]), false, AddToActive, def);
                    }
                    else
                    {
                        menu.AddDisabledItem(new GUIContent("Add Item/DefaultsUI/" + name[name.Length - 1]));
                    }
                }

                if (ShortcutsDefaults.Count > 0)
                {
                    menu.AddSeparator("Add Item/DefaultsUI/");
                    menu.AddItem(new GUIContent("Add Item/DefaultsUI/Add All"), false, AddAllDefaultsUI);
                }

                foreach (string cust in ShortcutsCustoms)
                {
                    string[] name = cust.Split('/');
                    if (!Shortcuts.Contains(cust))
                    {
                        menu.AddItem(new GUIContent("Add Item/Customs/" + name[name.Length - 1]), false, AddToActive, cust);
                    }
                    else
                    {
                        menu.AddDisabledItem(new GUIContent("Add Item/Customs/" + name[name.Length - 1]));
                    }
                }

                if (ShortcutsCustoms.Count > 0)
                {
                    menu.AddSeparator("Add Item/Customs/");
                    menu.AddItem(new GUIContent("Add Item/Customs/Add All"), false, AddAllCustoms);
                }

                for (int i = 0; i < Shortcuts.Count; ++i)
                {
                    string[] name = Shortcuts[i].Split('/');
                    int      ind  = i;
                    menu.AddItem(new GUIContent("Remove Item/" + name[name.Length - 1]), false, RemoveFromActive, (object)Shortcuts[i]);
                    if (ind != i)
                    {
                        i = ind;    //necessary since we delete items during loop
                    }
                }

                if (Shortcuts.Count > 0)
                {
                    menu.AddSeparator("Remove Item/");
                    menu.AddItem(new GUIContent("Remove Item/Remove All"), false, ClearActive);
                }

                menu.AddSeparator("");

                menu.AddItem(new GUIContent("Add Custom Button"), false, EnableEditing);


                menu.ShowAsContext();
            }
        }
	private void CreateEmptyMenu (bool isAsset)
	{
		GenericMenu menu = new GenericMenu ();
		menu.AddItem (new GUIContent ("Add new Action"), false, EmptyCallback, "Add new Action");
		if (AdvGame.copiedActions != null && AdvGame.copiedActions.Count > 0)
		{
			menu.AddSeparator ("");
			menu.AddItem (new GUIContent ("Paste copied Action(s)"), false, EmptyCallback, "Paste copied Action(s)");
		}
		
		menu.AddSeparator ("");
		menu.AddItem (new GUIContent ("Select all"), false, EmptyCallback, "Select all");
		
		if (NumActionsMarked (isAsset) > 0)
		{
			menu.AddItem (new GUIContent ("Deselect all"), false, EmptyCallback, "Deselect all");
			menu.AddSeparator ("");
			menu.AddItem (new GUIContent ("Copy selected"), false, EmptyCallback, "Copy selected");
			menu.AddItem (new GUIContent ("Delete selected"), false, EmptyCallback, "Delete selected");
			
			if (NumActionsMarked (isAsset) == 1)
			{
				menu.AddSeparator ("");
				menu.AddItem (new GUIContent ("Move to front"), false, EmptyCallback, "Move to front");
			}
		}
		
		menu.AddSeparator ("");
		menu.AddItem (new GUIContent ("Auto-arrange"), false, EmptyCallback, "Auto-arrange");
		
		menu.ShowAsContext ();
	}
        ///The gear context menu for all parameters
        public static void DoParamGearContextMenu(AnimatedParameter animParam, IKeyable keyable)
        {
            var keyableLength = keyable.endTime - keyable.startTime;
            var keyableTime   = Mathf.Clamp(keyable.root.currentTime - keyable.startTime, 0, keyableLength);
            var hasKeyNow     = animParam.HasKey(keyableTime);
            var hasAnyKey     = animParam.HasAnyKey();

            var menu = new GenericMenu();

            if (animParam.enabled)
            {
                if (hasKeyNow)
                {
                    menu.AddDisabledItem(new GUIContent("Add Key"));
                    menu.AddItem(new GUIContent("Remove Key"), false, () => { animParam.RemoveKey(keyableTime); });
                }
                else
                {
                    menu.AddItem(new GUIContent("Add Key"), false, () => { animParam.SetKeyCurrent(keyableTime); });
                    menu.AddDisabledItem(new GUIContent("Remove Key"));
                }

                if (hasAnyKey)
                {
                    menu.AddItem(new GUIContent("Pre Wrap Mode/Clamp"), false, () => { animParam.SetPreWrapMode(WrapMode.ClampForever); });
                    menu.AddItem(new GUIContent("Pre Wrap Mode/Loop"), false, () => { animParam.SetPreWrapMode(WrapMode.Loop); });
                    menu.AddItem(new GUIContent("Pre Wrap Mode/PingPong"), false, () => { animParam.SetPreWrapMode(WrapMode.PingPong); });

                    menu.AddItem(new GUIContent("Post Wrap Mode/Clamp"), false, () => { animParam.SetPostWrapMode(WrapMode.ClampForever); });
                    menu.AddItem(new GUIContent("Post Wrap Mode/Loop"), false, () => { animParam.SetPostWrapMode(WrapMode.Loop); });
                    menu.AddItem(new GUIContent("Post Wrap Mode/PingPong"), false, () => { animParam.SetPostWrapMode(WrapMode.PingPong); });
                }
                else
                {
                    menu.AddDisabledItem(new GUIContent("Pre Wrap Mode"));
                    menu.AddDisabledItem(new GUIContent("Post Wrap Mode"));
                }

#if SLATE_USE_EXPRESSIONS
                if (!animParam.hasActiveExpression)
                {
                    menu.AddItem(new GUIContent("Set Expression"), false, () => { animParam.scriptExpression = "value"; });
                    menu.AddDisabledItem(new GUIContent("Remove Expression"));
                }
                else
                {
                    menu.AddDisabledItem(new GUIContent("Set Expression"));
                    menu.AddItem(new GUIContent("Remove Expression"), false, () => { animParam.scriptExpression = null; });
                }
#endif
            }

            menu.AddItem(new GUIContent(animParam.enabled ? "Disable" : "Enable"), false, () => { animParam.SetEnabled(!animParam.enabled, keyableTime); });

            menu.AddSeparator("/");
            if (hasAnyKey)
            {
                menu.AddItem(new GUIContent("Remove Animation"), false, () =>
                {
                    if (EditorUtility.DisplayDialog("Reset Animation", "All animation keys will be removed for this parameter.\nAre you sure?", "Yes", "No"))
                    {
                        if (animParam.isExternal)
                        {
                            animParam.RestoreSnapshot();
                        }
                        animParam.Reset();
                        if (animParam.isExternal)
                        {
                            animParam.SetSnapshot();
                        }
                    }
                });
            }
            else
            {
                menu.AddDisabledItem(new GUIContent("Remove Animation"));
            }

            if (animParam.isExternal)
            {
                menu.AddItem(new GUIContent("Remove Parameter"), false, () =>
                {
                    if (EditorUtility.DisplayDialog("Remove Parameter", "Completely Remove Parameter.\nAre you sure?", "Yes", "No"))
                    {
                        animParam.RestoreSnapshot();
                        keyable.animationData.RemoveParameter(animParam);
                        CutsceneUtility.RefreshAllAnimationEditorsOf(keyable.animationData);
                    }
                });
            }

            menu.ShowAsContext();
            Event.current.Use();
        }
예제 #29
0
	void Selector(SerializedProperty property) {
		SpineBone attrib = (SpineBone)attribute;
		SkeletonData data = skeletonDataAsset.GetSkeletonData(true);
		if (data == null)
			return;

		GenericMenu menu = new GenericMenu();

		menu.AddDisabledItem(new GUIContent(skeletonDataAsset.name));
		menu.AddSeparator("");

		for (int i = 0; i < data.Bones.Count; i++) {
			string name = data.Bones.Items[i].Name;
			if (name.StartsWith(attrib.startsWith))
				menu.AddItem(new GUIContent(name), name == property.stringValue, HandleSelect, new SpineDrawerValuePair(name, property));
		}

		menu.ShowAsContext();
	}
예제 #30
0
        public virtual void ShowContextMenu()
        {
            var block     = target as Block;
            var flowchart = (Flowchart)block.GetFlowchart();

            if (flowchart == null)
            {
                return;
            }

            bool showCut    = false;
            bool showCopy   = false;
            bool showDelete = false;
            bool showPaste  = false;
            bool showPlay   = false;

            if (flowchart.SelectedCommands.Count > 0)
            {
                showCut    = true;
                showCopy   = true;
                showDelete = true;
                if (flowchart.SelectedCommands.Count == 1 && Application.isPlaying)
                {
                    showPlay = true;
                }
            }



            CommandCopyBuffer commandCopyBuffer = CommandCopyBuffer.GetInstance();

            if (commandCopyBuffer.HasCommands())
            {
                showPaste = true;
            }

            GenericMenu commandMenu = new GenericMenu();

            if (showCut)
            {
                commandMenu.AddItem(new GUIContent("Cut"), false, Cut);
            }
            else
            {
                commandMenu.AddDisabledItem(new GUIContent("Cut"));
            }

            if (showCopy)
            {
                commandMenu.AddItem(new GUIContent("Copy"), false, Copy);
            }
            else
            {
                commandMenu.AddDisabledItem(new GUIContent("Copy"));
            }

            if (showPaste)
            {
                commandMenu.AddItem(new GUIContent("Paste"), false, Paste);
            }
            else
            {
                commandMenu.AddDisabledItem(new GUIContent("Paste"));
            }

            if (showDelete)
            {
                commandMenu.AddItem(new GUIContent("Delete"), false, Delete);
            }
            else
            {
                commandMenu.AddDisabledItem(new GUIContent("Delete"));
            }

            if (showPlay)
            {
                commandMenu.AddItem(new GUIContent("Play from selected"), false, PlayCommand);
                commandMenu.AddItem(new GUIContent("Stop all and play"), false, StopAllPlayCommand);
            }

            commandMenu.AddSeparator("");

            commandMenu.AddItem(new GUIContent("Select All"), false, SelectAll);
            commandMenu.AddItem(new GUIContent("Select None"), false, SelectNone);

            commandMenu.ShowAsContext();
        }
        //Returns single node context menu
        static GenericMenu GetNodeMenu_Single(Node node)
        {
            var menu = new GenericMenu();

            if (node.graph.primeNode != node && node.allowAsPrime)
            {
                menu.AddItem(new GUIContent("Set Start"), false, () => { node.graph.primeNode = node; });
            }

            if (node is IGraphAssignable)
            {
                menu.AddItem(new GUIContent("Edit Nested (Double Click)"), false, () => { node.graph.currentChildGraph = (node as IGraphAssignable).nestedGraph; });
            }

            menu.AddItem(new GUIContent("Duplicate (CTRL+D)"), false, () => { GraphEditorUtility.activeElement = node.Duplicate(node.graph); });
            menu.AddItem(new GUIContent("Copy Node"), false, () => { CopyBuffer.Set <Node[]>(new Node[] { node }); });

            if (node.inConnections.Count > 0)
            {
                menu.AddItem(new GUIContent(node.isActive? "Disable" : "Enable"), false, () => { node.SetActive(!node.isActive); });
            }

            if (node.graph.autoSort && node.outConnections.Count > 0)
            {
                menu.AddItem(new GUIContent(node.collapsed? "Expand Children" : "Collapse Children"), false, () => { node.collapsed = !node.collapsed; });
            }

            if (node is ITaskAssignable)
            {
                var assignable = node as ITaskAssignable;
                if (assignable.task != null)
                {
                    menu.AddItem(new GUIContent("Copy Assigned Task"), false, () => { CopyBuffer.Set <Task>(assignable.task); });
                }
                else
                {
                    menu.AddDisabledItem(new GUIContent("Copy Assigned Task"));
                }

                if (CopyBuffer.Has <Task>())
                {
                    menu.AddItem(new GUIContent("Paste Assigned Task"), false, () =>
                    {
                        if (assignable.task == CopyBuffer.Peek <Task>())
                        {
                            return;
                        }

                        if (assignable.task != null)
                        {
                            if (!EditorUtility.DisplayDialog("Paste Task", string.Format("Node already has a Task assigned '{0}'. Replace assigned task with pasted task '{1}'?", assignable.task.name, CopyBuffer.Peek <Task>().name), "YES", "NO"))
                            {
                                return;
                            }
                        }

                        try { assignable.task = CopyBuffer.Get <Task>().Duplicate(node.graph); }
                        catch { ParadoxNotion.Services.Logger.LogWarning("Can't paste Task here. Incombatible Types", "Editor", node); }
                    });
                }
                else
                {
                    menu.AddDisabledItem(new GUIContent("Paste Assigned Task"));
                }
            }

            //extra items with override
            menu = node.OnContextMenu(menu);

            if (menu != null)
            {
                //extra items with attribute
                foreach (var _m in node.GetType().RTGetMethods())
                {
                    var m   = _m;
                    var att = m.RTGetAttribute <ContextMenu>(true);
                    if (att != null)
                    {
                        menu.AddItem(new GUIContent(att.menuItem), false, () => { m.Invoke(node, null); });
                    }
                }

                menu.AddSeparator("/");
                menu.AddItem(new GUIContent("Delete (DEL)"), false, () => { node.graph.RemoveNode(node); });
            }
            return(menu);
        }
예제 #32
0
        public static bool Header(string title, SerializedProperty group, SerializedProperty enabledField, Action resetAction)
        {
            var          field  = ReflectionUtils.GetFieldInfoFromPath(enabledField.serializedObject.targetObject, enabledField.propertyPath);
            object       parent = null;
            PropertyInfo prop   = null;

            if (field != null && field.IsDefined(typeof(GetSetAttribute), false))
            {
                var attr = (GetSetAttribute)field.GetCustomAttributes(typeof(GetSetAttribute), false)[0];
                parent = ReflectionUtils.GetParentObject(enabledField.propertyPath, enabledField.serializedObject.targetObject);
                prop   = parent.GetType().GetProperty(attr.name);
            }

            var display = group == null || group.isExpanded;
            var enabled = enabledField.boolValue;

            var rect = GUILayoutUtility.GetRect(16f, 22f, FxStyles.header);

            GUI.Box(rect, title, FxStyles.header);

            var toggleRect = new Rect(rect.x + 4f, rect.y + 4f, 13f, 13f);
            var e          = Event.current;

            var popupRect = new Rect(rect.x + rect.width - FxStyles.paneOptionsIcon.width - 5f, rect.y + FxStyles.paneOptionsIcon.height / 2f + 1f, FxStyles.paneOptionsIcon.width, FxStyles.paneOptionsIcon.height);

            GUI.DrawTexture(popupRect, FxStyles.paneOptionsIcon);

            if (e.type == EventType.Repaint)
            {
                FxStyles.headerCheckbox.Draw(toggleRect, false, false, enabled, false);
            }

            if (e.type == EventType.MouseDown)
            {
                const float kOffset = 2f;
                toggleRect.x      -= kOffset;
                toggleRect.y      -= kOffset;
                toggleRect.width  += kOffset * 2f;
                toggleRect.height += kOffset * 2f;

                if (toggleRect.Contains(e.mousePosition))
                {
                    enabledField.boolValue = !enabledField.boolValue;

                    if (prop != null)
                    {
                        prop.SetValue(parent, enabledField.boolValue, null);
                    }

                    e.Use();
                }
                else if (popupRect.Contains(e.mousePosition))
                {
                    var popup = new GenericMenu();
                    popup.AddItem(GetContent("Reset"), false, () => resetAction());
                    popup.AddSeparator(string.Empty);
                    popup.AddItem(GetContent("Copy Settings"), false, () => CopySettings(group));

                    if (CanPaste(group))
                    {
                        popup.AddItem(GetContent("Paste Settings"), false, () => PasteSettings(group));
                    }
                    else
                    {
                        popup.AddDisabledItem(GetContent("Paste Settings"));
                    }

                    popup.ShowAsContext();
                }
                else if (rect.Contains(e.mousePosition) && group != null)
                {
                    display          = !display;
                    group.isExpanded = !group.isExpanded;
                    e.Use();
                }
            }

            return(display);
        }
        void OnContextClick(Vector2 position, VolumeComponentEditor targetEditor, int id)
        {
            var targetComponent = targetEditor.target;
            var menu            = new GenericMenu();

            if (id == 0)
            {
                menu.AddDisabledItem(EditorGUIUtility.TrTextContent("Move Up"));
                menu.AddDisabledItem(EditorGUIUtility.TrTextContent("Move to Top"));
            }
            else
            {
                menu.AddItem(EditorGUIUtility.TrTextContent("Move to Top"), false, () => MoveComponent(id, -id));
                menu.AddItem(EditorGUIUtility.TrTextContent("Move Up"), false, () => MoveComponent(id, -1));
            }

            if (id == m_Editors.Count - 1)
            {
                menu.AddDisabledItem(EditorGUIUtility.TrTextContent("Move to Bottom"));
                menu.AddDisabledItem(EditorGUIUtility.TrTextContent("Move Down"));
            }
            else
            {
                menu.AddItem(EditorGUIUtility.TrTextContent("Move to Bottom"), false, () => MoveComponent(id, (m_Editors.Count - 1) - id));
                menu.AddItem(EditorGUIUtility.TrTextContent("Move Down"), false, () => MoveComponent(id, 1));
            }

            menu.AddSeparator(string.Empty);
            menu.AddItem(EditorGUIUtility.TrTextContent("Collapse All"), false, () => CollapseComponents());
            menu.AddItem(EditorGUIUtility.TrTextContent("Expand All"), false, () => ExpandComponents());
            menu.AddSeparator(string.Empty);
            menu.AddItem(EditorGUIUtility.TrTextContent("Reset"), false, () => ResetComponent(targetComponent.GetType(), id));
            menu.AddItem(EditorGUIUtility.TrTextContent("Remove"), false, () => RemoveComponent(id));
            menu.AddSeparator(string.Empty);
            if (targetEditor.hasAdditionalProperties)
            {
                menu.AddItem(EditorGUIUtility.TrTextContent("Show Additional Properties"), targetEditor.showAdditionalProperties, () => targetEditor.showAdditionalProperties ^= true);
                menu.AddItem(EditorGUIUtility.TrTextContent("Show All Additional Properties..."), false, () => CoreRenderPipelinePreferences.Open());
            }
            else
            {
                menu.AddDisabledItem(EditorGUIUtility.TrTextContent("Show Additional Properties"));
                menu.AddDisabledItem(EditorGUIUtility.TrTextContent("Show All Additional Properties..."));
            }

            menu.AddSeparator(string.Empty);
            menu.AddItem(EditorGUIUtility.TrTextContent("Copy Settings"), false, () => CopySettings(targetComponent));

            if (CanPaste(targetComponent))
            {
                menu.AddItem(EditorGUIUtility.TrTextContent("Paste Settings"), false, () => PasteSettings(targetComponent));
            }
            else
            {
                menu.AddDisabledItem(EditorGUIUtility.TrTextContent("Paste Settings"));
            }

            menu.AddSeparator(string.Empty);
            menu.AddItem(EditorGUIUtility.TrTextContent("Toggle All"), false, () => m_Editors[id].SetAllOverridesTo(true));
            menu.AddItem(EditorGUIUtility.TrTextContent("Toggle None"), false, () => m_Editors[id].SetAllOverridesTo(false));

            menu.DropDown(new Rect(position, Vector2.zero));
        }
        private void DrawRoot(GUIContent label, Rect position, SerializedObject sObject, SerializedProperty sSpeed, SerializedProperty sRoots, SerializedProperty sRoot, int index)
        {
            var e     = Event.current;
            var rectL = position; rectL.width = EditorGUIUtility.labelWidth - 16.0f;
            var rectR = position; rectR.xMin += EditorGUIUtility.labelWidth;

            if (e.isMouse == true && e.button == 1 && rectL.Contains(e.mousePosition) == true)
            {
                var menu          = new GenericMenu();
                var methodPrefabs = AssetDatabase.FindAssets("t:GameObject").
                                    Select((guid) => AssetDatabase.LoadAssetAtPath <GameObject>(AssetDatabase.GUIDToAssetPath(guid))).
                                    Where((prefab) => prefab.GetComponent <LeanMethod>() != null);
                var targetComponent = sObject.targetObject as Component;

                if (targetComponent != null)
                {
                    if (sRoot.objectReferenceValue == null)
                    {
                        var title = label.text;

                        menu.AddItem(new GUIContent("Create"), false, () =>
                        {
                            var root = new GameObject("[" + title + "]").transform;

                            root.SetParent(targetComponent.transform, false);

                            sRoots.GetArrayElementAtIndex(index).objectReferenceValue = root;
                            sObject.ApplyModifiedProperties();

                            Selection.activeTransform = root;
                        });
                    }
                    else
                    {
                        menu.AddItem(new GUIContent("Add"), false, () =>
                        {
                            sRoots.InsertArrayElementAtIndex(index + 1);
                            sRoots.GetArrayElementAtIndex(index + 1).objectReferenceValue = null;
                            sObject.ApplyModifiedProperties();
                        });
                    }
                }

                if (sSpeed.floatValue <= 0.0f)
                {
                    menu.AddItem(new GUIContent("Speed"), false, () =>
                    {
                        sSpeed.floatValue = 1.0f;
                        sObject.ApplyModifiedProperties();
                    });
                }
                else
                {
                    menu.AddItem(new GUIContent("Speed"), true, () =>
                    {
                        sSpeed.floatValue = 0.0f;
                        sObject.ApplyModifiedProperties();
                    });
                }

                menu.AddSeparator("");

                foreach (var methodPrefab in methodPrefabs)
                {
                    var root = methodPrefab.transform;

                    menu.AddItem(new GUIContent("Prefab/" + methodPrefab.name), false, () =>
                    {
                        sRoot.objectReferenceValue = root;
                        sObject.ApplyModifiedProperties();
                    });
                }

                menu.AddSeparator("");

                menu.AddItem(new GUIContent("Remove"), false, () =>
                {
                    sRoots.GetArrayElementAtIndex(index).objectReferenceValue = null;
                    sRoots.DeleteArrayElementAtIndex(index);
                    sObject.ApplyModifiedProperties();
                });

                menu.ShowAsContext();
            }

            EditorGUI.LabelField(rectL, label);

            EditorGUI.PropertyField(rectR, sRoot, GUIContent.none);
        }
예제 #35
0
    private static void ShowPopup(Event evt, UTNodeEditorModel model)
    {
        var menu = new GenericMenu();

        if (!model.HasPlan)
        {
            menu.AddDisabledItem(new GUIContent("Please select an automation plan."));
            menu.ShowAsContext();
            return;
        }


        var hotNode      = GetNodeUnderMouse(model, evt.mousePosition);
        var hotConnector = GetConnectorUnderMouse(model, evt.mousePosition);
        var data         = new NodeEventData(evt, model, hotConnector);

        if (hotNode == null && hotConnector == null)
        {
            menu.AddItem(new GUIContent("Add Action Node"), false, AddActionNode, data);
            menu.AddItem(new GUIContent("Add Decision Node"), false, AddDecisionNode, data);
            menu.AddItem(new GUIContent("Add My Decision Node"), false, AddMyDecisionNode, data);
            menu.AddItem(new GUIContent("Add LowQuality Decision Node"), false, AddLowQualityDecisionNode, data);
            menu.AddItem(new GUIContent("Add My CopyAssetBundles Decision Node"), false, AddMyCopyAssetBundlesDecisionNode, data);
            menu.AddItem(new GUIContent("Add For-Each Node"), false, AddForEachNode, data);
            menu.AddItem(new GUIContent("Add For-Each File Node"), false, AddForEachFileNode, data);
            menu.AddItem(new GUIContent("Add My For-Each For Build Node"), false, AddMyForEachForBuildNode, data);
            menu.AddItem(new GUIContent("Add Sub-Plan Node"), false, AddPlanNode, data);
            menu.AddItem(new GUIContent("Add Note"), false, AddNote, data);
        }

        if (hotNode != null)
        {
            if (!model.SelectedNodes.Contains(hotNode))
            {
                model.SelectNode(hotNode, UTNodeEditorModel.SelectionMode.Replace);
            }

            if (menu.GetItemCount() > 0)
            {
                menu.AddSeparator("");
            }

            var isMultiSelection = model.SelectedNodes.Count > 1;

            if (!model.IsFirstNode(hotNode) && !isMultiSelection && !(hotNode.Data is UTAutomationPlanNoteEntry))
            {
                menu.AddItem(new GUIContent("Set As First Node"), false, SetAsFirstNode, data);
            }
            menu.AddItem(new GUIContent(isMultiSelection ? "Delete Nodes" : "Delete Node"), false, DeleteNode, data);
        }

        if (hotConnector != null && hotConnector.isConnected)
        {
            if (menu.GetItemCount() > 0)
            {
                menu.AddSeparator("");
            }
            menu.AddItem(new GUIContent("Delete Connection"), false, DeleteConnection, data);
        }
        menu.ShowAsContext();
    }
예제 #36
0
        private void OnGUI()
        {
            Event e = Event.current;

            mousePos = e.mousePosition;

            if (e.button == 1 && !makeTransitionMode)
            {
                if (e.type == EventType.MouseDown)
                {
                    bool clickedOnWindow = false;
                    int  selectIndex     = -1;

                    for (int i = 0; i < windows.Count; i++)
                    {
                        if (windows[i].windowRect.Contains(mousePos))
                        {
                            selectIndex     = i;
                            clickedOnWindow = true;
                            break;
                        }
                    }

                    if (!clickedOnWindow)
                    {
                        GenericMenu menu = new GenericMenu();

                        menu.AddItem(new GUIContent("Add Input Node"), false, ContextCallback, "inputNode");
                        menu.AddItem(new GUIContent("Add Output Node"), false, ContextCallback, "outputNode");
                        menu.AddItem(new GUIContent("Calculation Node"), false, ContextCallback, "calcNode");
                        menu.AddItem(new GUIContent("Comparison Node"), false, ContextCallback, "compNode");

                        menu.ShowAsContext();
                        e.Use();
                    }
                    else
                    {
                        GenericMenu menu = new GenericMenu();

                        menu.AddItem(new GUIContent("Make Transition"), false, ContextCallback, "makeTransition");
                        menu.AddSeparator("");
                        menu.AddItem(new GUIContent("Delete Node"), false, ContextCallback, "deleteNode");

                        menu.ShowAsContext();
                        e.Use();
                    }
                }
            }
            else if (e.button == 0 && e.type == EventType.MouseDown && makeTransitionMode)
            {
                bool clickedOnWindow = false;
                int  selectIndex     = -1;

                for (int i = 0; i < windows.Count; i++)
                {
                    if (windows[i].windowRect.Contains(mousePos))
                    {
                        selectIndex     = i;
                        clickedOnWindow = true;
                        break;
                    }
                }

                if (clickedOnWindow && !windows[selectIndex].Equals(selectedNode))
                {
                    windows[selectIndex].SetInput((BaseInputNode)selectedNode, mousePos);
                    makeTransitionMode = false;
                    selectedNode       = null;
                }

                if (!clickedOnWindow)
                {
                    makeTransitionMode = false;
                    selectedNode       = null;
                }

                e.Use();
            }
            else if (e.button == 0 && e.type == EventType.MouseDown && !makeTransitionMode)
            {
                bool clickedOnWindow = false;
                int  selectIndex     = -1;

                for (int i = 0; i < windows.Count; i++)
                {
                    if (windows[i].windowRect.Contains(mousePos))
                    {
                        selectIndex     = i;
                        clickedOnWindow = true;
                        break;
                    }
                }

                if (clickedOnWindow)
                {
                    BaseInputNode nodeToChange = windows[selectIndex].CLickedOnIput(mousePos);

                    if (nodeToChange != null)
                    {
                        selectedNode       = nodeToChange;
                        makeTransitionMode = true;
                    }
                }
            }

            if (makeTransitionMode && selectedNode != null)
            {
                Rect mouseRect = new Rect(e.mousePosition.x, mousePos.y, 10, 10);
                DrawNodeCurve(selectedNode.windowRect, mouseRect);
                Repaint();
            }

            foreach (BaseNode n in windows)
            {
                n.DrawCurves();
            }

            BeginWindows();

            for (int i = 0; i < windows.Count; i++)
            {
                windows[i].windowRect = GUI.Window(i, windows[i].windowRect, DrawNodeWindow, windows[i].windowTitle);
            }

            EndWindows();
        }
        private void DrawBranchesList()
        {
            using (var scrollView = new EditorGUILayout.ScrollViewScope(m_BranchesScroll)) {
                m_BranchesScroll = scrollView.scrollPosition;

                // For hover effects to work.
                if (Event.current.type == EventType.MouseMove)
                {
                    Repaint();
                }

                // TODO: Sort list by folder depths: compare by lastIndexOf('/'). If equal, by string.

                foreach (var branchProject in Database.BranchProjects)
                {
                    if (!string.IsNullOrEmpty(m_BranchFilter) && branchProject.BranchName.IndexOf(m_BranchFilter, System.StringComparison.OrdinalIgnoreCase) == -1)
                    {
                        continue;
                    }

                    // Apply setting only in Scanned mode since the thread will still be working otherwise and
                    // cause inconsistent GUILayout structure.
                    if (m_ConflictsScanState == ConflictsScanState.Scanned && !m_ConflictsShowNormal)
                    {
                        var conflictResult = m_ConflictsScanResults.First(r => r.UnityURL == branchProject.UnityProjectURL);
                        if (conflictResult.State == ConflictState.Normal)
                        {
                            continue;
                        }
                    }

                    using (new EditorGUILayout.HorizontalScope(/*BranchRowStyle*/)) {
                        float buttonSize   = 24f;
                        bool  repoBrowser  = GUILayout.Button(RepoBrowserContent, MiniIconButtonlessStyle, GUILayout.Height(buttonSize), GUILayout.Width(buttonSize));
                        bool  showLog      = GUILayout.Button(SelectShowLogContent(branchProject), MiniIconButtonlessStyle, GUILayout.Height(buttonSize), GUILayout.Width(buttonSize));
                        bool  switchBranch = GUILayout.Button(SwitchBranchContent, MiniIconButtonlessStyle, GUILayout.Height(buttonSize), GUILayout.Width(buttonSize));

                        bool branchSelected = GUILayout.Button(new GUIContent(branchProject.BranchRelativePath, branchProject.BranchURL), BranchLabelStyle);

                        if (repoBrowser)
                        {
                            SVNContextMenusManager.RepoBrowser(branchProject.UnityProjectURL + "/" + AssetDatabase.GetAssetPath(m_TargetAsset));
                        }

                        if (showLog)
                        {
                            SVNContextMenusManager.ShowLog(branchProject.UnityProjectURL + "/" + AssetDatabase.GetAssetPath(m_TargetAsset));
                        }

                        if (switchBranch)
                        {
                            bool confirm = EditorUtility.DisplayDialog("Switch Operation",
                                                                       "Unity needs to be closed while switching. Do you want to close it?\n\n" +
                                                                       "Reason: if Unity starts crunching assets while SVN is downloading files, the Library may get corrupted.",
                                                                       "Yes!", "No"
                                                                       );
                            if (confirm && UnityEditor.SceneManagement.EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
                            {
                                var localPathNative = WiseSVNIntegration.WorkingCopyRootPath();
                                var targetUrl       = branchProject.BranchURL;

                                if (branchProject.BranchURL != branchProject.UnityProjectURL)
                                {
                                    bool useBranchRoot = EditorUtility.DisplayDialog("Switch what?",
                                                                                     "What do you want to switch?\n" +
                                                                                     "- Working copy root (the whole checkout)\n" +
                                                                                     "- Unity project folder",
                                                                                     "Working copy root", "Unity project");
                                    if (!useBranchRoot)
                                    {
                                        localPathNative = WiseSVNIntegration.ProjectRootNative;
                                        targetUrl       = branchProject.UnityProjectURL;
                                    }
                                }

                                SVNContextMenusManager.Switch(localPathNative, targetUrl);
                                EditorApplication.Exit(0);
                            }
                        }

                        if (branchSelected)
                        {
                            var menu = new GenericMenu();

                            var prevValue = BranchContextMenu.CopyBranchName;
                            foreach (var value in System.Enum.GetValues(typeof(BranchContextMenu)).OfType <BranchContextMenu>())
                            {
                                if ((int)value / 10 != (int)prevValue / 10)
                                {
                                    menu.AddSeparator("");
                                }

                                menu.AddItem(new GUIContent(ObjectNames.NicifyVariableName(value.ToString())), false, OnSelectBranchOption, new KeyValuePair <BranchContextMenu, BranchProject>(value, branchProject));
                                prevValue = value;
                            }

                            menu.ShowAsContext();
                        }
                    }

                    var rect = EditorGUILayout.GetControlRect(GUILayout.ExpandWidth(true), GUILayout.Height(1f));
                    EditorGUI.DrawRect(rect, Color.black);
                }
            }
        }
    void Selector(SerializedProperty property)
    {
        SkeletonData data = skeletonDataAsset.GetSkeletonData(true);

        if (data == null)
        {
            return;
        }

        SpineAttachment attrib = (SpineAttachment)attribute;

        List <Skin> validSkins = new List <Skin>();

        if (skeletonRenderer != null && attrib.currentSkinOnly)
        {
            if (skeletonRenderer.skeleton.Skin != null)
            {
                validSkins.Add(skeletonRenderer.skeleton.Skin);
            }
            else
            {
                validSkins.Add(data.Skins[0]);
            }
        }
        else
        {
            foreach (Skin skin in data.Skins)
            {
                if (skin != null)
                {
                    validSkins.Add(skin);
                }
            }
        }

        GenericMenu   menu             = new GenericMenu();
        List <string> attachmentNames  = new List <string>();
        List <string> placeholderNames = new List <string>();

        string prefix = "";

        if (skeletonRenderer != null && attrib.currentSkinOnly)
        {
            menu.AddDisabledItem(new GUIContent(skeletonRenderer.gameObject.name + " (SkeletonRenderer)"));
        }
        else
        {
            menu.AddDisabledItem(new GUIContent(skeletonDataAsset.name));
        }
        menu.AddSeparator("");

        menu.AddItem(new GUIContent("Null"), property.stringValue == "", HandleSelect, new SpineDrawerValuePair("", property));
        menu.AddSeparator("");

        Skin defaultSkin = data.Skins[0];

        SerializedProperty slotProperty = property.serializedObject.FindProperty(attrib.slotField);
        string             slotMatch    = "";

        if (slotProperty != null)
        {
            if (slotProperty.propertyType == SerializedPropertyType.String)
            {
                slotMatch = slotProperty.stringValue.ToLower();
            }
        }

        foreach (Skin skin in validSkins)
        {
            string skinPrefix = skin.Name + "/";

            if (validSkins.Count > 1)
            {
                prefix = skinPrefix;
            }

            for (int i = 0; i < data.Slots.Count; i++)
            {
                if (slotMatch.Length > 0 && data.Slots[i].Name.ToLower().Contains(slotMatch) == false)
                {
                    continue;
                }

                attachmentNames.Clear();
                placeholderNames.Clear();

                skin.FindNamesForSlot(i, attachmentNames);
                if (skin != defaultSkin)
                {
                    defaultSkin.FindNamesForSlot(i, attachmentNames);
                    skin.FindNamesForSlot(i, placeholderNames);
                }


                for (int a = 0; a < attachmentNames.Count; a++)
                {
                    string attachmentPath = attachmentNames[a];
                    string menuPath       = prefix + data.Slots[i].Name + "/" + attachmentPath;
                    string name           = attachmentNames[a];

                    if (attrib.returnAttachmentPath)
                    {
                        name = skin.Name + "/" + data.Slots[i].Name + "/" + attachmentPath;
                    }

                    if (attrib.placeholdersOnly && placeholderNames.Contains(attachmentPath) == false)
                    {
                        menu.AddDisabledItem(new GUIContent(menuPath));
                    }
                    else
                    {
                        menu.AddItem(new GUIContent(menuPath), name == property.stringValue, HandleSelect, new SpineDrawerValuePair(name, property));
                    }
                }
            }
        }


        menu.ShowAsContext();
    }
        void DrawSchemas(List <AddressableAssetGroupSchema> schemas)
        {
            GUILayout.Space(6);

            EditorGUILayout.BeginHorizontal();
            var activeProfileName = m_GroupTarget.Settings.profileSettings.GetProfileName(m_GroupTarget.Settings.activeProfileId);

            if (string.IsNullOrEmpty(activeProfileName))
            {
                m_GroupTarget.Settings.activeProfileId = null; //this will reset it to default.
                activeProfileName = m_GroupTarget.Settings.profileSettings.GetProfileName(m_GroupTarget.Settings.activeProfileId);
            }
            EditorGUILayout.PrefixLabel("Active Profile: " + activeProfileName);
            if (GUILayout.Button("Inspect Top Level Settings"))
            {
                EditorGUIUtility.PingObject(AddressableAssetSettingsDefaultObject.Settings);
                Selection.activeObject = AddressableAssetSettingsDefaultObject.Settings;
            }

            EditorGUILayout.EndHorizontal();
            GUILayout.Space(6);


            if (m_FoldoutState == null || m_FoldoutState.Length != schemas.Count)
            {
                m_FoldoutState = new bool[schemas.Count];
            }

            EditorGUILayout.BeginVertical();
            for (int i = 0; i < schemas.Count; i++)
            {
                var schema       = schemas[i];
                int currentIndex = i;

                DrawDivider();
                EditorGUILayout.BeginHorizontal();
                m_FoldoutState[i] = EditorGUILayout.Foldout(m_FoldoutState[i], AddressableAssetUtility.GetCachedTypeDisplayName(schema.GetType()));
                if (!m_GroupTarget.ReadOnly)
                {
                    GUILayout.FlexibleSpace();
                    GUIStyle gearIconStyle = UnityEngine.GUI.skin.FindStyle("IconButton") ?? EditorGUIUtility.GetBuiltinSkin(EditorSkin.Inspector).FindStyle("IconButton");

                    if (EditorGUILayout.DropdownButton(EditorGUIUtility.IconContent("_Popup"), FocusType.Keyboard, gearIconStyle))
                    {
                        var menu = new GenericMenu();
                        menu.AddItem(AddressableAssetGroup.RemoveSchemaContent, false, () =>
                        {
                            if (EditorUtility.DisplayDialog("Remove selected schema?", "Are you sure you want to remove " + AddressableAssetUtility.GetCachedTypeDisplayName(schema.GetType()) + " schema?\n\nYou cannot undo this action.", "Yes", "No"))
                            {
                                m_GroupTarget.RemoveSchema(schema.GetType());
                                var newFoldoutstate = new bool[schemas.Count];
                                for (int j = 0; j < newFoldoutstate.Length; j++)
                                {
                                    if (j < i)
                                    {
                                        newFoldoutstate[j] = m_FoldoutState[j];
                                    }
                                    else
                                    {
                                        newFoldoutstate[j] = m_FoldoutState[i + 1];
                                    }
                                }

                                m_FoldoutState = newFoldoutstate;
                            }
                        });
                        menu.AddItem(AddressableAssetGroup.MoveSchemaUpContent, false, () =>
                        {
                            if (currentIndex > 0)
                            {
                                m_GroupTarget.Schemas[currentIndex]     = m_GroupTarget.Schemas[currentIndex - 1];
                                m_GroupTarget.Schemas[currentIndex - 1] = schema;
                                return;
                            }
                        });
                        menu.AddItem(AddressableAssetGroup.MoveSchemaDownContent, false, () =>
                        {
                            if (currentIndex < m_GroupTarget.Schemas.Count - 1)
                            {
                                m_GroupTarget.Schemas[currentIndex]     = m_GroupTarget.Schemas[currentIndex + 1];
                                m_GroupTarget.Schemas[currentIndex + 1] = schema;
                                return;
                            }
                        });
                        menu.AddSeparator("");
                        menu.AddItem(AddressableAssetGroup.ExpandSchemaContent, false, () =>
                        {
                            m_FoldoutState[currentIndex] = true;
                            foreach (var targetSchema in m_GroupTarget.Schemas)
                            {
                                targetSchema.ShowAllProperties();
                            }
                        });
                        menu.ShowAsContext();
                    }
                }

                EditorGUILayout.EndHorizontal();
                if (m_FoldoutState[i])
                {
                    try
                    {
                        EditorGUI.indentLevel++;
                        if (m_GroupTargets.Length == 1)
                        {
                            schema.OnGUI();
                        }
                        else
                        {
                            schema.OnGUIMultiple(GetSchemasForOtherTargets(schema));
                        }
                        EditorGUI.indentLevel--;
                    }
                    catch (Exception se)
                    {
                        Debug.LogException(se);
                    }
                }
            }

            if (schemas.Count > 0)
            {
                DrawDivider();
            }
            GUILayout.Space(4);
            EditorGUILayout.BeginHorizontal();

            GUILayout.FlexibleSpace();
            GUIStyle addSchemaButton = new GUIStyle(UnityEngine.GUI.skin.button);

            addSchemaButton.fontSize    = 12;
            addSchemaButton.fixedWidth  = 225;
            addSchemaButton.fixedHeight = 22;

            if (!m_GroupTarget.ReadOnly)
            {
                if (EditorGUILayout.DropdownButton(new GUIContent("Add Schema", "Add new schema to this group."), FocusType.Keyboard, addSchemaButton))
                {
                    var menu = new GenericMenu();
                    for (int i = 0; i < m_SchemaTypes.Count; i++)
                    {
                        var type = m_SchemaTypes[i];

                        if (m_GroupTarget.GetSchema(type) == null)
                        {
                            menu.AddItem(new GUIContent(AddressableAssetUtility.GetCachedTypeDisplayName(type), ""), false, () => OnAddSchema(type));
                        }
                        else
                        {
                            menu.AddDisabledItem(new GUIContent(AddressableAssetUtility.GetCachedTypeDisplayName(type), ""), true);
                        }
                    }

                    menu.ShowAsContext();
                }
            }

            GUILayout.FlexibleSpace();

            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndVertical();
        }
예제 #40
0
        private void DrawColumn(Rect rect, IPropertyValueEntry <TArray> entry, Context context, int columnIndex)
        {
            if (columnIndex < context.ColCount)
            {
                GUI.Label(rect, columnIndex.ToString(), SirenixGUIStyles.LabelCentered);

                // Handle Column dragging.
                if (!context.Attribute.IsReadOnly)
                {
                    var id = GUIUtility.GetControlID(FocusType.Passive);
                    if (GUI.enabled && Event.current.type == EventType.MouseDown && Event.current.button == 0 && rect.Contains(Event.current.mousePosition))
                    {
                        GUIHelper.RemoveFocusControl();
                        GUIUtility.hotControl = id;
                        EditorGUIUtility.SetWantsMouseJumping(1);
                        Event.current.Use();
                        context.ColumnDragFrom = columnIndex;
                        context.ColumnDragTo   = columnIndex;
                        context.dragStartPos   = Event.current.mousePosition;
                    }
                    else if (GUIUtility.hotControl == id)
                    {
                        if ((context.dragStartPos - Event.current.mousePosition).sqrMagnitude > 5 * 5)
                        {
                            context.IsDraggingColumn = true;
                        }
                        if (Event.current.type == EventType.MouseDrag)
                        {
                            Event.current.Use();
                        }
                        else if (Event.current.type == EventType.MouseUp)
                        {
                            GUIUtility.hotControl = 0;
                            EditorGUIUtility.SetWantsMouseJumping(0);
                            Event.current.Use();
                            context.IsDraggingColumn = false;

                            ApplyArrayModifications(entry, arr => MultiDimArrayUtilities.MoveColumn(arr, context.ColumnDragFrom, context.ColumnDragTo));
                        }
                    }

                    if (context.IsDraggingColumn && Event.current.type == EventType.Repaint)
                    {
                        float mouseX = Event.current.mousePosition.x;
                        if (mouseX > rect.x - 1 && mouseX < rect.x + rect.width + 1)
                        {
                            Rect arrowRect;
                            if (mouseX > rect.x + rect.width * 0.5f)
                            {
                                arrowRect            = rect.AlignRight(16);
                                arrowRect.height     = 16;
                                arrowRect.y         -= 13;
                                arrowRect.x         += 8;
                                context.ColumnDragTo = columnIndex;
                            }
                            else
                            {
                                arrowRect            = rect.AlignLeft(16);
                                arrowRect.height     = 16;
                                arrowRect.y         -= 13;
                                arrowRect.x         -= 8;
                                context.ColumnDragTo = columnIndex - 1;
                            }

                            entry.Property.Tree.DelayActionUntilRepaint(() =>
                            {
                                //GL.sRGBWrite = QualitySettings.activeColorSpace == ColorSpace.Linear;
                                GUI.DrawTexture(arrowRect, EditorIcons.ArrowDown.Active);
                                //GL.sRGBWrite = false;

                                var lineRect   = arrowRect;
                                lineRect.x     = lineRect.center.x - 2 + 1;
                                lineRect.width = 3;
                                lineRect.y    += 14;
                                lineRect.yMax  = context.Table.TableRect.yMax;
                                EditorGUI.DrawRect(lineRect, new Color(0, 0, 0, 0.6f));
                            });
                        }

                        if (columnIndex == context.ColCount - 1)
                        {
                            entry.Property.Tree.DelayActionUntilRepaint(() =>
                            {
                                var cell     = context.Table[context.Table.ColumnCount - context.ColCount + context.ColumnDragFrom, context.Table.RowCount - 1];
                                var rowRect  = cell.Rect;
                                rowRect.yMin = rect.yMin;
                                SirenixEditorGUI.DrawSolidRect(rowRect, new Color(0, 0, 0, 0.2f));
                            });
                        }
                    }
                }
            }
            else
            {
                GUI.Label(rect, "-", EditorStyles.centeredGreyMiniLabel);
            }

            if (!context.Attribute.IsReadOnly && Event.current.type == EventType.MouseDown && Event.current.button == 1 && rect.Contains(Event.current.mousePosition))
            {
                Event.current.Use();
                GenericMenu menu = new GenericMenu();
                menu.AddItem(new GUIContent("Insert 1 left"), false, () => ApplyArrayModifications(entry, arr => MultiDimArrayUtilities.InsertOneColumnLeft(arr, columnIndex)));
                menu.AddItem(new GUIContent("Insert 1 right"), false, () => ApplyArrayModifications(entry, arr => MultiDimArrayUtilities.InsertOneColumnRight(arr, columnIndex)));
                menu.AddItem(new GUIContent("Duplicate"), false, () => ApplyArrayModifications(entry, arr => MultiDimArrayUtilities.DuplicateColumn(arr, columnIndex)));
                menu.AddSeparator("");
                menu.AddItem(new GUIContent("Delete"), false, () => ApplyArrayModifications(entry, arr => MultiDimArrayUtilities.DeleteColumn(arr, columnIndex)));
                menu.ShowAsContext();
            }
        }
예제 #41
0
    void BuildFileMenu()
    {
        _fileMenu = new GenericMenu();
        _fileMenu.AddItem(new GUIContent("New psai Soundtrack"), false, FileMenuCallback, "new");
        _fileMenu.AddItem(new GUIContent("Open psai Soundtrack"), false, FileMenuCallback, "open");
        if (EditorModel.Instance.ProjectDataChangedSinceLastSave)
        {
            _fileMenu.AddItem(new GUIContent("Save"), false, FileMenuCallback, "save");
        }
        else
        {
            _fileMenu.AddDisabledItem(new GUIContent("Save"));
        }

        if (EditorModel.Instance.Project != null)
        {
            _fileMenu.AddItem(new GUIContent("Save As"), false, FileMenuCallback, "saveas");
        }
        else
        {
            _fileMenu.AddDisabledItem(new GUIContent("Save As"));
        }

        _fileMenu.AddSeparator("");

        if (EditorModel.Instance.Project != null)
        {
            _fileMenu.AddItem(new GUIContent("Import Theme(s) from other psai Soundtrack"), false, FileMenuCallback, "import");
        }
        else
        {
            _fileMenu.AddDisabledItem(new GUIContent("Import Theme(s) from other psai Soundtrack"));
        }

        /*
        _fileMenu.AddSeparator("");
        if (EditorModel.Instance.Project != null && EditorModel.Instance.Project.Themes.Count > 0)
        {
            _fileMenu.AddItem(new GUIContent("Build Soundtrack"), false, FileMenuCallback, "export");
        }
        else
        {
            _fileMenu.AddDisabledItem(new GUIContent("Build Soundtrack"));
        }
         */
    }
예제 #42
0
 public void AddSeparator(string path = "")
 {
     m_Menu.AddSeparator(path);
 }
    void DrawToolStrip()
    {
        GUILayout.BeginHorizontal(EditorStyles.toolbar);

            /*
            if (GUILayout.Button("Refresh", EditorStyles.toolbarButton))
            {
                OnProjectChange();
            }
            */
            GUILayout.FlexibleSpace();

            bool _newShowHelp = GUILayout.Toggle(ShowHelp,"Help",EditorStyles.toolbarButton);
            if (_newShowHelp!=ShowHelp)
            {
                ShowHelp = _newShowHelp;
                EditorPrefs.SetInt(__namespace__+".ShowHelp",ShowHelp?1:0);
            }
            if (GUILayout.Button("Settings", EditorStyles.toolbarDropDown)) {
                GenericMenu toolsMenu = new GenericMenu();
                toolsMenu.AddItem(new GUIContent("Display Build Settings"),ShowBuildSettings, OnTools_ToggleShowBuildSettings);
              	toolsMenu.AddItem(new GUIContent("Discrete ToolBar"),DiscreteTooBar, OnTools_ToggleDiscreteTooBar);

                toolsMenu.AddSeparator("");

                toolsMenu.AddItem(new GUIContent("Help..."), false, OnTools_Help);

                // Offset menu from right of editor window
                toolsMenu.DropDown(new Rect(Screen.width-150, 0, 0, 16));
                EditorGUIUtility.ExitGUI();
            }

        GUILayout.EndHorizontal();
    }
    void OnGUI()
    {
        GUIStyle boldNumberFieldStyle = new GUIStyle(EditorStyles.numberField);

        boldNumberFieldStyle.font = EditorStyles.boldFont;

        GUIStyle boldToggleStyle = new GUIStyle(EditorStyles.toggle);

        boldToggleStyle.font = EditorStyles.boldFont;

        GUI.enabled = !waitTillPlistHasBeenWritten;

        //Toolbar
        EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
        {
            Rect optionsRect = GUILayoutUtility.GetRect(0, 20, GUILayout.ExpandWidth(false));

            if (GUILayout.Button(new GUIContent("Sort   " + (sortAscending ? "▼" : "▲"), "Change sorting to " + (sortAscending ? "descending" : "ascending")), EditorStyles.toolbarButton, GUILayout.ExpandWidth(false)))
            {
                OnChangeSortModeClicked();
            }

            if (GUILayout.Button(new GUIContent("Options", "Contains additional functionality like \"Add new entry\" and \"Delete all entries\" "), EditorStyles.toolbarDropDown, GUILayout.ExpandWidth(false)))
            {
                GenericMenu options = new GenericMenu();
                options.AddItem(new GUIContent("New Entry..."), false, OnNewEntryClicked);
                options.AddSeparator("");
                options.AddItem(new GUIContent("Import..."), false, OnImport);
                options.AddItem(new GUIContent("Export Selected..."), false, OnExportSelected);
                options.AddItem(new GUIContent("Export All Entries"), false, OnExportAllClicked);
                options.AddSeparator("");
                options.AddItem(new GUIContent("Delete Selected Entries"), false, OnDeleteSelectedClicked);
                options.AddItem(new GUIContent("Delete All Entries"), false, OnDeleteAllClicked);
                options.DropDown(optionsRect);
            }

            GUILayout.Space(5);

            //Searchfield
            Rect position = GUILayoutUtility.GetRect(50, 250, 10, 50, EditorStyles.toolbarTextField);
            position.width -= 16;
            position.x     += 16;
            SearchString    = GUI.TextField(position, SearchString, EditorStyles.toolbarTextField);

            position.x     = position.x - 18;
            position.width = 20;
            if (GUI.Button(position, "", ToolbarSeachTextFieldPopup))
            {
                GenericMenu options = new GenericMenu();
                options.AddItem(new GUIContent("All"), SearchFilter == SearchFilterType.All, OnSearchAllClicked);
                options.AddItem(new GUIContent("Key"), SearchFilter == SearchFilterType.Key, OnSearchKeyClicked);
                options.AddItem(new GUIContent("Value (Strings only)"), SearchFilter == SearchFilterType.Value, OnSearchValueClicked);
                options.DropDown(position);
            }

            position    = GUILayoutUtility.GetRect(10, 10, ToolbarSeachCancelButton);
            position.x -= 5;
            if (GUI.Button(position, "", ToolbarSeachCancelButton))
            {
                SearchString = string.Empty;
            }

            GUILayout.FlexibleSpace();

            if (Application.platform == RuntimePlatform.WindowsEditor)
            {
                string refreshTooltip = "Should all entries be automaticly refreshed every " + UpdateIntervalInSeconds + " seconds?";
                autoRefresh = GUILayout.Toggle(autoRefresh, new GUIContent("Auto Refresh ", refreshTooltip), EditorStyles.toolbarButton, GUILayout.ExpandWidth(false), GUILayout.MinWidth(75));
            }

            if (GUILayout.Button(new GUIContent(RefreshIcon, "Force a refresh, could take a few seconds."), EditorStyles.toolbarButton, GUILayout.ExpandWidth(false), GUILayout.ExpandHeight(false)))
            {
                if (Application.platform == RuntimePlatform.OSXEditor)
                {
                    waitTillPlistHasBeenWritten = IsUnityWritingToPlist();
                }

                RefreshKeys();
            }

            Rect r;
            if (Application.platform == RuntimePlatform.OSXEditor)
            {
                r = GUILayoutUtility.GetRect(16, 16);
            }
            else
            {
                r = GUILayoutUtility.GetRect(9, 16);
            }

            if (waitTillPlistHasBeenWritten)
            {
                Texture2D t = AssetDatabase.LoadAssetAtPath(IconsPath + "loader/" + (Mathf.FloorToInt(rotation % 12) + 1) + ".png", typeof(Texture2D)) as Texture2D;

                GUI.DrawTexture(new Rect(r.x + 3, r.y, 16, 16), t);
            }
        }
        EditorGUILayout.EndHorizontal();

        GUI.enabled = !waitTillPlistHasBeenWritten;

        //Show new entry box
        if (showNewEntryBox)
        {
            GUILayout.BeginHorizontal(GUI.skin.box);
            {
                GUILayout.BeginVertical(GUILayout.ExpandWidth(true));
                {
                    newKey = EditorGUILayout.TextField("Key", newKey);

                    switch (selectedType)
                    {
                    default:
                    case ValueType.String:
                        newValueString = EditorGUILayout.TextField("Value", newValueString);
                        break;

                    case ValueType.Float:
                        newValueFloat = EditorGUILayout.FloatField("Value", newValueFloat);
                        break;

                    case ValueType.Integer:
                        newValueInt = EditorGUILayout.IntField("Value", newValueInt);
                        break;
                    }

                    selectedType = (ValueType)EditorGUILayout.EnumPopup("Type", selectedType);
                }
                GUILayout.EndVertical();

                GUILayout.BeginVertical(GUILayout.Width(1));
                {
                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.FlexibleSpace();

                        if (GUILayout.Button(new GUIContent("X", "Close"), EditorStyles.boldLabel, GUILayout.ExpandWidth(false)))
                        {
                            showNewEntryBox = false;
                        }
                    }
                    GUILayout.EndHorizontal();

                    if (GUILayout.Button(new GUIContent(AddIcon, "Add a new key-value.")))
                    {
                        if (!string.IsNullOrEmpty(newKey))
                        {
                            switch (selectedType)
                            {
                            case ValueType.Integer:
                                PlayerPrefs.SetInt(newKey, newValueInt);
                                ppeList.Add(new PlayerPrefsEntry(newKey, newValueInt));
                                break;

                            case ValueType.Float:
                                PlayerPrefs.SetFloat(newKey, newValueFloat);
                                ppeList.Add(new PlayerPrefsEntry(newKey, newValueFloat));
                                break;

                            default:
                            case ValueType.String:
                                PlayerPrefs.SetString(newKey, newValueString);
                                ppeList.Add(new PlayerPrefsEntry(newKey, newValueString));
                                break;
                            }
                            PlayerPrefs.Save();
                            Sort();
                        }

                        newKey        = newValueString = "";
                        newValueInt   = 0;
                        newValueFloat = 0;
                        GUIUtility.keyboardControl = 0; //move focus from textfield, else the text won't be cleared
                        showNewEntryBox            = false;
                    }
                }
                GUILayout.EndVertical();
            }
            GUILayout.EndHorizontal();
        }

        GUILayout.Space(2);

        GUI.backgroundColor = Color.white;

        EditorGUI.indentLevel++;

        //Show all PlayerPrefs
        scrollPos = EditorGUILayout.BeginScrollView(scrollPos);
        {
            EditorGUILayout.BeginVertical();
            {
                for (int i = 0; i < filteredPpeList.Count; i++)
                {
                    if (filteredPpeList[i].Value != null)
                    {
                        EditorGUILayout.BeginHorizontal();
                        {
                            filteredPpeList[i].IsSelected = GUILayout.Toggle(filteredPpeList[i].IsSelected, new GUIContent("", "Toggle selection."), filteredPpeList[i].HasChanged ? boldToggleStyle : EditorStyles.toggle, GUILayout.MaxWidth(20), GUILayout.MinWidth(20), GUILayout.ExpandWidth(false));
                            filteredPpeList[i].Key        = EditorGUILayout.TextField(filteredPpeList[i].Key, filteredPpeList[i].HasChanged ? boldNumberFieldStyle : EditorStyles.numberField, GUILayout.MaxWidth(125), GUILayout.MinWidth(40), GUILayout.ExpandWidth(true));

                            GUIStyle numberFieldStyle = filteredPpeList[i].HasChanged ? boldNumberFieldStyle : EditorStyles.numberField;

                            switch (filteredPpeList[i].Type)
                            {
                            default:
                            case ValueType.String:
                                filteredPpeList[i].Value = EditorGUILayout.TextField("", (string)filteredPpeList[i].Value, numberFieldStyle, GUILayout.MinWidth(40));
                                break;

                            case ValueType.Float:
                                filteredPpeList[i].Value = EditorGUILayout.FloatField("", (float)filteredPpeList[i].Value, numberFieldStyle, GUILayout.MinWidth(40));
                                break;

                            case ValueType.Integer:
                                filteredPpeList[i].Value = EditorGUILayout.IntField("", (int)filteredPpeList[i].Value, numberFieldStyle, GUILayout.MinWidth(40));
                                break;
                            }

                            GUILayout.Label(new GUIContent("?", filteredPpeList[i].Type.ToString()), GUILayout.ExpandWidth(false));

                            GUI.enabled = filteredPpeList[i].HasChanged && !waitTillPlistHasBeenWritten;
                            if (GUILayout.Button(new GUIContent(SaveIcon, "Save changes made to this value."), GUILayout.ExpandWidth(false)))
                            {
                                filteredPpeList[i].SaveChanges();
                            }

                            if (GUILayout.Button(new GUIContent(UndoIcon, "Discard changes made to this value."), GUILayout.ExpandWidth(false)))
                            {
                                filteredPpeList[i].RevertChanges();
                            }

                            GUI.enabled = !waitTillPlistHasBeenWritten;

                            if (GUILayout.Button(new GUIContent(DeleteIcon, "Delete this key-value."), GUILayout.ExpandWidth(false)))
                            {
                                PlayerPrefs.DeleteKey(filteredPpeList[i].Key);
                                ppeList.Remove(filteredPpeList[i]);
                                PlayerPrefs.Save();

                                UpdateFilteredList();
                                break;
                            }
                        }
                        EditorGUILayout.EndHorizontal();
                    }
                }
            }
            EditorGUILayout.EndVertical();
        }
        EditorGUILayout.EndScrollView();

        EditorGUI.indentLevel--;
    }
    private void HandleAnchorContext(int controlID, JointHelpers.AnchorBias bias, AnchoredJoint2D joint,
        Joint2DSettingsBase joint2DSettings, Vector2 anchorPosition,
        Rigidbody2D connectedBody)
    {
        EditorHelpers.ContextClick(controlID, () => {
            var menu = new GenericMenu();
            menu.AddDisabledItem(new GUIContent(joint.GetType()
                                                     .Name));
            menu.AddSeparator("");
            if (WantsLocking()) {
                menu.AddItem(new GUIContent("Lock Anchors", GetAnchorLockTooltip()),
                    joint2DSettings.lockAnchors, () => {
                        EditorHelpers.RecordUndo(
                            joint2DSettings.lockAnchors ? "Unlock Anchors" : "Lock Anchors", joint2DSettings,
                            joint);
                        if (!joint2DSettings.lockAnchors) {
                            ReAlignAnchors(joint, bias);
                        }
                        joint2DSettings.lockAnchors = !joint2DSettings.lockAnchors;
                        EditorUtility.SetDirty(joint2DSettings);
                        EditorUtility.SetDirty(joint);
                    });
            }
            {
                var otherBias = JointHelpers.GetOppositeBias(bias);
                var otherPosition = JointHelpers.GetAnchorPosition(joint, otherBias);
                if (Vector2.Distance(otherPosition, anchorPosition) <= AnchorEpsilon) {
                    menu.AddDisabledItem(new GUIContent("Bring other anchor here"));
                } else {
                    menu.AddItem(new GUIContent("Bring other anchor here"), false, () => {
                        EditorHelpers.RecordUndo("Move Joint Anchor", joint);
                        JointHelpers.SetWorldAnchorPosition(joint, anchorPosition, otherBias);
                        EditorUtility.SetDirty(joint);
                    });
                }
            }

            menu.AddItem(new GUIContent("Enable Collision",
                "Should rigid bodies connected with this joint collide?"), joint.enableCollision,
                () => {
                    EditorHelpers.RecordUndo("Move Joint Anchor", joint);
                    joint.enableCollision = !joint.enableCollision;
                    EditorUtility.SetDirty(joint);
                });

            menu.AddSeparator("");

            var itemCount = menu.GetItemCount();

            ExtraMenuItems(menu, joint);

            if (itemCount != menu.GetItemCount()) {
                menu.AddSeparator("");
            }

            if (connectedBody) {
                var connectedBodyName = connectedBody.name;
                var selectConnectedBodyContent = new GUIContent(string.Format("Select '{0}'", connectedBodyName));
                if (isCreatedByTarget) {
                    menu.AddDisabledItem(selectConnectedBodyContent);
                } else {
                    menu.AddItem(selectConnectedBodyContent, false,
                        () => { Selection.activeGameObject = connectedBody.gameObject; });
                }
                menu.AddItem(new GUIContent(string.Format("Move ownership to '{0}'", connectedBodyName)), false, () => {
                    var connectedObject = connectedBody.gameObject;

                    var cloneJoint =
                        Undo.AddComponent(connectedObject, joint.GetType()) as AnchoredJoint2D;
                    if (!cloneJoint) {
                        return;
                    }
                    EditorUtility.CopySerialized(joint, cloneJoint);
                    cloneJoint.connectedBody = joint.GetComponent<Rigidbody2D>();

                    JointHelpers.SetWorldAnchorPosition(cloneJoint,
                        JointHelpers.GetAnchorPosition(joint, JointHelpers.AnchorBias.Main),
                        JointHelpers.AnchorBias.Connected);
                    JointHelpers.SetWorldAnchorPosition(cloneJoint,
                        JointHelpers.GetAnchorPosition(joint, JointHelpers.AnchorBias.Connected),
                        JointHelpers.AnchorBias.Main);

                    var jointSettings = SettingsHelper.GetOrCreate(joint);
                    var cloneSettings =
                        Undo.AddComponent(connectedObject, jointSettings.GetType()) as Joint2DSettingsBase;

                    if (cloneSettings == null) {
                        return;
                    }
                    cloneSettings.hideFlags = HideFlags.HideInInspector;

                    EditorUtility.CopySerialized(jointSettings, cloneSettings);
                    cloneSettings.Setup(cloneJoint);

                    cloneSettings.SetOffset(JointHelpers.AnchorBias.Main,
                        jointSettings.GetOffset(JointHelpers.AnchorBias.Connected));
                    cloneSettings.SetOffset(JointHelpers.AnchorBias.Connected,
                        jointSettings.GetOffset(JointHelpers.AnchorBias.Main));

                    if (!Selection.Contains(connectedObject)) {
                        var selectedObjects = new List<Object>(Selection.objects) {connectedObject};

                        if (selectedObjects.Contains(joint.gameObject)) {
                            selectedObjects.Remove(joint.gameObject);
                        }

                        Selection.objects = selectedObjects.ToArray();
                    }

                    Undo.DestroyObjectImmediate(joint);

                    OwnershipMoved(cloneJoint);
                });
                menu.AddItem(new GUIContent("Disconnect from '" + connectedBodyName + "'"), false, () => {
                    var worldConnectedPosition = JointHelpers.GetConnectedAnchorPosition(joint);

                    using (new Modification("Disconnect from connected body", joint)) {
                        joint.connectedBody = null;
                        JointHelpers.SetWorldConnectedAnchorPosition(joint, worldConnectedPosition);
                    }
                });
            } else {
                menu.AddDisabledItem(new GUIContent("Select connected body"));
                menu.AddDisabledItem(new GUIContent("Move ownership to connected body"));
                menu.AddDisabledItem(new GUIContent("Disconnect from connected body"));
            }

            menu.AddItem(new GUIContent("Delete " + joint.GetType()
                                                         .Name), false,
                () => Undo.DestroyObjectImmediate(joint));
            menu.ShowAsContext();
        });
    }
        private void OnSceneGUI()
        {
            if (EditorApplication.isPlayingOrWillChangePlaymode)
            {
                return;
            }
            // Don't process scene requests for Group Designer items when the ObjPathDesigner is enabled
            else if (lbGroupDesignerItem.lbGroupDesigner != null && lbGroupDesignerItem.lbGroupDesigner.isObjDesignerEnabled)
            {
                lbGroupDesignerItem.transform.position   = prevPosition;
                lbGroupDesignerItem.transform.rotation   = lbGroupDesignerItem.rotation;
                lbGroupDesignerItem.transform.localScale = lbGroupDesignerItem.scale;
                Selection.activeGameObject = null;
                return;
            }

            Event current = Event.current;

            //Debug.Log("DesignerItemEditor " + lbGroupDesignerItem.name);

            if (current != null)
            {
                // Get the group member. If we can't, and this isn't a SubGroup item, get out.
                if (lbGroupMember == null)
                {
                    lbGroupMember = lbGroupDesignerItem.lbGroupMember; if (lbGroupMember == null && !lbGroupDesignerItem.isSubGroup)
                    {
                        return;
                    }
                }

                bool isInSubGroup = !string.IsNullOrEmpty(lbGroupDesignerItem.SubGroupGUID);

                if (lbGroupDesignerItem.isObjPathMember || isInSubGroup)
                {
                    // If user attempts to move/rotate or scale an ObjPath member, SubGroup member, or a SubGroup, reset it
                    lbGroupDesignerItem.transform.position   = prevPosition;
                    lbGroupDesignerItem.transform.rotation   = lbGroupDesignerItem.rotation;
                    lbGroupDesignerItem.transform.localScale = lbGroupDesignerItem.scale;
                }
                else
                {
                    #region Check if Scale is overridden
                    // If Override is off, scaling is at the group level, not the member level, so don't allow scaling.
                    if (!lbGroupMember.isGroupOverride && Tools.current == Tool.Scale)
                    {
                        Tools.current = Tool.None;
                    }
                    #if UNITY_2017_3_OR_NEWER
                    else if (Tools.current == Tool.Scale || Tools.current == Tool.Transform)
                    #else
                    else if (Tools.current == Tool.Scale)
                    #endif
                    {
                        // If using Transform tool in U2017.3+, may need to reset scaling back to pre-scaled value.
                        if (!lbGroupMember.isGroupOverride)
                        {
                            lbGroupDesignerItem.transform.localScale = lbGroupDesignerItem.scale;
                        }
                        else
                        {
                            // Equally scale all axis
                            float   maxScale   = 0f;
                            Vector3 localScale = lbGroupDesignerItem.transform.localScale;

                            // Get the max scale amount of any of the axis
                            if (Mathf.Abs(localScale.x) > maxScale)
                            {
                                maxScale = localScale.x;
                            }
                            if (Mathf.Abs(localScale.y) > maxScale)
                            {
                                maxScale = localScale.y;
                            }
                            if (Mathf.Abs(localScale.z) > maxScale)
                            {
                                maxScale = localScale.z;
                            }

                            // Make each axis the same
                            localScale = maxScale * Vector3.one;

                            // Clamp scaling to between 0.1 and 10
                            if (localScale.x < 0.1f)
                            {
                                localScale = Vector3.one * 0.1f;
                            }
                            if (localScale.x > 10f)
                            {
                                localScale = Vector3.one * 10f;
                            }
                            lbGroupDesignerItem.transform.localScale = localScale;
                        }
                    }
                    #endregion

                    #region Lock Y rotation if randomise is enabled
                    #if UNITY_2017_3_OR_NEWER
                    if ((Tools.current == Tool.Rotate || Tools.current == Tool.Transform) && lbGroupMember.randomiseRotationY)
                    #else
                    if (Tools.current == Tool.Rotate && lbGroupMember.randomiseRotationY)
                    #endif
                    {
                        // Pivotmode of center can cause issues with some prefabs that aren't centred correctly.
                        // Prevent x,z movement of prefab when only y rotation change is attempted
                        if (Tools.pivotMode == PivotMode.Center)
                        {
                            Tools.pivotMode = PivotMode.Pivot;
                        }

                        lbGroupDesignerItem.transform.eulerAngles = new Vector3(lbGroupDesignerItem.transform.eulerAngles.x, lbGroupDesignerItem.rotation.eulerAngles.y, lbGroupDesignerItem.transform.eulerAngles.z);
                    }
                    #endregion

                    #region Clamp MinOffsetX,Z
                    #if UNITY_2017_3_OR_NEWER
                    if (Tools.current == Tool.Move || Tools.current == Tool.Transform)
                    #else
                    if (Tools.current == Tool.Move)
                    #endif
                    {
                        if (lbGroupMember.isPlacedInCentre)
                        {
                            if (lbGroup != null && lbGroupDesignerItem.lbGroupDesigner != null)
                            {
                                // If the user attempts to move it outside the clearing radius, lock the position to the last known position
                                Vector3 newPos           = lbGroupDesignerItem.transform.position;
                                float   distanceToCentre = Vector2.Distance(lbGroupDesignerItem.lbGroupDesigner.grpBasePlaneCentre2D, new Vector2(newPos.x, newPos.z));
                                if (distanceToCentre > lbGroup.maxClearingRadius)
                                {
                                    lbGroupDesignerItem.transform.position = prevPosition;
                                }
                            }
                        }
                        else if (!lbGroupMember.randomiseOffsetY)
                        {
                            // Don't allow movement on x,z axis for items that aren't offset from the Centre of the clearing AND don't use randomiseOffsetY.
                            lbGroupDesignerItem.transform.position = new Vector3(lbGroupDesignerItem.position.x, lbGroupDesignerItem.transform.position.y, lbGroupDesignerItem.position.z);
                        }
                        else
                        {
                            // Don't allow movement on any axis for items that aren't offset from the Centre of the clearing.
                            lbGroupDesignerItem.transform.position = lbGroupDesignerItem.position;
                        }

                        // Update last known position
                        prevPosition = lbGroupDesignerItem.transform.position;
                    }
                    #endregion
                }
                bool isLeftButton  = (current.button == 0);
                bool isRightButton = (current.button == 1);

                // ISSUE (ignore if vertex snapping is not enabled [v key held down]) current.keyCode != KeyCode.V

                // Record the starting positions
                if (!lbGroupDesignerItem.isObjPathMember && current.type == EventType.MouseDown && isLeftButton)
                {
                    Tools.hidden = false;
                    //Debug.Log("Left Btn Down");
                    lbGroupDesignerItem.position = lbGroupDesignerItem.transform.position;
                    lbGroupDesignerItem.rotation = lbGroupDesignerItem.transform.rotation;
                    lbGroupDesignerItem.scale    = lbGroupDesignerItem.transform.localScale;
                }
                else if (!lbGroupDesignerItem.isObjPathMember && !isInSubGroup && current.type == EventType.MouseUp && lbGroupMember != null && isLeftButton)
                {
                    #region Move
#if UNITY_2017_3_OR_NEWER
                    if (Tools.current == Tool.Move || Tools.current == Tool.Transform)
#else
                    if (Tools.current == Tool.Move)
#endif
                    {
                        if (lbGroupMember.isPlacedInCentre)
                        {
                            lbGroupMember.minOffsetX = lbGroupDesignerItem.transform.position.x;
                            lbGroupMember.minOffsetZ = lbGroupDesignerItem.transform.position.z;
                            if (!lbGroupMember.randomiseOffsetY)
                            {
                                lbGroupMember.minOffsetY = lbGroupDesignerItem.transform.position.y - lbGroupDesignerItem.lbGroupDesigner.BasePlaneOffsetY;
                            }
                        }
                        else if (!lbGroupMember.randomiseOffsetY)
                        {
                            lbGroupMember.minOffsetY = lbGroupDesignerItem.transform.position.y - lbGroupDesignerItem.lbGroupDesigner.BasePlaneOffsetY;
                            lbGroupMember.maxOffsetY = lbGroupMember.minOffsetY;

                            // Update all the instances of this member in the Designer
                            if (lbGroupDesignerItem.lbGroupDesigner != null)
                            {
                                lbGroupDesignerItem.lbGroupDesigner.UpdateGroupMember(lbGroupMember);
                            }
                        }
                    }
                    #endregion

                    #region Rotate
#if UNITY_2017_3_OR_NEWER
                    if (Tools.current == Tool.Rotate || Tools.current == Tool.Transform)
#else
                    if (Tools.current == Tool.Rotate)
#endif
                    {
                        Vector3 newRotation = lbGroupDesignerItem.transform.rotation.eulerAngles;

                        lbGroupMember.rotationX = newRotation.x;
                        lbGroupMember.rotationZ = newRotation.z;

                        if (!lbGroupMember.randomiseRotationY)
                        {
                            lbGroupMember.startRotationY = newRotation.y;
                            lbGroupMember.endRotationY   = newRotation.y;

                            if (!lbGroupMember.isPlacedInCentre && lbGroupDesignerItem.lbGroupDesigner != null)
                            {
                                // Update all the instances of this member in the Designer
                                lbGroupDesignerItem.lbGroupDesigner.UpdateGroupMember(lbGroupMember);
                            }
                        }
                    }
                    #endregion

                    #region Scale
#if UNITY_2017_3_OR_NEWER
                    if ((Tools.current == Tool.Scale || Tools.current == Tool.Transform) && lbGroupMember.isGroupOverride)
#else
                    if (Tools.current == Tool.Scale && lbGroupMember.isGroupOverride)
#endif
                    {
                        //Debug.Log("Scale start:" + lbGroupDesignerItem.scale + " mouseup:" +  lbGroupDesignerItem.transform.localScale);
                        lbGroupMember.minScale = lbGroupDesignerItem.transform.localScale.x;
                        lbGroupMember.maxScale = lbGroupMember.minScale;

                        if (!lbGroupMember.isPlacedInCentre && lbGroupDesignerItem.lbGroupDesigner != null)
                        {
                            // Update all the instances of this member in the Designer
                            lbGroupDesignerItem.lbGroupDesigner.UpdateGroupMember(lbGroupMember);
                        }
                    }
                    #endregion

                    // Update the LB Editor Windows
                    LBEditorHelper.RepaintEditorWindow(typeof(LandscapeBuilderWindow));

                    //Debug.Log("Prefab: " + this.name + " start pos:" + lbGroupDesignerItem.position + " end pos:" + lbGroupDesignerItem.transform.position);
                }

                //if (current.keyCode == KeyCode.V && current.type == EventType.KeyUp)
                //if (current.keyCode != KeyCode.V)
                //{
                //    //LBIntegration.ReflectionOutputFields(typeof(Tools), true, true);
                //    bool isVertexDragging = false;
                //    try
                //    {
                //        isVertexDragging = LBIntegration.ReflectionGetValue<bool>(typeof(Tools), "vertexDragging", null, true, true);
                //    }
                //    catch (System.Exception ex)
                //    {
                //        Debug.LogWarning("LBGroupDesignerItemEditor could not find VertexDragging - PLEASE REPORT " + ex.Message);
                //    }

                //    Debug.Log("Vertex Snapping enabled..." + Time.realtimeSinceStartup + " vertexDragging: " + isVertexDragging);
                //}


                #region Display the Context-sensitive menu
                else if (current.type == EventType.MouseDown && isRightButton)
                {
                    bool isCheckProximity = (lbGroupDesignerItem.lbGroupDesigner == null ? true : lbGroupDesignerItem.lbGroupDesigner.isCheckProximity);

                    GenericMenu menu = new GenericMenu();
                    menu.AddItem(new GUIContent("Close Designer"), false, CloseGroupDesigner);
                    menu.AddItem(new GUIContent("Refresh Designer"), false, () => RefreshDesigner(true));
                    menu.AddItem(new GUIContent("Check Proximity"), isCheckProximity, CheckProximity, !isCheckProximity);
                    menu.AddItem(new GUIContent("Auto Refresh"), lbGroupDesignerItem.lbGroupDesigner.GetAutoRefresh, () => { lbGroupDesignerItem.lbGroupDesigner.SetAutoRefresh(!lbGroupDesignerItem.lbGroupDesigner.GetAutoRefresh); });
                    // The following context menu items only apply to GroupMembers.
                    // Also exclude members in a subgroup within the Clearing Group
                    if (!lbGroupDesignerItem.isSubGroup && !isInSubGroup)
                    {
                        menu.AddSeparator("");
                        if (lbGroupDesignerItem.lbGroupDesigner.showZones)
                        {
                            menu.AddItem(new GUIContent("Add/"), false, () => { });
                            menu.AddItem(new GUIContent("Add/Zone under Object"), false, AddZoneToObject);
                        }
                        menu.AddItem(new GUIContent("Reset/"), false, () => { });
                        menu.AddItem(new GUIContent("Reset/Reset Rotation"), false, ResetRotation);
                        menu.AddItem(new GUIContent("Reset/Reset Position"), false, ResetPosition);
                        if (lbGroupMember.isGroupOverride)
                        {
                            menu.AddItem(new GUIContent("Reset/Reset Scale"), false, ResetScale);
                        }
                        menu.AddItem(new GUIContent("Snap/"), false, () => { });
                        menu.AddItem(new GUIContent("Snap/Pivot to Ground"), false, () => SnapToGround(false));
                        menu.AddItem(new GUIContent("Snap/Model to Ground"), false, () => SnapToGround(true));
                        if (!lbGroupDesignerItem.isObjPathMember)
                        {
                            menu.AddItem(new GUIContent("Place In Centre +offset"), lbGroupMember.isPlacedInCentre, TogglePlaceInCentre);
                        }
                        menu.AddItem(new GUIContent("Override Group"), lbGroupMember.isGroupOverride, ToggleOverrideGroupDefaults);
                        menu.AddItem(new GUIContent("Rotation/Face 2 Group Centre"), lbGroupMember.rotationType == LBGroupMember.LBRotationType.Face2GroupCentre, SetRotationType, LBGroupMember.LBRotationType.Face2GroupCentre);
                        menu.AddItem(new GUIContent("Rotation/Face 2 Zone Centre"), lbGroupMember.rotationType == LBGroupMember.LBRotationType.Face2ZoneCentre, SetRotationType, LBGroupMember.LBRotationType.Face2ZoneCentre);
                        menu.AddItem(new GUIContent("Rotation/Group Space"), lbGroupMember.rotationType == LBGroupMember.LBRotationType.GroupSpace, SetRotationType, "GroupSpace");
                        menu.AddItem(new GUIContent("Rotation/World Space"), lbGroupMember.rotationType == LBGroupMember.LBRotationType.WorldSpace, SetRotationType, "WorldSpace");
                        menu.AddItem(new GUIContent("Rotation/"), false, () => { });
                        menu.AddItem(new GUIContent("Rotation/Randomise Y"), lbGroupMember.randomiseRotationY, () =>
                        {
                            lbGroupMember.randomiseRotationY = !lbGroupMember.randomiseRotationY;
                            lbGroupMember.showtabInEditor    = (int)LBGroupMember.LBMemberEditorTab.XYZ;
                            LBEditorHelper.RepaintEditorWindow(typeof(LandscapeBuilderWindow));
                            lbGroupDesignerItem.lbGroupDesigner.UpdateGroupMember(lbGroupMember);
                        });
                    }

                    menu.AddSeparator("");

                    if (lbGroupDesignerItem.isObjPathMember && !isInSubGroup)
                    {
                        menu.AddItem(new GUIContent("Show Object Path"), false, () =>
                        {
                            if (!string.IsNullOrEmpty(lbGroupDesignerItem.objPathGroupMemberGUID) && lbGroupDesignerItem.lbGroupDesigner.lbGroup != null)
                            {
                                LBGroupMember objPathGroupMember = lbGroupDesignerItem.lbGroupDesigner.lbGroup.GetMemberByGUID(lbGroupDesignerItem.objPathGroupMemberGUID, false);
                                if (objPathGroupMember != null)
                                {
                                    lbGroupDesignerItem.lbGroupDesigner.lbGroup.GroupMemberListExpand(false);
                                    lbGroupDesignerItem.lbGroupDesigner.lbGroup.showGroupMembersInEditor = true;
                                    objPathGroupMember.showInEditor = true;
                                    LBEditorHelper.RepaintLBW();
                                }
                                ;
                            }
                            ;
                        });
                    }

                    menu.AddItem(new GUIContent("Zoom Out"), false, () => { lbGroupDesignerItem.lbGroupDesigner.ZoomExtent(SceneView.lastActiveSceneView); });
                    menu.AddItem(new GUIContent("Zoom In"), false, () => { lbGroupDesignerItem.lbGroupDesigner.ZoomIn(SceneView.lastActiveSceneView); });
                    menu.AddItem(new GUIContent("Display/Group Extent"), lbGroupDesignerItem.lbGroupDesigner.showGroupExtent, () => { lbGroupDesignerItem.lbGroupDesigner.showGroupExtent = !lbGroupDesignerItem.lbGroupDesigner.showGroupExtent; });
                    menu.AddItem(new GUIContent("Display/SubGroup Extents"), lbGroupDesignerItem.lbGroupDesigner.showSubGroupExtent, () => { lbGroupDesignerItem.lbGroupDesigner.showSubGroupExtent = !lbGroupDesignerItem.lbGroupDesigner.showSubGroupExtent; });
                    menu.AddItem(new GUIContent("Display/Member Extent Proximity"), lbGroupDesignerItem.lbGroupDesigner.showProximity, () =>
                    {
                        lbGroupDesignerItem.lbGroupDesigner.showProximity = !lbGroupDesignerItem.lbGroupDesigner.showProximity;
                        if (lbGroupDesignerItem.lbGroupDesigner.showProximity)
                        {
                            lbGroupMember.showtabInEditor = (int)LBGroupMember.LBMemberEditorTab.Proximity;
                        }
                        LBEditorHelper.RepaintEditorWindow(typeof(LandscapeBuilderWindow));
                    });
                    menu.AddItem(new GUIContent("Display/Member Tree Proximity"), lbGroupDesignerItem.lbGroupDesigner.showTreeProximity, () =>
                    {
                        lbGroupDesignerItem.lbGroupDesigner.showTreeProximity = !lbGroupDesignerItem.lbGroupDesigner.showTreeProximity;
                        if (lbGroupDesignerItem.lbGroupDesigner.showTreeProximity)
                        {
                            lbGroupMember.showtabInEditor = (int)LBGroupMember.LBMemberEditorTab.Proximity;
                        }
                        LBEditorHelper.RepaintEditorWindow(typeof(LandscapeBuilderWindow));
                    });
                    menu.AddItem(new GUIContent("Display/Member Flatten Area"), lbGroupDesignerItem.lbGroupDesigner.showFlattenArea, () =>
                    {
                        lbGroupDesignerItem.lbGroupDesigner.showFlattenArea = !lbGroupDesignerItem.lbGroupDesigner.showFlattenArea;
                        if (lbGroupDesignerItem.lbGroupDesigner.showFlattenArea)
                        {
                            lbGroupMember.showtabInEditor = (int)LBGroupMember.LBMemberEditorTab.General;
                        }
                        LBEditorHelper.RepaintEditorWindow(typeof(LandscapeBuilderWindow));
                    });
                    menu.AddItem(new GUIContent("Display/Zones"), lbGroupDesignerItem.lbGroupDesigner.showZones, () =>
                    {
                        lbGroupDesignerItem.lbGroupDesigner.showZones = !lbGroupDesignerItem.lbGroupDesigner.showZones;
                        if (lbGroupDesignerItem.lbGroupDesigner.showZones)
                        {
                            lbGroupMember.showtabInEditor = (int)LBGroupMember.LBMemberEditorTab.Zone;
                        }
                        LBEditorHelper.RepaintEditorWindow(typeof(LandscapeBuilderWindow));
                    });
                    // Cannot directly delete items:
                    // 1. in an Object Path
                    // 2. in a subgroup within the current Group
                    // 3. a whole subgroup within the current Group
                    if (!lbGroupDesignerItem.isObjPathMember && !isInSubGroup && !lbGroupDesignerItem.isSubGroup)
                    {
                        menu.AddSeparator("");
                        menu.AddItem(new GUIContent("Delete"), false, DeleteMember);
                    }
                    menu.AddSeparator("");
                    menu.AddItem(new GUIContent("Unselect"), false, () => { Selection.activeObject = null; });
                    // The Cancel option is not really necessary as use can just click anywhere else. However, it may help some users.
                    menu.AddItem(new GUIContent("Cancel"), false, () => { });
                    menu.ShowAsContext();
                    current.Use();
                }
                #endregion
            }
        }
예제 #47
0
    private void OnGUIToolbar()
    {
        GUILayout.BeginHorizontal(EditorStyles.toolbar);

        GUILayout.Label("");

        if (GUILayout.Button("Help", EditorStyles.toolbarButton, GUILayout.ExpandWidth(false)))
        {
            GenericMenu menu = new GenericMenu();
            menu.AddItem(new GUIContent("View Online Documentation"), false, OnViewDocs);
            menu.AddItem(new GUIContent("View API Reference"), false, OnViewAPI);
            menu.AddSeparator("");
            menu.AddItem(new GUIContent("Open Product Page"), false, OnProductPage);
            menu.AddItem(new GUIContent("Check Updates"), false, OnCheckUpdates);
            menu.AddItem(new GUIContent("Mail to Support"), false, OnSendMail);
            menu.ShowAsContext();
        }


        GUILayout.EndHorizontal();
    }
예제 #48
0
        private void CreateEditMenu(Rect position)
        {
            GenericMenu editMenu = new GenericMenu();

            editMenu.AddItem(new GUIContent("New Configuration"), false, HandleEditMenuOption, EditMenuOptions.NewInputConfiguration);
            if (_selectionPath.Count >= 1)
            {
                editMenu.AddItem(new GUIContent("New Axis"), false, HandleEditMenuOption, EditMenuOptions.NewAxisConfiguration);
            }
            else
            {
                editMenu.AddDisabledItem(new GUIContent("New Axis"));
            }
            editMenu.AddSeparator("");

            if (_selectionPath.Count > 0)
            {
                editMenu.AddItem(new GUIContent("Duplicate          Shift+D"), false, HandleEditMenuOption, EditMenuOptions.Duplicate);
            }
            else
            {
                editMenu.AddDisabledItem(new GUIContent("Duplicate          Shift+D"));
            }

            if (_selectionPath.Count > 0)
            {
                editMenu.AddItem(new GUIContent("Delete                Del"), false, HandleEditMenuOption, EditMenuOptions.Delete);
            }
            else
            {
                editMenu.AddDisabledItem(new GUIContent("Delete                Del"));
            }

            if (_inputManager.inputConfigurations.Count > 0)
            {
                editMenu.AddItem(new GUIContent("Delete All"), false, HandleEditMenuOption, EditMenuOptions.DeleteAll);
            }
            else
            {
                editMenu.AddDisabledItem(new GUIContent("Delete All"));
            }

            if (_selectionPath.Count >= 2)
            {
                editMenu.AddItem(new GUIContent("Copy"), false, HandleEditMenuOption, EditMenuOptions.Copy);
            }
            else
            {
                editMenu.AddDisabledItem(new GUIContent("Copy"));
            }

            if (_copySource != null && _selectionPath.Count >= 2)
            {
                editMenu.AddItem(new GUIContent("Paste"), false, HandleEditMenuOption, EditMenuOptions.Paste);
            }
            else
            {
                editMenu.AddDisabledItem(new GUIContent("Paste"));
            }

            editMenu.AddSeparator("");

            editMenu.AddItem(new GUIContent("Select Target"), false, HandleEditMenuOption, EditMenuOptions.SelectTarget);
            editMenu.AddItem(new GUIContent("Ignore Timescale"), _inputManager.ignoreTimescale, HandleEditMenuOption, EditMenuOptions.IgnoreTimescale);
            editMenu.AddItem(new GUIContent("Dont Destroy On Load"), _inputManager.dontDestroyOnLoad, HandleEditMenuOption, EditMenuOptions.DontDestroyOnLoad);
            editMenu.DropDown(position);
        }
    private void displayContextMenu()
    {
        var menu = new GenericMenu();

        var items = new List<ContextMenuItem>();
        FillContextMenu( items );

        var actionFunc = new System.Action<int>( ( command ) =>
        {
            var handler = items[ command ].Handler;
            handler();
        } );

        menu.AddDisabledItem( new GUIContent( string.Format( "{0} (GUI Manager)", target.name ) ) );
        menu.AddSeparator( "" );

        var options = items.Select( i => i.MenuText ).ToList();
        for( int i = 0; i < options.Count; i++ )
        {
            var index = i;
            if( options[ i ] == "-" )
                menu.AddSeparator( "" );
            else
                menu.AddItem( new GUIContent( options[ i ] ), false, () => { actionFunc( index ); } );
        }

        menu.ShowAsContext();
    }
예제 #50
0
    private void OnGUI()
    {
        switch (Event.current.type)
        {
            case EventType.KeyDown:
                if ((Event.current.modifiers & ~EventModifiers.FunctionKey) == EventModifiers.Control &&
                    (Event.current.keyCode == KeyCode.PageUp || Event.current.keyCode == KeyCode.PageDown))
                {
                    SelectAdjacentCodeTab(Event.current.keyCode == KeyCode.PageDown);
                    Event.current.Use();
                    GUIUtility.ExitGUI();
                }
                else if (Event.current.alt && EditorGUI.actionKey)
                {
                    if (Event.current.keyCode == KeyCode.RightArrow || Event.current.keyCode == KeyCode.LeftArrow)
                    {
                        if (Event.current.shift)
                        {
                            MoveThisTab(Event.current.keyCode == KeyCode.RightArrow);
                        }
                        else
                        {
                            SelectAdjacentCodeTab(Event.current.keyCode == KeyCode.RightArrow);
                        }
                        Event.current.Use();
                        GUIUtility.ExitGUI();
                    }
                }
                else if (!Event.current.alt && !Event.current.shift && EditorGUI.actionKey)
                {
                    if (Event.current.keyCode == KeyCode.W || Event.current.keyCode == KeyCode.F4)
                    {
                        Event.current.Use();
                        FGCodeWindow codeTab = GetAdjacentCodeTab(false);
                        if (codeTab == null)
                            codeTab = GetAdjacentCodeTab(true);
                        Close();
                        if (codeTab != null)
                            codeTab.Focus();
                    }
                }
                //else if (!Event.current.alt && !Event.current.shift && EditorGUI.actionKey)
                //{
                //	if (Event.current.keyCode == KeyCode.M)
                //	{
                //		Event.current.Use();
                //		ToggleMaximized();
                //		GUIUtility.ExitGUI();
                //	}
                //}
                break;

            case EventType.DragUpdated:
            case EventType.DragPerform:
                if (DragAndDrop.objectReferences.Length > 0)
                {
                    bool ask = false;

                    HashSet<Object> accepted = new HashSet<Object>();
                    foreach (Object obj in DragAndDrop.objectReferences)
                    {
                        if (AssetDatabase.GetAssetPath(obj).EndsWith(".dll", System.StringComparison.OrdinalIgnoreCase))
                            continue;

                        if (obj is MonoScript)
                            accepted.Add(obj);
                        else if (obj is TextAsset || obj is Shader)
                            accepted.Add(obj);
                        else if (obj is Material)
                        {
                            Material material = obj as Material;
                            if (material.shader != null)
                            {
                                int shaderID = material.shader.GetInstanceID();
                                if (shaderID != 0)
                                {
                                    if (!string.IsNullOrEmpty(AssetDatabase.GetAssetPath(shaderID)))
                                        accepted.Add(material.shader);
                                }
                            }
                        }
                        else if (obj is GameObject)
                        {
                            GameObject gameObject = obj as GameObject;
                            MonoBehaviour[] monoBehaviours = gameObject.GetComponents<MonoBehaviour>();
                            foreach (MonoBehaviour mb in monoBehaviours)
                            {
                                MonoScript monoScript = MonoScript.FromMonoBehaviour(mb);
                                if (monoScript != null)
                                {
                                    if (!string.IsNullOrEmpty(AssetDatabase.GetAssetPath(monoScript)))
                                    {
                                        accepted.Add(monoScript);
                                        ask = true;
                                    }
                                }
                            }
                        }
                    }

                    if (accepted.Count > 0)
                    {
                        DragAndDrop.AcceptDrag();
                        DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
                        if (Event.current.type == EventType.DragPerform)
                        {
                            Object[] sorted = accepted.OrderBy((x) => x.name, System.StringComparer.OrdinalIgnoreCase).ToArray();

                            if (ask && sorted.Length > 1)
                            {
                                GenericMenu popupMenu = new GenericMenu();
                                foreach (Object target in sorted)
                                {
                                    Object tempTarget = target;
                                    popupMenu.AddItem(
                                        new GUIContent("Open " + System.IO.Path.GetFileName(AssetDatabase.GetAssetPath(target))),
                                        false,
                                        () => { OpenNewWindow(tempTarget, this, true); });
                                }
                                popupMenu.AddSeparator("");
                                popupMenu.AddItem(
                                    new GUIContent("Open All"),
                                    false,
                                    () => { foreach (Object target in sorted) OpenNewWindow(target, this); });

                                popupMenu.ShowAsContext();
                            }
                            else
                            {
                                foreach (Object target in sorted)
                                    OpenNewWindow(target, this, sorted.Length == 1);
                            }
                        }
                        Event.current.Use();
                        return;
                    }
                }
                break;

            case EventType.ValidateCommand:
                if (Event.current.commandName == "ScriptInspector.AddTab")
                {
                    Event.current.Use();
                    return;
                }
                break;

            case EventType.ExecuteCommand:
                if (Event.current.commandName == "ScriptInspector.AddTab")
                {
                    Event.current.Use();
                    OpenNewWindow(targetAsset, this);
                    return;
                }
                break;
        }

        wantsMouseMove = true;
        textEditor.OnWindowGUI(this, new RectOffset(0, 0, 19, 1));
    }
    public override void OnInspectorGUI()
    {
        EditorGUILayout.PropertyField(tInterpolation,new GUIContent("Interpolation","Interpolation Method"));
        EditorGUILayout.PropertyField(tClosed,new GUIContent("Close Spline","Close spline?"));
        GUI.enabled = !tClosed.boolValue && tInterpolation.enumNames[tInterpolation.enumValueIndex]!="Linear";
        EditorGUILayout.PropertyField(tAutoEndTangents,new GUIContent("Auto End Tangents","Handle End Control Points automatically?"));
        GUI.enabled = true;
        EditorGUILayout.PropertyField(tGranularity, new GUIContent("Granularity", "Approximation resolution"));
        tGranularity.intValue = Mathf.Max(1, tGranularity.intValue);
        EditorGUILayout.LabelField("Orientation", EditorStyles.boldLabel);
        EditorGUILayout.PropertyField(tOrientation, new GUIContent("Orientation", "How the Up-Vector should be calculated"));
        if (tOrientation.enumNames[tOrientation.enumValueIndex] == "Tangent") {
            EditorGUILayout.PropertyField(tInitialUp, new GUIContent("Initial Up-Vector", "How the first Up-Vector should be determined"));
            EditorGUILayout.PropertyField(tSwirl, new GUIContent("Swirl", "Orientation swirl mode"));
            if (tSwirl.enumNames[tSwirl.enumValueIndex] != "None")
                EditorGUILayout.PropertyField(tSwirlTurns, new GUIContent("Turns", "Swirl turns"));
        }
        EditorGUILayout.LabelField("Updates", EditorStyles.boldLabel);
        EditorGUILayout.PropertyField(tAutoRefresh, new GUIContent("Auto Refresh", "Refresh when Control Point position change?"));
        EditorGUILayout.PropertyField(tAutoRefreshLength, new GUIContent("Auto Refresh Length", "Recalculate Length on Refresh?"));
        EditorGUILayout.PropertyField(tAutoRefreshOrientation, new GUIContent("Auto Refresh Orientation", "Recalculate tangent normals and Up-Vectors on Refresh?"));
        
        if (tInterpolation.enumNames[tInterpolation.enumValueIndex] == "TCB") {
            EditorGUILayout.LabelField("TCB", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(tT, new GUIContent("Tension", "Tension for TCB-Spline"));
            EditorGUILayout.PropertyField(tC, new GUIContent("Continuity", "Continuity for TCB-Spline"));
            EditorGUILayout.PropertyField(tB, new GUIContent("Bias", "Bias for TCB-Spline"));

            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button(new GUIContent("Set Catmul", "Set TCB to match Catmul Rom"))) {
                tT.floatValue = 0; tC.floatValue = 0; tB.floatValue = 0;
            }
            if (GUILayout.Button(new GUIContent("Set Cubic", "Set TCB to match Simple Cubic"))) {
                tT.floatValue = -1; tC.floatValue = 0; tB.floatValue = 0;
            }
            if (GUILayout.Button(new GUIContent("Set Linear", "Set TCB to match Linear"))) {
                tT.floatValue = 0; tC.floatValue = -1; tB.floatValue = 0;
            }
            EditorGUILayout.EndHorizontal();
        }
        EditorGUILayout.LabelField("Miscellaneous", EditorStyles.boldLabel);
        EditorGUILayout.PropertyField(tUserValueSize, new GUIContent("User Value Size", "Size of User Value array"));
        EditorGUILayout.PropertyField(tShowUserValues, new GUIContent("Show in scene", "Show values in the scene view"));
        EditorGUILayout.LabelField("Gizmos",EditorStyles.boldLabel);
        EditorGUILayout.PropertyField(tShowGizmos, new GUIContent("Show Gizmos", "Show Spline Gizmos"));
        EditorGUILayout.PropertyField(tShowApprox, new GUIContent("Show Approximation", "Show Approximation"));
        EditorGUILayout.PropertyField(tShowTangents, new GUIContent("Show Tangents", "Show Tangents"));
        EditorGUILayout.PropertyField(tShowOrientation, new GUIContent("Show Orientation", "Show Orientation"));

        if (serializedObject.targetObject && serializedObject.ApplyModifiedProperties()) {
            Target.Refresh(true,true,false);
            SceneView.RepaintAll();
        }
        
        EditorGUILayout.LabelField("Spline Info",EditorStyles.boldLabel);
            EditorGUILayout.LabelField("Total Length: " + Target.Length);
            EditorGUILayout.LabelField("Control Points: " + Target.ControlPointCount);
            EditorGUILayout.LabelField("Segments: " + Target.Count);
        
        EditorGUILayout.LabelField("Tools & Components", EditorStyles.boldLabel);
        GUILayout.BeginHorizontal();
            if (GUILayout.Button(new GUIContent(mTexAlignWizard,"Align wizard"),GUILayout.ExpandWidth(false)))
                CurvySplineAlignWizard.Create();
            if (GUILayout.Button(new GUIContent(mTexExportWizard,"Mesh Export wizard"),GUILayout.ExpandWidth(false)))
                CurvySplineExportWizard.Create();
            if (GUILayout.Button(new GUIContent(mTexCenterPivot,"Center Pivot"),GUILayout.ExpandWidth(false))){
                Undo.RegisterUndo(EditorUtility.CollectDeepHierarchy(new Object[]{Target}), "Center Spline Pivot");
                CurvyUtility.centerPivot(Target);
            }
            GUILayout.Space(10);
            if (GUILayout.Button(new GUIContent(mTexClonePath, "Create Clone Path"), GUILayout.ExpandWidth(false)))
                CurvySplinePathCloneBuilderInspector.CreateCloneBuilder();
            if (GUILayout.Button(new GUIContent(mTexMeshPath, "Create Mesh Path"), GUILayout.ExpandWidth(false)))
                CurvySplinePathMeshBuilderInspector.CreateMeshBuilder();
        GUILayout.EndHorizontal();
        EditorGUILayout.LabelField("General", EditorStyles.boldLabel);
        GUILayout.BeginHorizontal();


        if (GUILayout.Button(new GUIContent(mTexPrefs, "Preferences"), GUILayout.ExpandWidth(false)))
            CurvyPreferences.Open();
        
        if (GUILayout.Button(new GUIContent(mTexHelp, "Help"), GUILayout.ExpandWidth(false))) {
            var mnu = new GenericMenu();
            mnu.AddItem(new GUIContent("Online Manual"), false, new GenericMenu.MenuFunction(OnShowManual));
            mnu.AddItem(new GUIContent("Website"), false, new GenericMenu.MenuFunction(OnShowWeb));
            mnu.AddSeparator("");
            mnu.AddItem(new GUIContent("Report a bug"), false, new GenericMenu.MenuFunction(OnBugReport));
            mnu.ShowAsContext();
        }
        
        GUILayout.EndHorizontal();

        Repaint();   
    }
예제 #52
0
		public override void OnFlowCreateMenuGUI(string prefix, GenericMenu menu) {

			if (this.InstallationNeeded() == false) {

				if (Social.settings != null) {

					menu.AddSeparator(prefix);

					menu.AddItem(new GUIContent(prefix + "Social"), on: false, func: () => {

						this.flowEditor.CreateNewItem(() => {

							var window = FlowSystem.CreateWindow(FD.FlowWindow.Flags.IsSmall | FD.FlowWindow.Flags.CantCompiled | Social.settings.uniqueTag);
							window.smallStyleDefault = "flow node 1";
							window.smallStyleSelected = "flow node 1 on";
							window.title = "Social";
							
							window.rect.width = 150f;
							window.rect.height = 100f;

							return window;

						});

					});

				}

			}

		}
예제 #53
0
	void Selector(SerializedProperty property) {
		SkeletonData data = skeletonDataAsset.GetSkeletonData(true);

		if (data == null)
			return;

		SpineAttachment attrib = (SpineAttachment)attribute;

		List<Skin> validSkins = new List<Skin>();

		if (skeletonRenderer != null && attrib.currentSkinOnly) {
			if (skeletonRenderer.skeleton.Skin != null) {
				validSkins.Add(skeletonRenderer.skeleton.Skin);
			} else {
				validSkins.Add(data.Skins.Items[0]);
			}
		} else {
			foreach (Skin skin in data.Skins) {
				if (skin != null)
					validSkins.Add(skin);
			}
		}

		GenericMenu menu = new GenericMenu();
		List<string> attachmentNames = new List<string>();
		List<string> placeholderNames = new List<string>();

		string prefix = "";

		if (skeletonRenderer != null && attrib.currentSkinOnly)
			menu.AddDisabledItem(new GUIContent(skeletonRenderer.gameObject.name + " (SkeletonRenderer)"));
		else
			menu.AddDisabledItem(new GUIContent(skeletonDataAsset.name));
		menu.AddSeparator("");

		menu.AddItem(new GUIContent("Null"), property.stringValue == "", HandleSelect, new SpineDrawerValuePair("", property));
		menu.AddSeparator("");

		Skin defaultSkin = data.Skins.Items[0];

		SerializedProperty slotProperty = property.serializedObject.FindProperty(attrib.slotField);
		string slotMatch = "";
		if (slotProperty != null) {
			if (slotProperty.propertyType == SerializedPropertyType.String) {
				slotMatch = slotProperty.stringValue.ToLower();
			}
		}

		foreach (Skin skin in validSkins) {
			string skinPrefix = skin.Name + "/";

			if (validSkins.Count > 1)
				prefix = skinPrefix;

			for (int i = 0; i < data.Slots.Count; i++) {
				if (slotMatch.Length > 0 && data.Slots.Items[i].Name.ToLower().Contains(slotMatch) == false)
					continue;

				attachmentNames.Clear();
				placeholderNames.Clear();

				skin.FindNamesForSlot(i, attachmentNames);
				if (skin != defaultSkin) {
					defaultSkin.FindNamesForSlot(i, attachmentNames);
					skin.FindNamesForSlot(i, placeholderNames);
				}
					

				for (int a = 0; a < attachmentNames.Count; a++) {
					
					string attachmentPath = attachmentNames[a];
					string menuPath = prefix + data.Slots.Items[i].Name + "/" + attachmentPath;
					string name = attachmentNames[a];

					if (attrib.returnAttachmentPath)
						name = skin.Name + "/" + data.Slots.Items[i].Name + "/" + attachmentPath;

					if (attrib.placeholdersOnly && placeholderNames.Contains(attachmentPath) == false) {
						menu.AddDisabledItem(new GUIContent(menuPath));
					} else {
						menu.AddItem(new GUIContent(menuPath), name == property.stringValue, HandleSelect, new SpineDrawerValuePair(name, property));
					}
					
					
				}
			}
		}


		menu.ShowAsContext();
	}
예제 #54
0
파일: ReactEditor.cs 프로젝트: s76/testAI
    void OnGUIHasBeenDrawn()
    {
        if (BaseNode.hotNode == null)
            return;
        if (BaseNode.hotNode.activateContext) {
            // Now create the menu, add items and show it
            var menu = new GenericMenu ();
            var isParent = BaseNode.hotNode.IsParent ();
            var sequenceTypes = (from i in nodeTypes orderby i.Name where i.BaseType == typeof(React.BranchNode) select i).ToArray ();
            foreach (var t in sequenceTypes) {
                if (isParent)
                    menu.AddItem (new GUIContent ("Add/Branch/" + t.Name), false, AddToHotNode, t);
                menu.AddItem (new GUIContent ("Convert/Branch/" + t.Name), false, ConvertHotNode, t);
            }

            var leafTypes = (from i in nodeTypes orderby i.Name where i.BaseType == typeof(React.LeafNode) select i).ToArray ();
            foreach (var t in leafTypes) {
                if (isParent)
                    menu.AddItem (new GUIContent ("Add/Leaf/" + t.Name), false, AddToHotNode, t);
                menu.AddItem (new GUIContent ("Convert/Leaf/" + t.Name), false, ConvertHotNode, t);
            }

            var decoratorTypes = (from i in nodeTypes orderby i.Name where i.BaseType == typeof(React.DecoratorNode) select i).ToArray ();
            foreach (var t in decoratorTypes) {
                if (isParent)
                    menu.AddItem (new GUIContent ("Add/Decorator/" + t.Name), false, AddToHotNode, t);
                menu.AddItem (new GUIContent ("Convert/Decorator/" + t.Name), false, ConvertHotNode, t);
                menu.AddItem (new GUIContent ("Decorate/" + t.Name), false, DecorateHotNode, t);
            }

            menu.AddSeparator ("");
            Action hotNodeAction = BaseNode.hotNode as Action;
            if (hotNodeAction != null)
            {
                Dictionary< string, List< string > > actionsMap = BaseNode.editorReactable.CollectActionsMap();

                foreach (KeyValuePair<string, List<string> > kvp in actionsMap)
                {
                    foreach (string method in kvp.Value )
                    {
                        menu.AddItem(new GUIContent("Set Action/" + kvp.Key + "/" + method), false, SetActionMethod, new KeyValuePair<string, string>( kvp.Key, method ) );
                    }
                }
            }

            Condition hotNodeCondition = BaseNode.hotNode as Condition;
            If hotNodeIf = BaseNode.hotNode as If;
            if (hotNodeCondition != null || hotNodeIf != null )
            {
                Dictionary< string, List< string > > actionsMap = BaseNode.editorReactable.CollectConditionsMap();

                foreach (KeyValuePair<string, List<string> > kvp in actionsMap)
                {
                    foreach (string method in kvp.Value )
                    {
                        menu.AddItem(new GUIContent("Set Condition/" + kvp.Key + "/" + method), false, SetConditionMethod, new KeyValuePair<string, string>(kvp.Key, method));
                    }
                }
            }

            menu.AddSeparator("");

            menu.AddItem (new GUIContent ("Cut"), false, OnCut);
            menu.AddItem (new GUIContent ("Copy"), false, OnCopy);
            if (isParent)
                menu.AddItem (new GUIContent ("Paste"), false, OnPaste);
            else
                menu.AddDisabledItem (new GUIContent ("Paste"));
            menu.AddItem (new GUIContent ("Duplicate"), false, OnDuplicate);
            menu.AddItem (new GUIContent ("Delete"), false, OnDelete);

            if (BaseNode.hotNode.HasAnyChildren())
            {
                if (BaseNode.hotNode.hideChildren)
                {
                    menu.AddItem(new GUIContent("Show"), false, OnShowChildren );
                }
                else
                {
                    menu.AddItem(new GUIContent("Hide"), false, OnHideChildren );
                }
            }

            menu.ShowAsContext ();
        }
    }
예제 #55
0
    void buildAddTrackMenu_Drag()
    {
        bool hasTransform = true;
        bool hasAnimation = true;
        bool hasAudioSource = true;
        bool hasCamera = true;

        foreach(GameObject g in objects_window) {
            // break loop when all variables are false
            if(!hasTransform && !hasAnimation && !hasAudioSource && !hasCamera) break;

            if(hasTransform && !g.GetComponent(typeof(Transform))) {
                hasTransform = false;
            }
            if(hasAnimation && !g.GetComponent(typeof(Animation))) {
                hasAnimation = false;
            }
            if(hasAudioSource && !g.GetComponent(typeof(AudioSource))) {
                hasAudioSource = false;
            }
            if(hasCamera && !g.GetComponent(typeof(Camera))) {
                hasCamera = false;
            }
        }
        // add track menu
        menu_drag = new GenericMenu();

        // Translation
        if(hasTransform) { menu_drag.AddItem(new GUIContent("Translation"), false, addTrackFromMenu, (int)Track.Translation); }
        else { menu_drag.AddDisabledItem(new GUIContent("Translation")); }
        // Rotation
        if(hasTransform) { menu_drag.AddItem(new GUIContent("Rotation"), false, addTrackFromMenu, (int)Track.Rotation); }
        else { menu_drag.AddDisabledItem(new GUIContent("Rotation")); }
        // Orientation
        if(hasTransform) menu_drag.AddItem(new GUIContent("Orientation"), false, addTrackFromMenu, (int)Track.Orientation);
        else menu_drag.AddDisabledItem(new GUIContent("Orientation"));
        // Animation
        if(hasAnimation) menu_drag.AddItem(new GUIContent("Animation"), false, addTrackFromMenu, (int)Track.Animation);
        else menu_drag.AddDisabledItem(new GUIContent("Animation"));
        // Audio
        if(hasAudioSource) menu_drag.AddItem(new GUIContent("Audio"), false, addTrackFromMenu, (int)Track.Audio);
        else menu_drag.AddDisabledItem(new GUIContent("Audio"));
        // Property
        menu_drag.AddItem(new GUIContent("Property"), false, addTrackFromMenu, (int)Track.Property);
        // Event
        menu_drag.AddItem(new GUIContent("Event"), false, addTrackFromMenu, (int)Track.Event);
        // GO Active
        menu_drag.AddItem(new GUIContent("GO Active"), false, addTrackFromMenu, (int)Track.GOSetActive);

        if(oData.quickAdd_Combos.Count > 0) {
            // multiple tracks
            menu_drag.AddSeparator("");
            foreach(List<int> combo in oData.quickAdd_Combos) {
                string combo_name = "";
                for(int i = 0; i < combo.Count; i++) {
                    //combo_name += Enum.GetName(typeof(Track),combo[i])+" ";
                    combo_name += TrackNames[combo[i]] + " ";
                    if(i < combo.Count - 1) combo_name += "+ ";
                }
                if(canQuickAddCombo(combo, hasTransform, hasAnimation, hasAudioSource, hasCamera)) menu_drag.AddItem(new GUIContent(combo_name), false, addTrackFromMenu, 100 + oData.quickAdd_Combos.IndexOf(combo));
                else menu_drag.AddDisabledItem(new GUIContent(combo_name));
            }
        }
    }
    private static void ShowPopup(Event evt, UTNodeEditorModel model)
    {
        var menu = new GenericMenu ();
        if (!model.HasPlan) {
            menu.AddDisabledItem (new GUIContent ("Please select an automation plan."));
            menu.ShowAsContext ();
            return;
        }

        var hotNode = GetNodeUnderMouse (model, evt.mousePosition);
        var hotConnector = GetConnectorUnderMouse (model, evt.mousePosition);
        var data = new NodeEventData (evt, model, hotConnector);
        if (hotNode == null && hotConnector == null) {
        #if UTOMATE_DEMO
            if (!model.CanAddEntriesToPlan) {
                menu.AddDisabledItem (new GUIContent ("You cannot add any more entries in the demo version."));
            }
            else {
        #endif
            menu.AddItem (new GUIContent ("Add Action Entry"), false, AddActionNode, data);
            menu.AddItem (new GUIContent ("Add Decision Entry"), false, AddDecisionNode, data);
            menu.AddItem (new GUIContent ("Add For-Each Entry"), false, AddForEachNode, data);
            menu.AddItem (new GUIContent ("Add For-Each File Entry"), false, AddForEachFileNode, data);
            menu.AddItem (new GUIContent ("Add Sub-Plan Entry"), false, AddPlanNode, data);
            menu.AddItem (new GUIContent ("Add Note"), false, AddNote, data);

        #if UTOMATE_DEMO
            }
        #endif
        }

        if (hotNode != null) {
            if (!model.SelectedNodes.Contains (hotNode)) {
                model.SelectNode (hotNode, UTNodeEditorModel.SelectionMode.Replace);
            }

            if (menu.GetItemCount () > 0) {
                menu.AddSeparator ("");
            }

            var isMultiSelection = model.SelectedNodes.Count > 1;

            if (!model.IsFirstNode (hotNode) && !isMultiSelection) {
                menu.AddItem (new GUIContent ("Set As First Entry"), false, SetAsFirstNode, data);
            }
            menu.AddItem (new GUIContent (isMultiSelection ? "Delete Entries" : "Delete Entry"), false, DeleteNode, data);
        }

        if (hotConnector != null && hotConnector.isConnected) {
            if (menu.GetItemCount () > 0) {
                menu.AddSeparator ("");
            }
            menu.AddItem (new GUIContent ("Delete Connection"), false, DeleteConnection, data);
        }
        menu.ShowAsContext ();
    }
	void SpawnHierarchyContextMenu () {
		GenericMenu menu = new GenericMenu();

		menu.AddItem(new GUIContent("Follow"), false, SpawnFollowHierarchy);
		menu.AddItem(new GUIContent("Follow (Root Only)"), false, SpawnFollowHierarchyRootOnly);
		menu.AddSeparator("");
		menu.AddItem(new GUIContent("Override"), false, SpawnOverrideHierarchy);
		menu.AddItem(new GUIContent("Override (Root Only)"), false, SpawnOverrideHierarchyRootOnly);

		menu.ShowAsContext();
	}
예제 #58
0
 void buildContextMenu(int frame)
 {
     contextMenuFrame = frame;
     contextMenu = new GenericMenu();
     bool selectionHasKeys = aData.getCurrentTake().contextSelectionTracks.Count > 1 || aData.getCurrentTake().contextSelectionHasKeys();
     bool copyBufferNotEmpty = (contextSelectionKeysBuffer.Count > 0);
     bool canPaste = false;
     bool singleTrack = contextSelectionKeysBuffer.Count == 1;
     AMTrack selectedTrack = aData.getCurrentTake().getSelectedTrack();
     if(copyBufferNotEmpty) {
         if(singleTrack) {
             // if origin is property track
             if(selectedTrack is AMPropertyTrack) {
                 // if pasting into property track
                 if(contextSelectionTracksBuffer[0] is AMPropertyTrack) {
                     // if property tracks have the same property
                     if((selectedTrack as AMPropertyTrack).hasSamePropertyAs((contextSelectionTracksBuffer[0] as AMPropertyTrack))) {
                         canPaste = true;
                     }
                 }
                 // if origin is event track
             }
             else if(selectedTrack is AMEventTrack) {
                 // if pasting into event track
                 if(contextSelectionTracksBuffer[0] is AMEventTrack) {
                     // if event tracks are compaitable
                     if((selectedTrack as AMEventTrack).hasSameEventsAs((contextSelectionTracksBuffer[0] as AMEventTrack))) {
                         canPaste = true;
                     }
                 }
             }
             else {
                 if(selectedTrack.getTrackType() == contextSelectionTracksBuffer[0].getTrackType()) {
                     canPaste = true;
                 }
             }
         }
         else {
             // to do
             if(contextSelectionTracksBuffer.Contains(selectedTrack)) canPaste = true;
         }
     }
     contextMenu.AddItem(new GUIContent("Insert Keyframe"), false, invokeContextMenuItem, 0);
     contextMenu.AddSeparator("");
     if(selectionHasKeys) {
         contextMenu.AddItem(new GUIContent("Cut Frames"), false, invokeContextMenuItem, 1);
         contextMenu.AddItem(new GUIContent("Copy Frames"), false, invokeContextMenuItem, 2);
         if(canPaste) contextMenu.AddItem(new GUIContent("Paste Frames"), false, invokeContextMenuItem, 3);
         else contextMenu.AddDisabledItem(new GUIContent("Paste Frames"));
         contextMenu.AddItem(new GUIContent("Clear Frames"), false, invokeContextMenuItem, 4);
     }
     else {
         contextMenu.AddDisabledItem(new GUIContent("Cut Frames"));
         contextMenu.AddDisabledItem(new GUIContent("Copy Frames"));
         if(canPaste) contextMenu.AddItem(new GUIContent("Paste Frames"), false, invokeContextMenuItem, 3);
         else contextMenu.AddDisabledItem(new GUIContent("Paste Frames"));
         contextMenu.AddDisabledItem(new GUIContent("Clear Frames"));
     }
     contextMenu.AddItem(new GUIContent("Select All Frames"), false, invokeContextMenuItem, 5);
 }
예제 #59
0
    private void DrawToolbarGUI()
    {
        GUILayout.BeginHorizontal(EditorStyles.toolbar);

        if (OnlineMapsUpdater.hasNewVersion && updateAvailableContent != null)
        {
            Color defBackgroundColor = GUI.backgroundColor;
            GUI.backgroundColor = new Color(1, 0.5f, 0.5f);
            if (GUILayout.Button(updateAvailableContent, EditorStyles.toolbarButton))
            {
                OnlineMapsUpdater.OpenWindow();
            }
            GUI.backgroundColor = defBackgroundColor;
        }
        else GUILayout.Label("");

        if (GUILayout.Button("Help", EditorStyles.toolbarButton, GUILayout.ExpandWidth(false)))
        {
            GenericMenu menu = new GenericMenu();
            menu.AddItem(new GUIContent("Documentation"), false, OnViewDocs);
            menu.AddItem(new GUIContent("API Reference"), false, OnViewAPI);
            menu.AddItem(new GUIContent("Atlas of Examples"), false, OnViewAtlas);
            menu.AddSeparator("");
            menu.AddItem(new GUIContent("Product Page"), false, OnProductPage);
            menu.AddItem(new GUIContent("Forum"), false, OnViewForum);
            menu.AddItem(new GUIContent("Check Updates"), false, OnCheckUpdates);
            menu.AddItem(new GUIContent("Support"), false, OnSendMail);
            menu.AddSeparator("");
            menu.AddItem(new GUIContent("About"), false, OnAbout);
            menu.ShowAsContext();
        }

        GUILayout.EndHorizontal();
    }
예제 #60
0
        void DrawSceneButton(EditorBuildSettingsScene scene, bool isActiveScene, Color defColor, out bool nowClicked)
        {
            nowClicked = false;

            #region get sceneName(path)
            string sceneName = "";
            switch (viewOption)
            {
            case 0:     //Show full path (remove "ASSETS/")
                sceneName = scene.path.Remove(0, 7);
                break;

            case 1:     //Show only scene name
                sceneName = System.IO.Path.GetFileName(scene.path);
                break;
            }
            #endregion

            #region draw scene text
            bool isNowSelectedScene = (selectedSceneIndex == nowSceneIndex);

            GUIContent sceneText     = new GUIContent(sceneName);
            Rect       sceneTextRect = GUILayoutUtility.GetRect(sceneText, sceneTextStyle);

            //Draw background when selected
            if (isNowSelectedScene)
            {
                if (focusedWindow == this)
                {
                    GUI.color = EditorGUIUtility.isProSkin ? (scene.enabled ? proSelectBackground : proDisableSelectBackground) :
                                (scene.enabled ? stdSelectBackground : stdDisableSelectBackground);
                }
                else
                {
                    GUI.color = EditorGUIUtility.isProSkin ? (scene.enabled ? proLostFocusSelectBackground : proLostFocusDisableSelectBackground) :
                                (scene.enabled ? stdLostFocusSelectBackground : stdLostFocusDisableSelectBackground);
                }
                GUI.DrawTexture(sceneTextRect, EditorGUIUtility.whiteTexture);
            }

            GUI.color = scene.enabled ? (EditorGUIUtility.isProSkin ? proTextColor : (isNowSelectedScene ? stdSelectTextColor : stdTextColor)) :
                        (EditorGUIUtility.isProSkin ? proDisableTextColor : (isNowSelectedScene ? stdSelectDisableTextColor : stdDisableTextColor));

            GUIStyle nowSceneTextStyle = isNowSelectedScene ? sceneSelectedTextStyle : sceneTextStyle;
            nowSceneTextStyle.fontStyle = isActiveScene ? FontStyle.Bold : FontStyle.Normal;

            GUI.Label(sceneTextRect, sceneText, nowSceneTextStyle);
            #endregion

            #region when click
            Event e = Event.current;
            if (sceneTextRect.Contains(e.mousePosition))
            {
                if (e.type == EventType.MouseDown)
                {
                    nowClicked         = true;
                    selectedSceneIndex = nowSceneIndex;
                }
                else if (e.type == EventType.MouseUp)
                {
                    if (e.button == 0)
                    {
                        if (lastClickedScene == nowSceneIndex && Time.realtimeSinceStartup - lastClickTime <= DoubleClickDelay)
                        {
                            SceneMenuCallback(new object[] { scene, SceneMenuType.Open });
                        }
                        else
                        {
                            lastClickedScene = nowSceneIndex;
                            lastClickTime    = Time.realtimeSinceStartup;
                        }
                    }
                    else if (e.button == 1)
                    {
                        GenericMenu menu = new GenericMenu();
                        menu.AddItem(new GUIContent("Show in Project"), false, SceneMenuCallback, new object[] { scene, SceneMenuType.ShowInProject });
                        menu.AddItem(new GUIContent("Show in Explorer"), false, SceneMenuCallback, new object[] { scene, SceneMenuType.ShowInExplorer });
                        menu.AddSeparator("");
                        menu.AddItem(new GUIContent("Open"), false, SceneMenuCallback, new object[] { scene, SceneMenuType.Open });
                        menu.AddItem(new GUIContent("Open Scene Addtive"), false, SceneMenuCallback, new object[] { scene, SceneMenuType.ShowInAddtive });
                        menu.ShowAsContext();
                    }
                }
            }
            #endregion
            nowSceneIndex++;
            GUI.color = defColor;
        }