RefreshMapMagic() public static method

public static RefreshMapMagic ( ) : void
return void
示例#1
0
		private void DragDrawAddRemove ()
		{
			int origButtonSize = 34; int origButtonOffset = 20;

			Vector2 buttonPos = new Vector2(
				UI.current.editorWindow.position.width - (origButtonSize + origButtonOffset)*UI.current.DpiScaleFactor,
				20*UI.current.DpiScaleFactor);
			Vector2 buttonSize = new Vector2(origButtonSize,origButtonSize) * UI.current.DpiScaleFactor;

			using (Cell.Custom(buttonPos,buttonSize))
			//later button pos could be overriden if dragging it
			{
				Cell.current.MakeStatic();


				//if dragging generator
				if (DragDrop.IsDragging()  &&  !DragDrop.IsStarted()  &&  DragDrop.obj is Cell  &&  UI.current.cellObjs.TryGetObject((Cell)DragDrop.obj, "Generator", out Generator draggedGen) )
				
				{
					if (Cell.current.Contains(UI.current.mousePos))
						Draw.Texture(UI.current.textures.GetTexture("MapMagic/Icons/NodeRemoveActive"));
					else
						Draw.Texture(UI.current.textures.GetTexture("MapMagic/Icons/NodeRemove"));
				}


				//if released generator on remove icon
				else if (DragDrop.IsReleased()  &&  
					DragDrop.releasedObj is Cell  &&  
					UI.current.cellObjs.TryGetObject((Cell)DragDrop.releasedObj, "Generator", out Generator releasedGen)  &&  
					Cell.current.Contains(UI.current.mousePos))
				{
					GraphEditorActions.RemoveGenerator(graph, releasedGen, selected); 
					GraphWindow.RefreshMapMagic();
				}


				//if not dragging generator
				else
				{
					if (focusedWindow==this) drawAddRemoveButton = true;   //re-enabling when window is focused again after popup
					bool drawFrame = false;
					Color frameColor = new Color();

					//dragging button
					if (DragDrop.TryDrag(addDragId, UI.current.mousePos))
					{
						Cell.current.pixelOffset += DragDrop.totalDelta; //offsetting cell position with the mouse

						Draw.Texture(UI.current.textures.GetTexture("MapMagic/Icons/NodeAdd"));

						//if dragging near link, output or node
						Vector2 mousePos = graphUI.mousePos;
						//Vector2 mousePos = graphUI.scrollZoom.ToInternal(addDragTo + new Vector2(addDragSize/2,addDragSize/2)); //add button center

						object clickedObj = RightClick.ClickedOn(graphUI, mousePos);
				
						if (clickedObj != null  &&  !(clickedObj is Group))
						{
							drawFrame = true;
							frameColor = GeneratorDraw.GetLinkColor(Generator.GetGenericType(clickedObj.GetType()));
						}
					}

					//releasing button
					if (DragDrop.TryRelease(addDragId))
					{
						drawAddRemoveButton = false;

						Vector2 mousePos = graphUI.mousePos;
						//Vector2 mousePos = graphUI.scrollZoom.ToInternal(addDragTo + new Vector2(addDragSize/2,addDragSize/2)); //add button center

						RightClick.ClickedNear (graphUI, mousePos, 
							out Group clickedGroup, out Generator clickedGen, out IInlet<object> clickedLink, out IInlet<object> clickedInlet, out IOutlet<object> clickedOutlet, out RightClickExpose clickedField);

						if (clickedOutlet != null)
							CreateRightClick.DrawAppendItems(mousePos, graph, clickedOutlet);

						else if (clickedLink != null)
							CreateRightClick.DrawInsertItems(mousePos, graph, clickedLink);

						else
							CreateRightClick.DrawCreateItems(mousePos, graph);
					}

					//starting button drag
					DragDrop.TryStart(addDragId, UI.current.mousePos, Cell.current.InternalRect);

					//drawing button
					#if !MM_DOC
					if (drawAddRemoveButton) //don't show this button if right-click items are shown
						Draw.Texture(UI.current.textures.GetTexture("MapMagic/Icons/NodeAdd")); //using Texture since Icon is scaled with scrollzoom
					#endif

					if (drawFrame)
					{
						Texture2D frameTex = UI.current.textures.GetColorizedTexture("MapMagic/Icons/NodeAddRemoveFrame", frameColor);
						Draw.Texture(frameTex);
					}
				}
			}
		}
示例#2
0
        public static Item AppendItems(Vector2 mousePos, Graph graph, IOutlet <object> clickedOutlet, int priority = 4)
        /// Item set appeared on node or outlet click
        {
            Item addItems = null;

            if (clickedOutlet != null)
            {
                Type genericLinkType = Generator.GetGenericType(clickedOutlet);
                if (genericLinkType == null)
                {
                    throw new Exception("Could not find category " + clickedOutlet.GetType().ToString());
                }

                Item createItems = CreateItems(mousePos, graph);
                addItems = createItems.Find(GetCategoryByType(genericLinkType));
            }

            if (addItems != null && addItems.subItems != null)
            {
                Item initial = addItems.Find("Initial");
                if (initial != null)
                {
                    initial.disabled = true;
                }

                //adding link to all create actions
                foreach (Item item in addItems.All(true))
                {
                    if (item.onClick != null)
                    {
                        Action baseOnClick = item.onClick;
                        item.onClick = () =>
                        {
                            baseOnClick();

                            Generator createdGen = graph.generators[graph.generators.Length - 1];                           //the last on is the one that's just created. Hacky

                            Vector2 pos = clickedOutlet.Gen.guiPosition + new Vector2(200, 0);
                            GeneratorDraw.FindPlace(ref pos, new Vector2(100, 200), GraphWindow.current.graph);
                            createdGen.guiPosition = pos;

                            graph.AutoLink(createdGen, clickedOutlet);

                            GraphWindow.RefreshMapMagic(createdGen);
                        };
                    }
                }
            }
            else
            {
                addItems          = new Item("Add");
                addItems.onDraw   = RightClick.DrawItem;
                addItems.disabled = true;
            }

            addItems.name     = "Add (Append)";
            addItems.icon     = RightClick.texturesCache.GetTexture("MapMagic/Popup/Create");
            addItems.color    = Color.gray;
            addItems.priority = priority;

            return(addItems);
        }
示例#3
0
		private void DrawToolbar () 
		{ 
			//using (Timer.Start("DrawToolbar"))

			using (Cell.LinePx(toolbarSize))
			{
				Draw.Button();

				//Graph graph = CurrentGraph;
				//Graph rootGraph = mapMagic.graph;

				//if (mapMagic != null  &&  mapMagic.graph!=graph  &&  mapMagic.graph!=rootGraph) mapMagic = null;

				UI.current.styles.Resize(0.9f);  //shrinking all font sizes

				Draw.Element(UI.current.styles.toolbar);

	
				//undefined graph
				if (graph==null)
				{
					using (Cell.RowPx(200)) Draw.Label("No graph selected to display. Select:");
					using (Cell.RowPx(100)) Draw.ObjectField(ref graph);
					return;
				}

				//if graph loaded corrupted
				if (graph.generators==null) 
				{
					using (Cell.RowPx(300)) Draw.Label("Graph is null. Check the console for the error on load.");

					using (Cell.RowPx(100))
						if (Draw.Button("Reload", style:UI.current.styles.toolbarButton)) graph.OnAfterDeserialize();

					using (Cell.RowPx(100))
					{
						if (Draw.Button("Reset", style:UI.current.styles.toolbarButton)) graph.generators = new Generator[0];
					}
					
					Cell.EmptyRowRel(1);

					return;
				}

				//root graph
				Graph rootGraph = null;
				if (parentGraphs != null  &&  parentGraphs.Count != 0) 
					rootGraph = parentGraphs[0];
					//this has nothing to do with currently assigned mm graph - we can view subGraphs with no mm in scene at all

				if (rootGraph != null)
				{
					Vector2 rootBtnSize = UnityEngine.GUI.skin.label.CalcSize( new GUIContent(rootGraph.name) );
					using (Cell.RowPx(rootBtnSize.x))
					{
						//Draw.Button(graph.name, style:UI.current.styles.toolbarButton, cell:rootBtnCell);
						Draw.Label(rootGraph.name);
							if (Draw.Button("", visible:false))
								EditorGUIUtility.PingObject(rootGraph);
					}
				
					using (Cell.RowPx(20)) Draw.Label(">>"); 
				}

				//this graph
				Vector2 graphBtnSize = UnityEngine.GUI.skin.label.CalcSize( new GUIContent(graph.name) );
				using (Cell.RowPx(graphBtnSize.x))
				{
					Draw.Label(graph.name);
					if (Draw.Button("", visible:false))
						EditorGUIUtility.PingObject(graph);
				}

				//up-level and tree
				using (Cell.RowPx(20))
				{
					if (Draw.Button(null, icon:UI.current.textures.GetTexture("DPUI/Icons/FolderTree"), iconScale:0.5f, visible:false))
						GraphTreePopup.DrawGraphTree(rootGraph!=null ? rootGraph : graph);
				}

				using (Cell.RowPx(20))
				{
					if (parentGraphs != null  &&  parentGraphs.Count != 0  && 
						Draw.Button(null, icon:UI.current.textures.GetTexture("DPUI/Icons/FolderUp"), iconScale:0.5f, visible:false))
					{
						graph = parentGraphs[parentGraphs.Count-1];
						parentGraphs.RemoveAt(parentGraphs.Count-1);
						ScrollZoomOnOpen();
						Repaint();
					}
				}

				Cell.EmptyRowRel(1); //switching to right corner

				//seed
				Cell.EmptyRowPx(5);
				using (Cell.RowPx(1)) Draw.ToolbarSeparator();

				using (Cell.RowPx(90))
				//	using (Cell.LinePx(toolbarSize-1))  //-1 just to place it nicely
				{
					#if UNITY_2019_1_OR_NEWER
					int newSeed;
					using (Cell.RowRel(0.4f)) Draw.Label("Seed:");
					using (Cell.RowRel(0.6f))
						using (Cell.Padded(1))
							newSeed = (int)Draw.Field(graph.random.Seed, style:UI.current.styles.toolbarField);
					#else
					Cell.current.fieldWidth = 0.6f;
					int newSeed = Draw.Field(graph.random.Seed, "Seed:");
					#endif
					if (newSeed != graph.random.Seed)
					{
						GraphWindow.RecordCompleteUndo();
						graph.random.Seed = newSeed;
						GraphWindow.RefreshMapMagic();
					}
				}

				Cell.EmptyRowPx(2);


				//gauge
				using (Cell.RowPx(1)) Draw.ToolbarSeparator();

				using (Cell.RowPx(200))
					using (Cell.LinePx(toolbarSize-1)) //-1 to leave underscore under gauge
				{
					if (mapMagic != null)
					{
						bool isGenerating = mapMagic.IsGenerating();

						//background gauge
						if (isGenerating)
						{
							float progress = mapMagic.GetProgress();

							if (progress < 1 && progress != 0)
							{
								Texture2D backgroundTex = UI.current.textures.GetTexture("DPUI/ProgressBar/BackgroundBorderless");
								mapMagic.GetProgress();
								Draw.Texture(backgroundTex);

								Texture2D fillTex = UI.current.textures.GetBlankTexture(StylesCache.isPro ? Color.grey : Color.white);
								Color color = StylesCache.isPro ? new Color(0.24f, 0.37f, 0.58f) : new Color(0.44f, 0.574f, 0.773f);
								Draw.ProgressBarGauge(progress, fillTex, color);
							}

							//Repaint(); //doing it in OnInspectorUpdate
						}

						//refresh buttons
						using (Cell.RowPx(20))
							if (Draw.Button(null, icon:UI.current.textures.GetTexture("DPUI/Icons/RefreshAll"), iconScale:0.5f, visible:false))
							{
								//graphUI.undo.Record(completeUndo:true); //won't record changed terrain data
								foreach (Terrain terrain in mapMagic.tiles.AllActiveTerrains())
									UnityEditor.Undo.RegisterFullObjectHierarchyUndo(terrain.terrainData, "RefreshAll");
								EditorUtility.SetDirty(mapMagic);

								GraphWindow.current.mapMagic.ClearAll();
								GraphWindow.current.mapMagic.StartGenerate();
							}

						using (Cell.RowPx(20))
							if (Draw.Button(null, icon:UI.current.textures.GetTexture("DPUI/Icons/Refresh"), iconScale:0.5f, visible:false))
							{
								GraphWindow.current.mapMagic.StartGenerate();
							}

						//ready mark
						if (!isGenerating)
						{
							Cell.EmptyRow();
							using (Cell.RowPx(40)) Draw.Label("Ready");
						}
					}

					else
						Draw.Label("Not Assigned to MapMagic Object");
				}

				using (Cell.RowPx(1)) Draw.ToolbarSeparator();

				//focus
				using (Cell.RowPx(20))
					if (Draw.Button(null, icon:UI.current.textures.GetTexture("DPUI/Icons/FocusSmall"), iconScale:0.5f, visible:false))
					{
						graphUI.scrollZoom.FocusWindowOn(GetNodesCenter(graph), position.size);
					}

				using (Cell.RowPx(20))
				{
					if (graphUI.scrollZoom.zoom < 0.999f)
					{
						if (Draw.Button(null, icon:UI.current.textures.GetTexture("DPUI/Icons/ZoomSmallPlus"), iconScale:0.5f, visible:false))
							graphUI.scrollZoom.Zoom(1f, position.size/2);
					}
					else
					{
						if (Draw.Button(null, icon:UI.current.textures.GetTexture("DPUI/Icons/ZoomSmallMinus"), iconScale:0.5f, visible:false))
							graphUI.scrollZoom.Zoom(miniZoom, position.size/2); 
					}
				}
			}
		}
示例#4
0
		private void DragDrawAddRemove ()
		{
			//if dragging generator
			if (DragDrop.IsDragging()  &&  !DragDrop.IsStarted()  &&  DragDrop.obj is Cell  &&  UI.current.cellObjs.TryGetObject((Cell)DragDrop.obj, "Generator", out Generator draggedGen) )
			{
				if (Cell.current.Contains(UI.current.mousePos))
					Draw.Texture(UI.current.textures.GetTexture("MapMagic/Icons/NodeRemoveActive"));
				else
					Draw.Texture(UI.current.textures.GetTexture("MapMagic/Icons/NodeRemove"));
			}


			//if released generator on remove icon
			else if (DragDrop.IsReleased()  &&  
				DragDrop.releasedObj is Cell  &&  
				UI.current.cellObjs.TryGetObject((Cell)DragDrop.releasedObj, "Generator", out Generator releasedGen)  &&  
				Cell.current.Contains(UI.current.mousePos))
			{
				GraphEditorActions.RemoveGenerator(graph, releasedGen, selected);
				GraphWindow.RefreshMapMagic();
			}


			//if not dragging generator
			else
			{
				addDragTo = addDragDefault;

				if (focusedWindow == this) disableAddRemoveButton = false; //re-enabling when window is focused again after popup

				if (DragDrop.TryDrag(addDragId, UI.current.scrollZoom.ToScreen(UI.current.mousePos)))
				{
					addDragTo += DragDrop.totalDelta;

					Draw.Texture(UI.current.textures.GetTexture("MapMagic/Icons/NodeAdd"));

					//if dragging near link, output or node
					//Vector2 mousePos = graphUI.mousePos;
					Vector2 mousePos = graphUI.scrollZoom.ToInternal(addDragTo + new Vector2(addDragSize/2,addDragSize/2)); //add button center

					object clickedObj = RightClick.ClickedOn(graphUI, mousePos);
				
					if (clickedObj != null  &&  !(clickedObj is Group))
					{
						Color linkColor = GeneratorDraw.GetLinkColor(Generator.GetGenericType(clickedObj.GetType()));
						Texture2D frameTex = UI.current.textures.GetColorizedTexture("MapMagic/Icons/NodeAddRemoveFrame", linkColor);
						Draw.Texture(frameTex);
					}
				}
				else if (!disableAddRemoveButton) //don't show this button if right-click items are shown
					Draw.Texture(UI.current.textures.GetTexture("MapMagic/Icons/NodeAdd")); //using Texture since Icon is scaled with scrollzoom


				if (DragDrop.TryRelease(addDragId))
				{
					disableAddRemoveButton = true;

					//Vector2 mousePos = graphUI.mousePos;
					Vector2 mousePos = graphUI.scrollZoom.ToInternal(addDragTo + new Vector2(addDragSize/2,addDragSize/2)); //add button center

					RightClick.ClickedNear (graphUI, mousePos, 
						out Group clickedGroup, out Generator clickedGen, out IOutlet<object> clickedLayer, out IInlet<object> clickedLink, out IInlet<object> clickedInlet, out IOutlet<object> clickedOutlet, out FieldInfo clickedField);

					if (clickedOutlet != null)
						CreateRightClick.DrawAppendItems(mousePos, graph, clickedOutlet);

					else if (clickedLayer != null)
						CreateRightClick.DrawAppendItems(mousePos, graph, clickedLayer);

					else if (clickedLink != null)
						CreateRightClick.DrawInsertItems(mousePos, graph, clickedLink);

					else
						CreateRightClick.DrawCreateItems(mousePos, graph);
				}


				DragDrop.TryStart(addDragId, new Rect(addDragDefault, new Vector2(addDragSize-4,addDragSize-4)));
			}
		}
示例#5
0
        public static Item GeneratorItems(Generator gen, Graph graph, int priority = 3)
        {
            Item genItems = new Item("Generator");

            genItems.onDraw   = RightClick.DrawItem;
            genItems.icon     = RightClick.texturesCache.GetTexture("MapMagic/Popup/Generator");
            genItems.color    = Color.gray;
            genItems.subItems = new List <Item>();
            genItems.priority = priority;

            genItems.disabled = gen == null;

            Item enableItem = new Item(gen == null || gen.enabled ? "Disable" : "Enable", onDraw: RightClick.DrawItem, priority: 11)
            {
                icon = RightClick.texturesCache.GetTexture("MapMagic/Popup/Eye"), color = Color.gray
            };

            enableItem.onClick = () =>
            {
                gen.enabled = !gen.enabled;
                GraphWindow.RefreshMapMagic(gen);
            };
            genItems.subItems.Add(enableItem);

            //genItems.subItems.Add( new Item("Export", onDraw:RightClick.DrawItem, priority:10) { icon = RightClick.texturesCache.GetTexture("MapMagic/Popup/Export"), color = Color.gray } );
            //genItems.subItems.Add( new Item("Import", onDraw:RightClick.DrawItem, priority:9) { icon = RightClick.texturesCache.GetTexture("MapMagic/Popup/Import"), color = Color.gray } );

            Item duplicateItem = new Item("Duplicate", onDraw: RightClick.DrawItem, priority: 8);

            duplicateItem.icon    = RightClick.texturesCache.GetTexture("MapMagic/Popup/Duplicate");
            duplicateItem.color   = Color.gray;
            duplicateItem.onClick = () => GraphEditorActions.DuplicateGenerator(graph, gen, ref GraphWindow.current.selected);
            genItems.subItems.Add(duplicateItem);

            genItems.subItems.Add(new Item("Update", onDraw: RightClick.DrawItem, priority: 7)
            {
                icon = RightClick.texturesCache.GetTexture("MapMagic/Popup/Update"), color = Color.gray
            });
            genItems.subItems.Add(new Item("Reset", onDraw: RightClick.DrawItem, priority: 4)
            {
                icon = RightClick.texturesCache.GetTexture("MapMagic/Popup/Reset"), color = Color.gray
            });

            /*Item testItem = new Item("Create Test", onDraw:RightClick.DrawItem, priority:5);
             * testItem.icon = RightClick.texturesCache.GetTexture("MapMagic/Popup/Export");
             * testItem.color = Color.gray;
             * testItem.onClick = ()=> GeneratorsTester.CreateTestCase(gen, GraphWindow.current.mapMagic.PreviewData);
             * genItems.subItems.Add(testItem);*/

            Item removeItem = new Item("Remove", onDraw: RightClick.DrawItem, priority: 5);

            removeItem.icon    = RightClick.texturesCache.GetTexture("MapMagic/Popup/Remove");
            removeItem.color   = Color.gray;
            removeItem.onClick = () => GraphEditorActions.RemoveGenerator(graph, gen, GraphWindow.current.selected);
            genItems.subItems.Add(removeItem);

            Item unlinkItem = new Item("Unlink", onDraw: RightClick.DrawItem, priority: 6);

            unlinkItem.icon    = RightClick.texturesCache.GetTexture("MapMagic/Popup/Unlink");
            unlinkItem.color   = Color.gray;
            unlinkItem.onClick = () =>
            {
                graph.UnlinkGenerator(gen);
                GraphWindow.RefreshMapMagic(gen);
                //undo
            };
            genItems.subItems.Add(unlinkItem);


            return(genItems);
        }
        public static Item GeneratorItems(Vector2 mousePos, Generator gen, Graph graph, int priority = 3)
        {
            Item genItems = new Item("Generator");

            genItems.onDraw   = RightClick.DrawItem;
            genItems.icon     = RightClick.texturesCache.GetTexture("MapMagic/Popup/Generator");
            genItems.color    = RightClick.defaultColor;
            genItems.subItems = new List <Item>();
            genItems.priority = priority;

            genItems.disabled = gen == null && copiedGenerators == null;

            {             //enable/disable
                string caption = (gen == null || gen.enabled) ? "Disable" : "Enable";
                Item   item    = new Item(caption, onDraw: RightClick.DrawItem, priority: 11);
                item.icon     = RightClick.texturesCache.GetTexture("MapMagic/Popup/Eye");
                item.color    = RightClick.defaultColor;
                item.disabled = gen == null;
                item.onClick  = () =>
                {
                    gen.enabled = !gen.enabled;
                    GraphWindow.RefreshMapMagic(gen);
                    GraphWindow.current.Focus();
                    GraphWindow.current.Repaint();
                };
                genItems.subItems.Add(item);
            }

            //genItems.subItems.Add( new Item("Export", onDraw:RightClick.DrawItem, priority:10) { icon = RightClick.texturesCache.GetTexture("MapMagic/Popup/Export"), color = Color.gray } );
            //genItems.subItems.Add( new Item("Import", onDraw:RightClick.DrawItem, priority:9) { icon = RightClick.texturesCache.GetTexture("MapMagic/Popup/Import"), color = Color.gray } );

            {             //duplicate
                Item item = new Item("Duplicate", onDraw: RightClick.DrawItem, priority: 8);
                item.icon     = RightClick.texturesCache.GetTexture("MapMagic/Popup/Duplicate");
                item.color    = RightClick.defaultColor;
                item.disabled = gen == null;
                item.onClick  = () =>
                                GraphEditorActions.DuplicateGenerator(graph, gen, ref GraphWindow.current.selected);
                genItems.subItems.Add(item);
            }


            {             //copy
                Item item = new Item("Copy", onDraw: RightClick.DrawItem, priority: 8);
                item.icon     = RightClick.texturesCache.GetTexture("MapMagic/Popup/Export");
                item.color    = RightClick.defaultColor;
                item.disabled = !(gen != null || (GraphWindow.current.selected != null && GraphWindow.current.selected.Count != 0));
                item.onClick  = () =>
                {
                    HashSet <Generator> gens;
                    if (GraphWindow.current.selected != null && GraphWindow.current.selected.Count != 0)
                    {
                        gens = GraphWindow.current.selected;
                    }
                    else
                    {
                        gens = new HashSet <Generator>(); gens.Add(gen);
                    }
                    copiedGenerators = graph.Export(gens);
                };
                item.closeOnClick = true;
                genItems.subItems.Add(item);
            }


            {             //paste
                Item item = new Item("Paste", onDraw: RightClick.DrawItem, priority: 7);
                item.icon     = RightClick.texturesCache.GetTexture("MapMagic/Popup/Export");
                item.color    = RightClick.defaultColor;
                item.disabled = copiedGenerators == null;
                item.onClick  = () =>
                {
                    Generator[] imported = graph.Import(copiedGenerators);
                    Graph.Reposition(imported, mousePos);
                };
                item.closeOnClick = true;
                genItems.subItems.Add(item);
            }


            {             //update
                Item item = new Item("Update", onDraw: RightClick.DrawItem, priority: 7);
                item.icon         = RightClick.texturesCache.GetTexture("MapMagic/Popup/Update");
                item.color        = RightClick.defaultColor;
                item.closeOnClick = true;
                item.disabled     = gen == null;
            }


            {             //reset
                Item item = new Item("Reset", onDraw: RightClick.DrawItem, priority: 4);
                item.icon         = RightClick.texturesCache.GetTexture("MapMagic/Popup/Reset");
                item.color        = RightClick.defaultColor;
                item.closeOnClick = true;
                item.disabled     = gen == null;
            }


            {             //remove
                Item item = new Item("Remove", onDraw: RightClick.DrawItem, priority: 5);
                item.icon     = RightClick.texturesCache.GetTexture("MapMagic/Popup/Remove");
                item.color    = RightClick.defaultColor;
                item.disabled = gen == null;
                item.onClick  = () =>
                                GraphEditorActions.RemoveGenerator(graph, gen, GraphWindow.current.selected);
                item.closeOnClick = true;
                genItems.subItems.Add(item);
            }


            {             //unlink
                Item item = new Item("Unlink", onDraw: RightClick.DrawItem, priority: 6);
                item.icon     = RightClick.texturesCache.GetTexture("MapMagic/Popup/Unlink");
                item.color    = RightClick.defaultColor;
                item.disabled = gen == null;
                item.onClick  = () =>
                {
                    graph.UnlinkGenerator(gen);
                    GraphWindow.RefreshMapMagic(gen);
                    //undo
                };
                item.closeOnClick = true;
                genItems.subItems.Add(item);
            }


            if (gen != null)
            {             //id
                Item item = new Item($"Id: {gen.id}", onDraw: RightClick.DrawItem, priority: 3);
                item.color        = RightClick.defaultColor;
                item.onClick      = () => EditorGUIUtility.systemCopyBuffer = gen.id.ToString();
                item.closeOnClick = true;
                genItems.subItems.Add(item);
            }

                        #if MM_DEBUG
            if (gen != null)
            {             //position
                Item item = new Item($"Pos: {gen.guiPosition}", onDraw: RightClick.DrawItem, priority: 2);
                item.color        = RightClick.defaultColor;
                item.onClick      = () => EditorGUIUtility.systemCopyBuffer = gen.guiPosition.ToString();
                item.closeOnClick = true;
                genItems.subItems.Add(item);
            }
                        #endif

            return(genItems);
        }
        public void DrawGUI()
        {
            using (Cell.LinePx(32))
                Draw.Label("WARNING: Keeping this asset selected in \nInspector can slow down editor GUI performance.", style: UI.current.styles.helpBox);
            Cell.EmptyLinePx(5);

            using (Cell.LinePx(24)) if (Draw.Button("Open Editor"))
                {
                    GraphWindow.Show(graph);
                }
            using (Cell.LinePx(20)) if (Draw.Button("Open in New Tab"))
                {
                    GraphWindow.ShowInNewTab(graph);
                }

            //seed
            Cell.EmptyLinePx(5);
            using (Cell.LineStd)
            {
                int newSeed = Draw.Field(graph.random.Seed, "Seed");                         //
                if (newSeed != graph.random.Seed)
                {
                    graph.random.Seed = newSeed;
                    //Graph.OnChange.Raise(graph);
                }
            }

            using (Cell.LineStd) Draw.DualLabel("Nodes", graph.generators.Length.ToString());
            using (Cell.LineStd) Draw.DualLabel("MapMagic ver", graph.serializedVersion.ToString());
            Cell.EmptyLinePx(5);


            //global values

            /*using (Cell.LineStd)
             *      using (new Draw.FoldoutGroup (ref showShared, "Global Values"))
             *              if (showShared)
             *      {
             *              List<string> changedNames = new List<string>();
             *              List<object> changedVals = new List<object>();
             *
             *              (Type type, string name)[] typeNames = graph.sharedVals.GetTypeNames();
             *              for (int i=0; i<typeNames.Length; i++)
             *                      using (Cell.LineStd) GeneratorDraw.DrawGlobalVar(typeNames[i].type, typeNames[i].name);
             *
             *              if (Cell.current.valChanged)
             *              {
             *                      GraphWindow.current.mapMagic.ClearAllNodes();
             *                      GraphWindow.current.mapMagic.StartGenerate();
             *              }
             *      }*/

            //exposed values
            using (Cell.LineStd)
                using (new Draw.FoldoutGroup(ref showExposed, "Exposed Values"))
                    if (showExposed)
                    {
                        graph.exposed.ClearObsoleteEntries(graph);

                        if (graph.exposed.entries != null)
                        {
                            for (int e = 0; e < graph.exposed.entries.Length; e++)
                            {
                                Exposed.Entry entry = graph.exposed.entries[e];
                                IExposedGuid  gen   = graph.FindGenByGuid(entry.guid);
                                FieldInfo     field = gen.GetType().GetField(entry.fieldName);

                                using (Cell.LineStd)
                                {
                                    if (field == null)
                                    {
                                        Draw.DualLabel(entry.guiName, "unknown");
                                    }

                                    else
                                    {
                                        Draw.ClassField(
                                            field: field,
                                            type: entry.type,
                                            obj: gen,
                                            name: entry.guiName);
                                    }
                                }

                                if (Cell.current.valChanged)
                                {
                                    GraphWindow.RefreshMapMagic();
                                }
                            }
                        }
                    }

            //dependent graphs
            using (Cell.LineStd)
                using (new Draw.FoldoutGroup(ref showDependent, "Dependent Graphs"))
                    if (showDependent)
                    {
                        using (Cell.LinePx(0))
                            DrawDependentGraphs(graph);
                    }
        }