private void DrawLinkTool() { EditorGUI.BeginChangeCheck(); linkTool_MarkMode = GUILayout.Toggle(linkTool_MarkMode, "Link Mode", GUI.skin.button); if (EditorGUI.EndChangeCheck()) { // reset when mode changes if (linkTool_MarkMode) { linkTool_UnlinkMode = false; } unlinkSelection.Clear(); linkTool_Nodes[0].Clear(); linkTool_Nodes[1].Clear(); SceneView.RepaintAll(); } if (linkTool_MarkMode) { EditorGUILayout.BeginVertical(Toolbox_Style); if (GUILayout.Button("Clear Marked")) { linkTool_Nodes[0].Clear(); linkTool_Nodes[1].Clear(); SceneView.RepaintAll(); } GUILayout.Space(10); linkTool_Data = EditorGUILayout.IntField("Link Data", linkTool_Data); if (MapNavEdUtil.GUILayout_LabelButton("", "Apply")) { UpdateNodeLinkData(); linkTool_Nodes[0].Clear(); linkTool_Nodes[1].Clear(); SceneView.RepaintAll(); } EditorGUILayout.EndVertical(); GUILayout.Space(30); } EditorGUI.BeginChangeCheck(); linkTool_UnlinkMode = GUILayout.Toggle(linkTool_UnlinkMode, "UnLink Mode", GUI.skin.button); if (EditorGUI.EndChangeCheck()) { // reset when mode changes if (linkTool_UnlinkMode) { linkTool_MarkMode = false; } unlinkSelection.Clear(); linkTool_Nodes[0].Clear(); linkTool_Nodes[1].Clear(); SceneView.RepaintAll(); } if (linkTool_UnlinkMode) { EditorGUILayout.BeginVertical(Toolbox_Style); if (GUILayout.Button("Remove all Links")) { if (EditorUtility.DisplayDialog("Warning", "You are about to remove all link data, continue?", "Yes", "Cancel")) { for (int i = 0; i < mapnav.grid.Length; i++) { mapnav.grid[i].linkData = null; } EditorUtility.SetDirty(mapnav); GUI.changed = false; col.Clear(); linkCache.Clear(); linkTool_Nodes[0].Clear(); linkTool_Nodes[1].Clear(); SceneView.RepaintAll(); } } GUILayout.Space(10); if (unlinkSelection.Count > 0) { if (GUILayout.Button("Remove Selected")) { foreach (LinkCacheEntry n in unlinkSelection) { mapnav.grid[n.idx1].RemoveLinkData(n.idx2, mapnav); } EditorUtility.SetDirty(mapnav); GUI.changed = false; unlinkSelection.Clear(); col.Clear(); linkCache.Clear(); linkTool_Nodes[0].Clear(); linkTool_Nodes[1].Clear(); UpdateLinkCache(); SceneView.RepaintAll(); } foreach (LinkCacheEntry n in unlinkSelection) { //EditorGUILayout.BeginHorizontal(); GUILayout.Label(mapnav.grid[n.idx1].ToString() + " => " + mapnav.grid[n.idx2].ToString()); //EditorGUILayout.EndHorizontal(); } } EditorGUILayout.EndVertical(); GUILayout.Space(30); } GUILayout.Space(15); EditorGUI.BeginChangeCheck(); linkTool_DrawLinks = EditorGUILayout.Toggle("Show NodeLinks", linkTool_DrawLinks); if (EditorGUI.EndChangeCheck()) { SceneView.RepaintAll(); } }
public override void OnInspectorGUI() { DrawDefaultInspector(); if (GUI.changed) { EditorUtility.SetDirty(mapnav); GUI.changed = false; } InitUI(); mapnav = target as MapNavBase; if (mapnav == null) { return; } EditorGUILayout.Space(); GUILayout.Label("Tools"); if (GUILayout.Button("Generate Grid")) { for (int i = 0; i < tool.Length; i++) { tool[i] = false; } linkCache.Clear(); col.Clear(); linkTool_Nodes[0].Clear(); linkTool_Nodes[1].Clear(); mapnav.CreateGrid(NodeType); EditorUtility.SetDirty(mapnav); } if (GUILayout.Button("Lift Grid")) { mapnav.ChangeGridHeight(+1); EditorUtility.SetDirty(mapnav); } if (GUILayout.Button("Lower Grid")) { mapnav.ChangeGridHeight(-1); EditorUtility.SetDirty(mapnav); } if (GUILayout.Button("Smooth Out")) { mapnav.SmoothOut(); EditorUtility.SetDirty(mapnav); } tool[0] = GUILayout.Toggle(tool[0], "Height Tool", GUI.skin.button); if (tool[0]) { EditorGUILayout.BeginVertical(Toolbox_Style); heightTool_LayerMask = MapNavEdUtil.GUILayout_LayerMaskField("Layer Mask", heightTool_LayerMask); heightTool_startHeight = EditorGUILayout.FloatField("Start Height", heightTool_startHeight); heightTool_endHeight = EditorGUILayout.FloatField("End Height", heightTool_endHeight); heightTool_markInvalids = EditorGUILayout.Toggle("Mark Invalid", heightTool_markInvalids); heightTool_extraPrecision = (heightTool_extraPrecision_type)EditorGUILayout.EnumPopup("Extra Precision", heightTool_extraPrecision); if (MapNavEdUtil.GUILayout_LabelButton("", "Execute")) { mapnav.AdjustToColliders(heightTool_LayerMask, heightTool_startHeight, linkTool_Data, heightTool_markInvalids, (int)heightTool_extraPrecision); EditorUtility.SetDirty(mapnav); } EditorGUILayout.EndVertical(); } EditorGUI.BeginChangeCheck(); tool[1] = GUILayout.Toggle(tool[1], "NodeLink Tool", GUI.skin.button); if (EditorGUI.EndChangeCheck()) { SceneView.RepaintAll(); } if (tool[1]) { EditorGUILayout.BeginVertical(Toolbox_Style); DrawLinkTool(); EditorGUILayout.EndVertical(); } EditorGUILayout.Space(); GUILayout.Label("Debug"); mapnav._dev_show_nodes = GUILayout.Toggle(mapnav._dev_show_nodes, "Show Nodes", GUI.skin.button); if (mapnav._dev_show_nodes) { EditorGUI.BeginChangeCheck(); debug_ShowLabels = EditorGUILayout.Toggle("Show labels", debug_ShowLabels); if (EditorGUI.EndChangeCheck()) { SceneView.RepaintAll(); } } }