private void OnGUI() { Shortcuts(); float width = this.position.width; float height = this.position.height; EditorGUILayout.BeginHorizontal(); if (currentTool != null) { string toolName = currentTool.GetType().Name.Replace("Tool", ": Options"); GUILayout.Label(toolName, new GUIStyle("ProgressBarBack"), GUILayout.Width(width - 32f)); } else { GUILayout.Label("Tool isn't selected", new GUIStyle("ProgressBarBack"), GUILayout.Width(width - 32f)); } GUIStyle iconButtonStyle = GUI.skin.FindStyle("IconButton") ?? EditorGUIUtility.GetBuiltinSkin(EditorSkin.Inspector).FindStyle("IconButton"); GUIContent popupIcon = EditorGUIUtility.IconContent("_Popup"); if (GUILayout.Button(popupIcon, iconButtonStyle)) { Vector2 settingPos = GUIUtility.GUIToScreenPoint(Event.current.mousePosition); settingPos.y += 32f; PrefabshopSettings.Init(settingPos); } EditorGUILayout.EndHorizontal(); height -= 24f; scrollView = EditorGUILayout.BeginScrollView(scrollView, GUILayout.Width(width), GUILayout.Height(height)); { if (currentTool != null) { currentTool.OnGUI(); for (int i = 0; i < currentTool.parameters.Count; i++) { if (!currentTool.parameters[i].Hidden) { GUI.enabled = currentTool.parameters[i].Enable; EditorGUILayout.BeginVertical(EditorStyles.helpBox); currentTool.parameters[i].DrawParameterGUI(); EditorGUILayout.EndVertical(); GUI.enabled = true; } } } } EditorGUILayout.EndScrollView(); }
public static void Init(Vector2 pos) { PrefabshopSettings window = EditorWindow.GetWindow <PrefabshopSettings>(); window.minSize = new Vector2(320, 420); GUIContent titleContent = new GUIContent("Prefabshop Settings"); window.titleContent = titleContent; window.Show(); Rect windowRect = new Rect(pos, window.position.size); window.position = windowRect; var types = Assembly.GetExecutingAssembly().GetTypes(); window.tools = (from System.Type type in types where type.IsSubclassOf(typeof(Tool)) select type).ToArray(); window.paint = ToolColorAttribute.GetColor(ToolColorAttribute.ToolUseType.Paint); window.remove = ToolColorAttribute.GetColor(ToolColorAttribute.ToolUseType.Remove); window.other = ToolColorAttribute.GetColor(ToolColorAttribute.ToolUseType.Other); }