destroyed proj
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Borodar.RainbowHierarchy
|
||||
{
|
||||
[SuppressMessage("ReSharper", "ConvertIfStatementToNullCoalescingExpression")]
|
||||
public static class ColorHelper
|
||||
{
|
||||
public static readonly Color POPUP_BORDER_CLR_FREE = new Color(0.51f, 0.51f, 0.51f);
|
||||
public static readonly Color POPUP_BORDER_CLR_PRO = new Color(0.13f, 0.13f, 0.13f);
|
||||
|
||||
public static readonly Color POPUP_BACKGROUND_CLR_FREE = new Color(0.83f, 0.83f, 0.83f);
|
||||
public static readonly Color POPUP_BACKGROUND_CLR_PRO = new Color(0.18f, 0.18f, 0.18f);
|
||||
|
||||
public static readonly Color SEPARATOR_CLR_1_FREE = new Color(0.65f, 0.65f, 0.65f, 1f);
|
||||
public static readonly Color SEPARATOR_CLR_2_FREE = new Color(0.9f, 0.9f, 0.9f, 1f);
|
||||
public static readonly Color SEPARATOR_CLR_1_PRO = new Color(0.13f, 0.13f, 0.13f, 1f);
|
||||
public static readonly Color SEPARATOR_CLR_2_PRO = new Color(0.22f, 0.22f, 0.22f, 1f);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f5afe207c4e956942a1f9bef022c3a98
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 106670
|
||||
packageName: Rainbow Hierarchy 2
|
||||
packageVersion: 2.6.2
|
||||
assetPath: Assets/Plugins/Borodar/RainbowHierarchy/Scripts/Editor/Helpers/ColorHelper.cs
|
||||
uploadId: 716077
|
||||
@@ -0,0 +1,227 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Borodar.RainbowHierarchy
|
||||
{
|
||||
[SuppressMessage("ReSharper", "ConvertIfStatementToNullCoalescingExpression")]
|
||||
public static class HierarchyEditorUtility
|
||||
{
|
||||
private static Texture2D _editIcon;
|
||||
private static Texture2D _settingsIcon;
|
||||
private static Texture2D _filterIcon;
|
||||
private static Texture2D _deleteIcon;
|
||||
|
||||
private static Texture2D _foldoutFirstIcon;
|
||||
private static Texture2D _foldoutMiddleIcon;
|
||||
private static Texture2D _foldoutLastIcon;
|
||||
private static Texture2D _foldoutLevelsIcon;
|
||||
|
||||
private static string _projectName;
|
||||
private static string _projectPath;
|
||||
private static string _tempDir;
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// Project
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
[SuppressMessage("ReSharper", "InvertIf")]
|
||||
public static string ProjectName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_projectName == null)
|
||||
{
|
||||
var path = Application.dataPath.Split('/');
|
||||
_projectName = path[path.Length - 2];
|
||||
}
|
||||
|
||||
return _projectName;
|
||||
}
|
||||
}
|
||||
|
||||
[SuppressMessage("ReSharper", "InvertIf")]
|
||||
public static string ProjectPath
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_projectPath == null)
|
||||
{
|
||||
_projectPath = Path.GetDirectoryName(Application.dataPath);
|
||||
}
|
||||
|
||||
return _projectPath;
|
||||
}
|
||||
}
|
||||
|
||||
[SuppressMessage("ReSharper", "InvertIf")]
|
||||
public static string TempDir
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_tempDir == null)
|
||||
{
|
||||
_tempDir = $"{ProjectPath}/Temp";
|
||||
}
|
||||
|
||||
return _tempDir;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// Windows
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
public static IEnumerable<EditorWindow> GetAllWindowsByType(string type)
|
||||
{
|
||||
var objectList = Resources.FindObjectsOfTypeAll(typeof(EditorWindow));
|
||||
var windows = from obj in objectList where obj.GetType().ToString() == type select (EditorWindow) obj;
|
||||
return windows;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// Scene
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
public static void UpdateSceneConfigVisibility(bool isVisible)
|
||||
{
|
||||
var rulesetInstances = HierarchyRulesetV2.Instances;
|
||||
if (rulesetInstances == null || rulesetInstances.Count < 1) return;
|
||||
|
||||
foreach (var ruleset in rulesetInstances)
|
||||
{
|
||||
if (ruleset == null) return;
|
||||
ruleset.transform.hideFlags = isVisible
|
||||
? HideFlags.None
|
||||
: HideFlags.HideInHierarchy;
|
||||
}
|
||||
|
||||
EditorApplication.DirtyHierarchyWindowSorting();
|
||||
}
|
||||
|
||||
public static string GetTransformPath(Transform transform)
|
||||
{
|
||||
var path = transform.name;
|
||||
while (transform.parent != null)
|
||||
{
|
||||
transform = transform.parent;
|
||||
path = $"{transform.name}/{path}";
|
||||
}
|
||||
return $"/{path}";
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// GUI
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
public static bool SearchField(ref string query, ref Enum filter, Enum defaultFilter, params GUILayoutOption[] options)
|
||||
{
|
||||
var queryBefore = query;
|
||||
var filterBefore = filter;
|
||||
var changed = false;
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
|
||||
var queryRect = GUILayoutUtility.GetRect(GUIContent.none, "ToolbarSearchTextFieldPopup", options);
|
||||
queryRect.x += 2f;
|
||||
queryRect.width -= 13f;
|
||||
|
||||
var filterRect = queryRect;
|
||||
filterRect.width = 20f;
|
||||
|
||||
filter = EditorGUI.EnumPopup(filterRect, filter, "label");
|
||||
if (!Equals(filter, filterBefore)) changed = true;
|
||||
|
||||
query = EditorGUI.TextField(queryRect, GUIContent.none, query, "ToolbarSearchTextField");
|
||||
if (query != null && !query.Equals(queryBefore)) changed = true;
|
||||
|
||||
var cancelRect = queryRect;
|
||||
cancelRect.x += queryRect.width;
|
||||
cancelRect.width = 12f;
|
||||
if (GUI.Button(cancelRect, GUIContent.none, "ToolbarSearchCancelButton"))
|
||||
{
|
||||
query = string.Empty;
|
||||
filter = defaultFilter;
|
||||
changed = true;
|
||||
// workaround for bug with selected text
|
||||
GUIUtility.keyboardControl = 0;
|
||||
}
|
||||
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// Icons
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
public static Texture2D GetEditIcon()
|
||||
{
|
||||
return GetTexture(ref _editIcon, HierarchyEditorTexture.IcnEdit);
|
||||
}
|
||||
|
||||
public static Texture2D GetSettingsButtonIcon()
|
||||
{
|
||||
return GetTexture(ref _settingsIcon, HierarchyEditorTexture.IcnSettings);
|
||||
}
|
||||
|
||||
public static Texture2D GetFilterButtonIcon()
|
||||
{
|
||||
return GetTexture(ref _filterIcon, HierarchyEditorTexture.IcnFilter);
|
||||
}
|
||||
|
||||
public static Texture2D GetDeleteButtonIcon()
|
||||
{
|
||||
return GetTexture(ref _deleteIcon, HierarchyEditorTexture.IcnDelete);
|
||||
}
|
||||
|
||||
public static Texture2D GetFoldoutIcon(SiblingIndex index)
|
||||
{
|
||||
switch (index)
|
||||
{
|
||||
case SiblingIndex.First:
|
||||
return GetTexture(ref _foldoutFirstIcon, HierarchyEditorTexture.IcnFoldoutFirst);
|
||||
case SiblingIndex.Middle:
|
||||
return GetTexture(ref _foldoutMiddleIcon, HierarchyEditorTexture.IcnFoldoutMiddle);
|
||||
case SiblingIndex.Last:
|
||||
return GetTexture(ref _foldoutLastIcon, HierarchyEditorTexture.IcnFoldoutLast);
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException("index", index, null);
|
||||
}
|
||||
}
|
||||
|
||||
public static Texture2D GetFoldoutLevelsIcon()
|
||||
{
|
||||
return GetTexture(ref _foldoutLevelsIcon, HierarchyEditorTexture.IcnFoldoutLevels);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// Helpers
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
private static Texture2D GetTexture(ref Texture2D texture, HierarchyEditorTexture type)
|
||||
{
|
||||
if (texture == null)
|
||||
texture = HierarchyEditorTexturesStorage.GetTexture(type);
|
||||
|
||||
return texture;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// Nested
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
public enum SiblingIndex
|
||||
{
|
||||
First,
|
||||
Middle,
|
||||
Last
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 706f956b3ade11845b3ebc2c47f0fe00
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 106670
|
||||
packageName: Rainbow Hierarchy 2
|
||||
packageVersion: 2.6.2
|
||||
assetPath: Assets/Plugins/Borodar/RainbowHierarchy/Scripts/Editor/Helpers/HierarchyEditorUtility.cs
|
||||
uploadId: 716077
|
||||
@@ -0,0 +1,124 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using UnityEditor;
|
||||
using UnityEditor.IMGUI.Controls;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Borodar.RainbowHierarchy
|
||||
{
|
||||
[InitializeOnLoad]
|
||||
public static class HierarchyWindowAdapter
|
||||
{
|
||||
private const string EDITOR_WINDOW_TYPE = "UnityEditor.SceneHierarchyWindow";
|
||||
private const double EDITOR_WINDOWS_CACHE_TTL = 2;
|
||||
|
||||
private const BindingFlags INSTANCE_PRIVATE = BindingFlags.Instance | BindingFlags.NonPublic;
|
||||
private const BindingFlags INSTANCE_PUBLIC = BindingFlags.Instance | BindingFlags.Public;
|
||||
|
||||
private static readonly FieldInfo SCENE_HIERARCHY_FIELD;
|
||||
private static readonly FieldInfo TREE_VIEW_FIELD;
|
||||
private static readonly PropertyInfo TREE_VIEW_DATA_PROPERTY;
|
||||
private static readonly MethodInfo TREE_VIEW_ITEMS_METHOD;
|
||||
private static readonly PropertyInfo TREE_VIEW_OBJECT_PROPERTY;
|
||||
|
||||
// Windows cache
|
||||
private static double _nextWindowsUpdate;
|
||||
private static EditorWindow[] _windowsCache;
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// Ctor
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
static HierarchyWindowAdapter()
|
||||
{
|
||||
// Reflection
|
||||
|
||||
var assembly = Assembly.GetAssembly(typeof(EditorWindow));
|
||||
|
||||
var hierarchyWindowType = assembly.GetType("UnityEditor.SceneHierarchyWindow");
|
||||
SCENE_HIERARCHY_FIELD = hierarchyWindowType.GetField("m_SceneHierarchy", INSTANCE_PRIVATE);
|
||||
|
||||
var sceneHierarchyType = assembly.GetType("UnityEditor.SceneHierarchy");
|
||||
TREE_VIEW_FIELD = sceneHierarchyType.GetField("m_TreeView", INSTANCE_PRIVATE);
|
||||
|
||||
var treeViewType = assembly.GetType("UnityEditor.IMGUI.Controls.TreeViewController");
|
||||
TREE_VIEW_DATA_PROPERTY = treeViewType.GetProperty("data", INSTANCE_PUBLIC);
|
||||
|
||||
var treeViewDataType = assembly.GetType("UnityEditor.GameObjectTreeViewDataSource");
|
||||
TREE_VIEW_ITEMS_METHOD = treeViewDataType.GetMethod("GetRows", INSTANCE_PUBLIC);
|
||||
|
||||
var treeViewItem = assembly.GetType("UnityEditor.GameObjectTreeViewItem");
|
||||
TREE_VIEW_OBJECT_PROPERTY = treeViewItem.GetProperty("objectPPTR", INSTANCE_PUBLIC);
|
||||
|
||||
// Callbacks
|
||||
|
||||
HierarchyRulesetV2.OnRulesetChangeCallback += ApplyDefaultIconsToAll;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// Public
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
public static EditorWindow GetFirstHierarchyWindow()
|
||||
{
|
||||
return GetAllHierarchyWindows().FirstOrDefault();
|
||||
}
|
||||
|
||||
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||
[SuppressMessage("ReSharper", "InvertIf")]
|
||||
public static IEnumerable<EditorWindow> GetAllHierarchyWindows(bool forceUpdate = false)
|
||||
{
|
||||
if (forceUpdate || _nextWindowsUpdate < EditorApplication.timeSinceStartup)
|
||||
{
|
||||
_nextWindowsUpdate = EditorApplication.timeSinceStartup + EDITOR_WINDOWS_CACHE_TTL;
|
||||
_windowsCache = HierarchyEditorUtility.GetAllWindowsByType(EDITOR_WINDOW_TYPE).ToArray();
|
||||
}
|
||||
|
||||
return _windowsCache;
|
||||
}
|
||||
|
||||
public static void ApplyIconByInstanceId(int instanceId, Texture2D icon)
|
||||
{
|
||||
var hierarchyWindows = GetAllHierarchyWindows();
|
||||
|
||||
foreach (var window in hierarchyWindows)
|
||||
{
|
||||
var treeViewItems = GetTreeViewItems(window);
|
||||
var treeViewItem = treeViewItems.FirstOrDefault(item => item.id == instanceId);
|
||||
if (treeViewItem != null) treeViewItem.icon = icon;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// Helpers
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
private static IEnumerable<TreeViewItem> GetTreeViewItems(EditorWindow window)
|
||||
{
|
||||
var sceneHierarchy = SCENE_HIERARCHY_FIELD.GetValue(window);
|
||||
var treeView = TREE_VIEW_FIELD.GetValue(sceneHierarchy);
|
||||
var treeViewData = TREE_VIEW_DATA_PROPERTY.GetValue(treeView, null);
|
||||
var treeViewItems = (IEnumerable<TreeViewItem>) TREE_VIEW_ITEMS_METHOD.Invoke(treeViewData, null);
|
||||
|
||||
return treeViewItems;
|
||||
}
|
||||
|
||||
private static void ApplyDefaultIconsToAll()
|
||||
{
|
||||
var hierarchyWindows = GetAllHierarchyWindows(true);
|
||||
foreach (var window in hierarchyWindows)
|
||||
{
|
||||
var treeViewItems = GetTreeViewItems(window);
|
||||
foreach (var item in treeViewItems)
|
||||
{
|
||||
var gameObject = TREE_VIEW_OBJECT_PROPERTY.GetValue(item, null);
|
||||
if (gameObject == null) continue;
|
||||
item.icon = PrefabUtility.GetIconForGameObject((GameObject) gameObject);
|
||||
}
|
||||
}
|
||||
EditorApplication.RepaintHierarchyWindow();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f23b31e6bba538a4cae0907091949e50
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 106670
|
||||
packageName: Rainbow Hierarchy 2
|
||||
packageVersion: 2.6.2
|
||||
assetPath: Assets/Plugins/Borodar/RainbowHierarchy/Scripts/Editor/Helpers/HierarchyWindowAdapter.cs
|
||||
uploadId: 716077
|
||||
@@ -0,0 +1,24 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Borodar.RainbowHierarchy
|
||||
{
|
||||
internal static class RHLogger
|
||||
{
|
||||
private const string TAG = "<b>[RH]</b>";
|
||||
|
||||
public static void Log(string message)
|
||||
{
|
||||
Debug.Log($"{TAG} {message}");
|
||||
}
|
||||
|
||||
public static void LogWarning(string message)
|
||||
{
|
||||
Debug.LogWarning($"{TAG} {message}");
|
||||
}
|
||||
|
||||
public static void LogError(string message)
|
||||
{
|
||||
Debug.LogError($"{TAG} {message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7f02ac93f4c0323408795cc555a9241b
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 106670
|
||||
packageName: Rainbow Hierarchy 2
|
||||
packageVersion: 2.6.2
|
||||
assetPath: Assets/Plugins/Borodar/RainbowHierarchy/Scripts/Editor/Helpers/RHLogger.cs
|
||||
uploadId: 716077
|
||||
Reference in New Issue
Block a user