public static void ShowWindow() { if (Theme.window.IsNull()) { Theme.window = Locate.GetAssets <ThemeWindow>().FirstOrDefault(); if (Theme.window.IsNull()) { Theme.window = ScriptableObject.CreateInstance <ThemeWindow>(); Theme.window.position = ThemeWindow.hiddenPosition; Theme.window.minSize = ThemeWindow.hiddenSize; Theme.window.maxSize = ThemeWindow.hiddenSize; Theme.window.wantsMouseMove = Theme.hoverResponse != HoverResponse.None; Theme.window.ShowPopup(); } } if (Theme.window.position != ThemeWindow.hiddenPosition) { Theme.window.position = ThemeWindow.hiddenPosition; } if (Theme.window.maxSize != ThemeWindow.hiddenSize) { Theme.window.minSize = ThemeWindow.hiddenSize; Theme.window.maxSize = ThemeWindow.hiddenSize; } }
//================================ // Internal //================================ public void InstanceGameObject(string[] values) { var target = Locate.GetAssets <GameObject>().Where(x => x.name == values[1]).FirstOrDefault(); if (!target.IsNull()) { var instance = GameObject.Instantiate <GameObject>(target); instance.SetActive(true); } }
public void Deserialize(string data) { if (data.IsEmpty()) { return; } var name = ""; ThemeFont themeFont = null; foreach (var line in data.GetLines()) { if (line.Trim().IsEmpty()) { continue; } if (line.Contains("[")) { name = line.Parse("[", "]"); themeFont = this.fonts.AddNew(name); themeFont.name = name; themeFont.path = name + ".ttf"; themeFont.proxy = File.GetAsset <Font>(themeFont.path); continue; } if (themeFont.IsNull()) { continue; } var current = line.Remove("\"", "'"); var term = current.Parse("", "=").Trim(); var value = current.Parse("=").Trim(); if (term.Matches("Font", true)) { themeFont.font = File.GetAsset <Font>(value + ".ttf", false); themeFont.font = themeFont.font ?? File.GetAsset <Font>(value + ".otf", false); themeFont.font = themeFont.font ?? Locate.GetAssets <Font>().Where(x => x.name == value).FirstOrDefault(); } else if (term.Matches("SizeOffset", true)) { themeFont.sizeOffset = value.ToInt(); } else if (term.Matches("OffsetX", true)) { themeFont.offsetX = value.ToFloat(); } else if (term.Matches("OffsetY", true)) { themeFont.offsetY = value.ToFloat(); } } }
public static void RebuildAll() { var windows = Locate.GetAssets <EditorWindow>(); foreach (var window in windows) { if (windows.IsNull()) { continue; } var tracker = window.GetVariable <ActiveEditorTracker>("m_Tracker"); if (tracker == null || System.Object.Equals(tracker, null)) { continue; } tracker.ForceRebuild(); } }
public void Setup(string path) { if (this.imageName.IsEmpty()) { return; } this.value.image = FileManager.GetAsset <Texture2D>(path + "/" + this.imageName + ".png"); if (this.value.image.IsNull()) { foreach (var texture in Locate.GetAssets <Texture2D>()) { if (texture.name == this.imageName && FileManager.GetPath(texture).Contains("Library/unity")) { this.value.image = texture; return; } } } }
public void ApplyMain(Theme theme) { if (this.skin.IsNull()) { return; } var skin = EditorGUIUtility.GetBuiltinSkin(EditorSkin.Inspector); var isFragment = this.path.Contains("#"); var isDefault = this.skinset.name == "Default"; var main = this.skin; var palette = theme.palette; if (!isDefault) { main = theme.fontset.Apply(main); theme.palette.Apply(main); ThemeSkin.RemoveHover(main); } skin.Use(main, !isFragment, true); EditorGUIUtility.GetBuiltinSkin(EditorSkin.Game).Use(skin, !isFragment, true); EditorGUIUtility.GetBuiltinSkin(EditorSkin.Scene).Use(skin, !isFragment, true); var collabStyle = isDefault ? skin.Get("DropDown").Padding(24, 14, 2, 3) : skin.Get("DropDown"); Utility.GetUnityType("Toolbar.Styles").GetVariable <GUIStyle>("collabButtonStyle").Use(collabStyle); Utility.GetUnityType("AppStatusBar").ClearVariable("background"); Utility.GetUnityType("SceneRenderModeWindow.Styles").SetVariable("sMenuItem", skin.Get("MenuItem")); Utility.GetUnityType("SceneRenderModeWindow.Styles").SetVariable("sSeparator", skin.Get("sv_iconselector_sep")); Utility.GetUnityType("GameView.Styles").SetVariable("gizmoButtonStyle", skin.Get("GV Gizmo DropDown")); typeof(SceneView).SetVariable <GUIStyle>("s_DropDownStyle", skin.Get("GV Gizmo DropDown")); var hostView = Utility.GetUnityType("HostView"); if (palette.Has("Cursor")) { skin.settings.cursorColor = palette.Get("Cursor"); } if (palette.Has("Selection")) { skin.settings.selectionColor = palette.Get("Selection"); } if (palette.Has("Curve")) { typeof(EditorGUI).SetVariable("kCurveColor", palette.Get("Curve")); } if (palette.Has("CurveBackground")) { typeof(EditorGUI).SetVariable("kCurveBGColor", palette.Get("CurveBackground")); } if (palette.Has("Window")) { typeof(EditorGUIUtility).SetVariable("kDarkViewBackground", palette.Get("Window")); hostView.SetVariable("kViewColor", palette.Get("Window")); } foreach (var view in Resources.FindObjectsOfTypeAll(hostView)) { view.ClearVariable("background"); } foreach (var window in Locate.GetAssets <EditorWindow>()) { window.minSize = new Vector2(100, 20); } if (!isDefault) { Utility.GetUnityType("PreferencesWindow").InstanceVariable("constants").SetVariable("sectionHeader", skin.Get("HeaderLabel")); } Utility.GetUnityType("BuildPlayerWindow").InstanceVariable("styles").SetVariable("toggleSize", new Vector2(24, 16)); }