public void OnGUI() { titleContent = new GUIContent("Road Network", GUIResources.RoadNetworkIcon); EditorGUILayout.BeginHorizontal(); FocusedRoadNetwork = (RoadNetwork)EditorGUILayout.ObjectField(FocusedRoadNetwork, typeof(RoadNetwork), false); GUI.color = FocusedRoadNetwork != null && FocusedRoadNetwork.SceneViewEnabled ? Color.white : Color.grey; if (FocusedRoadNetwork != null && GUILayout.Button(new GUIContent(GUIResources.EyeOpenIcon, FocusedRoadNetwork.SceneViewEnabled ? "Disable Gizmos" : "Enable Gizmos"), EditorStyles.label, GUILayout.Width(18), GUILayout.Height(18))) { FocusedRoadNetwork.SceneViewEnabled = !FocusedRoadNetwork.SceneViewEnabled; SceneView.RepaintAll(); } GUI.color = Color.white; EditorExtensions.HelpButton("http://lrtw.net/madmaps/index.php?title=Road_Network"); EditorGUILayout.EndHorizontal(); if (FocusedRoadNetwork == null) { EditorGUILayout.HelpBox("Select a Road Network object.", MessageType.Info); return; } if (!FocusedRoadNetwork.SceneViewEnabled) { EditorGUILayout.HelpBox("Gizmos are Disabled", MessageType.Info); } NodePreviewSize = FocusedRoadNetwork.NodePreviewSize; _currentTab.Value = GUILayout.Toolbar(_currentTab, _tabs, GUILayout.Height(20)); EditorExtensions.Seperator(); _scroll = EditorGUILayout.BeginScrollView(_scroll); switch (_currentTab) { case 0: // Connections DoConnectionsUI(); break; case 1: // Intersections DoIntersectionsUI(); break; case 2: // Configuration DoConfigUI(); break; } EditorGUILayout.LabelField("", GUILayout.ExpandHeight(true)); DoCommands(); EditorGUILayout.EndScrollView(); }
public void OnSelectionChange() { var activeGO = Selection.activeGameObject; if (!activeGO) { return; } var rn = activeGO.GetComponent <RoadNetwork>(); if (rn) { FocusedRoadNetwork = rn; } }