protected static MonoScript CahsedMono <T>(ref MonoScript monoScript) // да, здесь действительно нужен ref { if (monoScript == null) { monoScript = SpiralEditorTools.GetMonoScript(typeof(T)); } return(monoScript); }
public static void DrawScriptFieldRect(Type type, Rect position) { SpiralEditor.SetGUIEnabled(false); MonoScript monoScript = SpiralEditorTools.GetMonoScript(type); EditorGUI.ObjectField(position, monoScript, typeof(MonoScript), false); SpiralEditor.RestoreGUIEnabled(); }
public static void DrawScriptFieldRect(Type type, Rect position) { GUI.enabled = false; MonoScript monoScript = SpiralEditorTools.GetMonoScript(type); EditorGUI.ObjectField(position, monoScript, typeof(MonoScript), false); GUI.enabled = true; }
public static void DrawScriptField(Type type, string content = "") { BeginPanel(GroupType.Vertical); GUI.enabled = false; MonoScript monoScript = SpiralEditorTools.GetMonoScript(type); if (content == "") { content = "Script"; } EditorGUILayout.ObjectField(content, monoScript, typeof(MonoScript), false); GUI.enabled = true; EndPanel(); }
// Path Fields ---------------------------------------------------------------------------- #region PATH FIELDS public static string SelectPathField(string panelName, string path, string ext = "") { BeginGroup(GroupType.Horizontal); if (string.IsNullOrWhiteSpace(path)) { path = SpiralEditorTools.GetDirectory(path); } EditorGUILayout.TextField(GetLabel(panelName, "Path to save screenshots"), path); bool pathExists = Directory.Exists(path); SetGUIEnabled(pathExists); bool open = MiniButton("Open"); if (open) { try { EditorUtility.RevealInFinder(path); } catch { } } RestoreGUIEnabled(); bool browse = MiniButton("..."); string ans; if (browse) { string dir = SpiralEditorTools.GetDirectory(path); bool folder = string.IsNullOrEmpty(ext); ans = folder ? EditorUtility.OpenFolderPanel(panelName, dir, "") : EditorUtility.OpenFilePanel(panelName, dir, ext); if (ans == "") { ans = path; } } else { ans = path; } EndGroup(); return(ans); }
// INITIALIZE STYLES ====================================================================== // Инициализирует все шорткаты, используемые выше //========================================================================================= static SpiralStyles() { // panels ----------------------------------------------------------------------------- panel = new GUIStyle(EditorStyles.helpBox); panelIndented = new GUIStyle(panel); panelIndented.margin.left += indentPanelLeft; // labels ----------------------------------------------------------------------------- labelSmall = new GUIStyle(EditorStyles.label) { fontSize = fontSizeSmall, richText = true }; labelNormal = new GUIStyle(EditorStyles.label) { fontSize = fontSizeNormal, richText = true }; labelBold = new GUIStyle(EditorStyles.boldLabel) { fontSize = fontSizeNormal, richText = true }; labelSmallBold = new GUIStyle(EditorStyles.boldLabel) { fontSize = fontSizeSmall, richText = true }; labelSmallBoxedBold = new GUIStyle(panel) { fontStyle = FontStyle.Bold, fontSize = fontSizeSmall, richText = true }; labelBoxedBoldCaption = new GUIStyle(panel) { fontStyle = FontStyle.Bold, fontSize = fontSizeNormal, richText = true }; labelSmallBoxed = new GUIStyle(panel) { fontSize = fontSizeSmall, richText = true }; labelLogo = new GUIStyle(labelSmallBold); labelLogo.normal.textColor = new Color(0.2f, 0.4f, 0.2f); labelLogo.alignment = TextAnchor.MiddleRight; // buttons ---------------------------------------------------------------------------- buttonNormal = new GUIStyle(GUI.skin.button) { fontSize = fontSizeNormal, richText = true }; buttonMini = new GUIStyle(EditorStyles.miniButton) { // do nothing yet }; // foldouts --------------------------------------------------------------------------- foldoutNormal = new GUIStyle(EditorStyles.foldout) { fontSize = fontSizeNormal, richText = true }; foldoutIndentedNormal = new GUIStyle(foldoutNormal); foldoutIndentedNormal.margin.left += indentFoldoutLeft; foldoutIndentedBold = new GUIStyle(foldoutNormal) { fontStyle = FontStyle.Bold, }; foldoutIndentedBold.margin.left += indentFoldoutLeft; // foldout property ------------------------------------------------------------------- foldoutPropertyNormal = new GUIStyle(EditorStyles.foldout) { fontSize = fontSizeNormal, richText = true }; foldoutPropertyNormal.margin.left += indentPropertyFoldoutLeft; foldoutPropertySmall = new GUIStyle(EditorStyles.foldout) { fontSize = fontSizeSmall, richText = true }; foldoutPropertySmall.margin.left += indentPropertyFoldoutLeft; foldoutPropertyBold = new GUIStyle(foldoutPropertyNormal) { fontStyle = FontStyle.Bold }; foldoutPropertySmallBold = new GUIStyle(foldoutPropertySmall) { fontStyle = FontStyle.Bold }; // popups ----------------------------------------------------------------------------- popupSmall = new GUIStyle(EditorStyles.popup) { fontSize = fontSizePopupNormal, richText = false // lol, we have troubles here }; // hex colors ------------------------------------------------------------------------- hexDarkRed = SpiralEditorTools.GetColorHex(0.7f, 0.0f, 0.0f, 1.0f); }