Initial commit

This commit is contained in:
HussienX72u
2026-07-21 08:56:10 +03:00
commit 4017028111
9410 changed files with 2150500 additions and 0 deletions
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 86c83c65fcdbfc144893224d7677edba
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,45 @@
using UnityEngine;
namespace CGHierarchyIconsEditor
{
internal static class TextureHelper
{
public static readonly Texture2D NO_ICON = Load(NoIconBytes);
public static readonly Texture2D BUTTON_ON = Load(ButtonOnBytes);
public static readonly Texture2D CLEAR_SEARCH = Load(ClearSearchBytes);
public static readonly Texture2D REMOVE_ICON = Load(RemoveIconBytes);
static Texture2D Load(byte[] bytes)
{
Texture2D texture = new Texture2D(1, 1, TextureFormat.ARGB32, false);
texture.hideFlags = HideFlags.HideAndDontSave;
texture.LoadImage(bytes, true);
return texture;
}
#region TEXTURE BYTES
static byte[] ButtonOnBytes
{
get { return new byte[] {137, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13, 73, 72, 68, 82, 0, 0, 0, 2, 0, 0, 0, 2, 8, 2, 0, 0, 0, 253, 212, 154, 115, 0, 0, 0, 19, 73, 68, 65, 84, 8, 29, 99, 180, 171, 125, 206, 192, 192, 192, 4, 196, 64, 0, 0, 19, 25, 1, 166, 188, 203, 191, 138, 0, 0, 0, 0, 73, 69, 78, 68, 174, 66, 96, 130}; }
}
static byte[] NoIconBytes
{
get { return new byte[] {137, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13, 73, 72, 68, 82, 0, 0, 0, 16, 0, 0, 0, 16, 8, 6, 0, 0, 0, 31, 243, 255, 97, 0, 0, 2, 24, 73, 68, 65, 84, 56, 17, 133, 147, 93, 104, 141, 97, 28, 192, 127, 59, 239, 206, 216, 230, 107, 67, 171, 83, 139, 19, 133, 104, 156, 181, 220, 156, 88, 67, 169, 133, 41, 69, 73, 228, 163, 220, 184, 65, 41, 110, 92, 184, 90, 114, 225, 198, 40, 23, 148, 90, 185, 83, 106, 74, 145, 152, 175, 204, 87, 81, 83, 98, 109, 62, 98, 148, 89, 107, 200, 248, 61, 239, 57, 111, 142, 83, 242, 175, 223, 251, 127, 190, 254, 159, 207, 251, 84, 164, 248, 91, 158, 57, 221, 47, 159, 229, 158, 44, 149, 211, 50, 93, 206, 75, 185, 148, 219, 151, 239, 255, 119, 94, 238, 160, 66, 139, 195, 178, 76, 170, 101, 159, 76, 147, 127, 74, 106, 194, 173, 18, 42, 127, 193, 150, 163, 112, 112, 6, 212, 189, 133, 181, 153, 130, 163, 70, 143, 181, 74, 85, 185, 167, 40, 114, 37, 164, 81, 164, 122, 29, 228, 179, 208, 92, 239, 225, 73, 80, 27, 106, 159, 11, 7, 174, 65, 102, 141, 14, 247, 66, 207, 93, 215, 18, 82, 33, 231, 18, 194, 124, 228, 24, 156, 92, 13, 187, 103, 195, 156, 22, 200, 217, 204, 190, 46, 56, 158, 134, 38, 143, 155, 220, 31, 41, 239, 65, 40, 56, 186, 9, 87, 59, 225, 220, 84, 152, 117, 65, 227, 121, 176, 224, 132, 151, 243, 18, 94, 252, 128, 49, 33, 1, 83, 142, 41, 102, 81, 101, 161, 57, 13, 107, 38, 67, 125, 155, 117, 215, 216, 196, 44, 180, 180, 67, 71, 4, 13, 66, 41, 149, 73, 50, 122, 15, 142, 190, 171, 30, 21, 215, 198, 212, 55, 138, 227, 7, 234, 0, 71, 36, 116, 242, 74, 152, 40, 137, 3, 131, 50, 83, 222, 172, 52, 187, 14, 7, 193, 58, 72, 200, 112, 68, 174, 203, 99, 185, 40, 165, 146, 10, 145, 37, 99, 147, 242, 227, 133, 43, 179, 249, 44, 18, 171, 136, 3, 216, 130, 56, 104, 168, 50, 4, 108, 144, 240, 143, 196, 18, 45, 86, 213, 106, 176, 81, 7, 195, 48, 124, 8, 78, 121, 178, 117, 20, 62, 230, 97, 207, 79, 104, 247, 38, 150, 27, 253, 235, 54, 232, 90, 8, 155, 27, 97, 73, 15, 60, 213, 116, 52, 21, 92, 73, 109, 157, 77, 91, 5, 27, 94, 65, 90, 7, 155, 238, 23, 116, 243, 86, 216, 101, 9, 243, 219, 96, 125, 175, 149, 237, 128, 51, 154, 52, 77, 209, 137, 144, 74, 126, 34, 179, 72, 223, 134, 39, 94, 114, 88, 218, 185, 194, 102, 235, 104, 252, 44, 108, 247, 167, 138, 250, 225, 189, 27, 175, 63, 65, 191, 181, 77, 56, 142, 194, 193, 232, 155, 159, 15, 54, 110, 0, 134, 46, 67, 111, 31, 12, 104, 144, 187, 228, 184, 27, 238, 100, 125, 144, 157, 208, 125, 203, 199, 233, 185, 119, 190, 214, 161, 65, 24, 124, 8, 207, 157, 127, 209, 60, 150, 228, 106, 13, 26, 95, 115, 120, 64, 161, 97, 33, 72, 156, 169, 58, 217, 11, 103, 195, 94, 208, 252, 6, 80, 219, 116, 25, 64, 124, 234, 141, 0, 0, 0, 0, 73, 69, 78, 68, 174, 66, 96, 130}; }
}
static byte[] ClearSearchBytes
{
get { return new byte[] {137, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13, 73, 72, 68, 82, 0, 0, 0, 13, 0, 0, 0, 13, 8, 6, 0, 0, 0, 114, 235, 228, 124, 0, 0, 1, 47, 73, 68, 65, 84, 40, 21, 117, 82, 65, 106, 131, 80, 16, 213, 6, 68, 76, 64, 107, 19, 8, 93, 202, 63, 64, 54, 122, 0, 169, 123, 215, 61, 64, 47, 208, 43, 148, 120, 6, 247, 186, 17, 247, 133, 8, 57, 129, 71, 8, 89, 184, 10, 72, 136, 171, 46, 74, 193, 190, 247, 243, 5, 73, 226, 192, 115, 254, 188, 121, 51, 127, 230, 163, 174, 93, 77, 192, 61, 3, 142, 138, 31, 185, 14, 228, 5, 56, 60, 225, 35, 194, 48, 124, 45, 138, 66, 239, 251, 190, 157, 2, 243, 212, 81, 15, 104, 62, 136, 0, 226, 197, 64, 224, 172, 13, 160, 0, 38, 152, 167, 14, 103, 159, 68, 4, 98, 3, 239, 218, 182, 189, 133, 103, 98, 108, 129, 226, 93, 165, 139, 56, 158, 52, 16, 63, 101, 89, 238, 45, 203, 250, 2, 49, 20, 6, 140, 201, 51, 175, 164, 210, 201, 155, 64, 114, 36, 179, 174, 235, 119, 8, 119, 44, 164, 103, 76, 94, 229, 57, 81, 196, 170, 113, 145, 44, 76, 146, 228, 147, 5, 244, 163, 2, 230, 238, 139, 216, 1, 38, 88, 144, 231, 249, 135, 186, 81, 190, 214, 195, 155, 174, 122, 77, 24, 134, 241, 173, 70, 178, 233, 25, 179, 17, 243, 119, 55, 129, 147, 175, 119, 179, 131, 220, 241, 246, 245, 216, 192, 207, 178, 204, 71, 151, 85, 85, 85, 111, 240, 195, 210, 236, 44, 119, 84, 252, 138, 58, 234, 103, 248, 152, 109, 219, 46, 49, 198, 60, 142, 227, 95, 196, 252, 157, 214, 35, 44, 61, 207, 251, 195, 142, 78, 154, 166, 86, 211, 52, 39, 29, 73, 154, 7, 188, 0, 14, 131, 9, 235, 192, 159, 129, 227, 63, 69, 197, 241, 197, 126, 216, 78, 194, 0, 0, 0, 0, 73, 69, 78, 68, 174, 66, 96, 130}; }
}
static byte[] RemoveIconBytes
{
get { return new byte[] {137, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13, 73, 72, 68, 82, 0, 0, 0, 9, 0, 0, 0, 9, 8, 6, 0, 0, 0, 224, 145, 6, 16, 0, 0, 0, 111, 73, 68, 65, 84, 24, 25, 93, 143, 209, 13, 128, 48, 8, 68, 169, 113, 60, 117, 11, 117, 36, 63, 220, 162, 14, 229, 26, 189, 87, 133, 52, 92, 114, 133, 192, 11, 208, 114, 153, 85, 51, 187, 229, 71, 206, 90, 85, 168, 179, 158, 141, 228, 239, 142, 96, 7, 84, 47, 64, 40, 131, 1, 208, 116, 40, 131, 76, 46, 20, 209, 244, 133, 120, 185, 13, 224, 140, 138, 146, 17, 98, 197, 46, 51, 97, 145, 15, 185, 203, 33, 7, 184, 13, 17, 3, 228, 166, 12, 0, 33, 255, 204, 11, 196, 10, 159, 64, 115, 84, 7, 27, 132, 23, 20, 126, 163, 174, 246, 6, 0, 0, 0, 0, 73, 69, 78, 68, 174, 66, 96, 130}; }
}
#endregion
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 3aaac47a537340843a1d85cf4774c7dd
timeCreated: 1519027026
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,12 @@
{
"name": "HierarchyIconsEditor",
"references": [
"HierarchyIcons"
],
"optionalUnityReferences": [],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false
}
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: effacf331d64ef64c83f1b4e2312f212
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: fc907af72a34a6741809816222a956fa
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,113 @@
using HierarchyIcons;
using UnityEngine;
using UnityEditor;
namespace CGHierarchyIconsEditor
{
[CanEditMultipleObjects]
[CustomEditor(typeof(HierarchyIcon))]
public class HierarchyIconEditor : Editor
{
SerializedProperty m_iconProperty;
SerializedProperty m_tooltipProperty;
SerializedProperty m_positionProperty;
SerializedProperty m_directionProperty;
HierarchyIcon m_hierarchyIcon;
const float ICON_BUTTON_SIZE = 28;
void OnEnable()
{
m_iconProperty = serializedObject.FindProperty("icon");
m_tooltipProperty = serializedObject.FindProperty("tooltip");
m_positionProperty = serializedObject.FindProperty("position");
m_directionProperty = serializedObject.FindProperty("direction");
m_hierarchyIcon = target as HierarchyIcon;
}
public override void OnInspectorGUI()
{
#region DRAW SCRIPT HEADER
GUI.enabled = false;
DrawPropertiesExcluding(
serializedObject,
m_iconProperty.name,
m_tooltipProperty.name,
m_positionProperty.name,
m_directionProperty.name
);
GUI.enabled = true;
#endregion
// Update the serializedProperty - always do this in the beginning of OnInspectorGUI.
serializedObject.Update();
#region PICK ICON BUTTON
EditorGUILayout.BeginHorizontal();
{
EditorGUILayout.PrefixLabel("Icon");
Rect btnRect = EditorGUILayout.GetControlRect(GUILayout.Width(ICON_BUTTON_SIZE), GUILayout.Height(ICON_BUTTON_SIZE));
GUIContent btnContent = new GUIContent();
// if selected multiple game objects show a _ character
if (m_iconProperty.hasMultipleDifferentValues)
{
btnContent.text = "_";
btnContent.tooltip = "Different values on selection";
}
else
{
// show the selected icon
btnContent.image = m_hierarchyIcon.icon;
}
if (GUI.Button(btnRect, btnContent))
PopupWindow.Show(btnRect, new PickIconWindow(m_iconProperty));
}
EditorGUILayout.EndHorizontal();
#endregion
#region POSITION
EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField(m_positionProperty);
if (EditorGUI.EndChangeCheck())
{
// repaint the hierarchy
EditorApplication.RepaintHierarchyWindow();
}
#endregion
#region DIRECTION
EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField(m_directionProperty);
if (EditorGUI.EndChangeCheck())
{
// repaint the hierarchy
EditorApplication.RepaintHierarchyWindow();
}
#endregion
#region TOOLTIP
EditorGUILayout.PropertyField(m_tooltipProperty);
#endregion
// Apply changes to the serializedProperty - always do this in the end of OnInspectorGUI.
serializedObject.ApplyModifiedProperties();
// space at the bottom
GUILayout.Space(5);
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: c0f001d5f6bf9374fb393d140eef3727
timeCreated: 1519023853
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: ef1be50a405732a42b3a48997126cd0b
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using HierarchyIcons;
using UnityEditor;
using UnityEditor.Callbacks;
using UnityEngine;
using UnityEngine.SceneManagement;
// https://forum.unity.com/threads/excluding-certain-monobehaviour-classes-from-build.568090/#post-3779695
public class DestroyInstancesOnBuild : MonoBehaviour
{
[PostProcessScene]
public static void DeleteObjects()
{
if (BuildPipeline.isBuildingPlayer)
{
Type type = typeof(HierarchyIcon);
Debug.Log("Destroying all instances of '" + type.Name + "' from scenes on build!");
foreach (Component obj in FindObjectsOfTypeAll(type, true))
DestroyImmediate(obj);
}
}
static List<Component> FindObjectsOfTypeAll(Type type, bool findInactive = false)
{
List<Component> results = new List<Component>();
for (int i = 0; i < SceneManager.sceneCount; i++)
{
Scene scene = SceneManager.GetSceneAt(i);
if (scene.isLoaded)
{
GameObject[] allGameObjects = scene.GetRootGameObjects();
for (int j = 0; j < allGameObjects.Length; j++)
{
GameObject go = allGameObjects[j];
results.AddRange(go.GetComponentsInChildren(type, findInactive));
}
}
}
return results;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e80715f9811a6ab449fc1b6403f5bf27
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,50 @@
using HierarchyIcons;
using UnityEngine;
using UnityEditor;
namespace CGHierarchyIconsEditor
{
[InitializeOnLoad]
public class ShowIconOnHierarchyView
{
const float MAX_ICON_SIZE = 16;
static ShowIconOnHierarchyView()
{
EditorApplication.hierarchyWindowItemOnGUI += HierarchyWindowItemCallback;
}
static void HierarchyWindowItemCallback(int instanceID, Rect selectionRect)
{
GameObject gameObject = EditorUtility.InstanceIDToObject(instanceID) as GameObject;
if (gameObject == null)
return;
HierarchyIcon[] hierarchyIcons = gameObject.GetComponents<HierarchyIcon>();
foreach (HierarchyIcon hierarchyIcon in hierarchyIcons)
{
Texture2D icon = hierarchyIcon.icon ? hierarchyIcon.icon : TextureHelper.NO_ICON;
float width = Mathf.Min(icon.width, MAX_ICON_SIZE);
float height = Mathf.Min(icon.height, MAX_ICON_SIZE);
// get the starting x position based on the direction
float x = selectionRect.x;
if (hierarchyIcon.direction == HierarchyIcon.Direction.LeftToRight)
x += hierarchyIcon.position * MAX_ICON_SIZE;
else
x += (selectionRect.width - width) - hierarchyIcon.position * MAX_ICON_SIZE;
// draw the icon
Rect rect = new Rect(x, selectionRect.y, width, height);
GUI.DrawTexture(rect, icon);
// set link cursor
EditorGUIUtility.AddCursorRect(rect, MouseCursor.Link);
// and draw a button for change the icon and display the tooltip
if (GUI.Button(rect, new GUIContent(string.Empty, hierarchyIcon.tooltip), EditorStyles.label))
PopupWindow.Show(rect, new PickIconWindow(hierarchyIcon));
}
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: f9de4623bd5b3274985a8f32e6007ff9
timeCreated: 1516518841
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 7c4d577218251034d86165460c287b49
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,312 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System.Reflection;
using System;
using HierarchyIcons;
namespace CGHierarchyIconsEditor
{
internal class PickIconWindow : PopupWindowContent
{
readonly SerializedProperty m_iconProperty;
Vector2 m_scrollPosition;
int m_myUndoGroup;
static GUIContent[] s_IconContents;
static readonly GUIStyle BUTTON_STYLE;
static string s_searchWord = "";
static bool s_loadAllIcons;
const int BUTTON_STYLE_PADDING = 2;
const float BUTTON_SIZE = 16 + BUTTON_STYLE_PADDING * 2;
const float COLUMNS = 12;
const int HEADER_HEIGHT = 22;
const int BODY_HEIGHT = 200;
const int BOTTOM_HEIGHT = 26;
static PickIconWindow()
{
BUTTON_STYLE = new GUIStyle
{
fixedWidth = BUTTON_SIZE,
fixedHeight = BUTTON_SIZE,
alignment = TextAnchor.MiddleCenter,
onNormal = {background = TextureHelper.BUTTON_ON},
padding = new RectOffset(
BUTTON_STYLE_PADDING,
BUTTON_STYLE_PADDING,
BUTTON_STYLE_PADDING,
BUTTON_STYLE_PADDING
)
};
}
public PickIconWindow(HierarchyIcon hierarchyIcon) : this(new SerializedObject(hierarchyIcon).FindProperty("icon"))
{
if (m_iconProperty == null)
Debug.LogError("'icon' property not found in the HierarchyIcon script.");
}
public PickIconWindow(SerializedProperty target)
{
LoadIcons(false);
m_iconProperty = target;
m_myUndoGroup = -1;
}
public override void OnGUI(Rect rect)
{
if (m_iconProperty == null) return;
// body - scroll view with a selection grid
{
float rows = Mathf.Ceil(s_IconContents.Length / COLUMNS);
float height = rows * BUTTON_SIZE;
// calculate rects
Rect rectScrollViewPosition = rect;
rectScrollViewPosition.y = HEADER_HEIGHT;
rectScrollViewPosition.height -= HEADER_HEIGHT + BOTTOM_HEIGHT;
Rect rectScrollView = new Rect(0, 0, rect.width - BUTTON_SIZE, height);
m_scrollPosition = GUI.BeginScrollView(rectScrollViewPosition, m_scrollPosition, rectScrollView, false, true);
{
const float X = 3;
Rect rectButtons = new Rect(X, 1, BUTTON_SIZE, BUTTON_SIZE);
int counter = 0; // used in the case we are searching
for (int i = 0; i < s_IconContents.Length; i++)
{
GUIContent content = s_IconContents[i];
if (!ContainsSearchWord(content.tooltip))
continue;
bool selected = (content.image == m_iconProperty.objectReferenceValue);
EditorGUI.BeginChangeCheck();
GUI.Toggle(rectButtons, selected, content, BUTTON_STYLE);
if (EditorGUI.EndChangeCheck())
AssignIconAndRecordUndo(i);
rectButtons.x += BUTTON_SIZE;
if ((counter + 1) % COLUMNS == 0)
{
rectButtons.y += BUTTON_SIZE;
rectButtons.x = X;
}
counter++;
}
}
GUI.EndScrollView();
}
// header
{
// search
{
GUI.Label(new Rect(3, 3, 50, 17), "Search:");
Rect rectCloseSearch = new Rect(167, 4, 16, 16);
// the button for clicking
if (GUI.Button(rectCloseSearch, "", EditorStyles.label))
s_searchWord = "";
s_searchWord = GUI.TextField(new Rect(53, 3, 130, 17), s_searchWord, EditorStyles.helpBox);
// the button graphic on top of the text field
if (s_searchWord != "")
GUI.Label(rectCloseSearch, new GUIContent(TextureHelper.CLEAR_SEARCH, "Clear Search"));
}
// none button
{
if (!m_iconProperty.objectReferenceValue) // disable the button if no icon
GUI.enabled = false;
GUIContent noneIconContent = new GUIContent("None", TextureHelper.REMOVE_ICON, "Remove Icon");
float width = EditorStyles.label.CalcSize(noneIconContent).x + 5;
if (GUI.Button(new Rect(rect.width - width, 4, width, HEADER_HEIGHT), noneIconContent, EditorStyles.label))
{
AssignIconAndRecordUndo(-1);
//editorWindow.Close();
}
GUI.enabled = true;
}
// horizontal line
DrawLineH(0, HEADER_HEIGHT, rect.width, Color.gray);
}
Event e = Event.current;
// other icon
{
// horizontal line
DrawLineH(0, rect.height - BOTTOM_HEIGHT, rect.width, Color.gray);
const float MARGIN_LEFT_AND_RIGHT = 50;
const float MARGIN_TOP_AND_BOTTOM = 3;
Rect rectButton = new Rect(
MARGIN_LEFT_AND_RIGHT,
rect.height - BOTTOM_HEIGHT + MARGIN_TOP_AND_BOTTOM,
rect.width - MARGIN_LEFT_AND_RIGHT * 2,
BOTTOM_HEIGHT - MARGIN_TOP_AND_BOTTOM * 2);
int controlID = GUIUtility.GetControlID("rectButtonOtherIcon***".GetHashCode(), FocusType.Keyboard, rectButton);
if (GUI.Button(rectButton, "Other..."))
{
GUIUtility.keyboardControl = controlID;
EditorGUIUtility.ShowObjectPicker<Texture2D>(m_iconProperty.objectReferenceValue, false, string.Empty, controlID);
}
// handle object picker commands
if (e.type == EventType.ExecuteCommand)
{
string commandName = e.commandName;
if (EditorGUIUtility.GetObjectPickerControlID() == controlID && GUIUtility.keyboardControl == controlID)
{
GUI.changed = true;
e.Use();
if (commandName == "ObjectSelectorUpdated")
{
Texture2D icon = EditorGUIUtility.GetObjectPickerObject() as Texture2D;
AssignIconAndRecordUndo(icon);
}
}
}
// toggle load all icons
{
const float W = 40, H = 17;
Rect r = new Rect(rect.width - W, rect.height - H - 3, W, H);
EditorGUI.BeginChangeCheck();
{
s_loadAllIcons = GUI.Toggle(r, s_loadAllIcons, new GUIContent("All", "Show all unity textures. Including yours in the project view."));
}
if (EditorGUI.EndChangeCheck())
LoadIcons(true);
}
}
// cancel with escape
if (e.type == EventType.KeyDown && e.keyCode == KeyCode.Escape)
editorWindow.Close();
}
static bool ContainsSearchWord(string name)
{
string searchWordLower = s_searchWord.Trim().ToLower();
if (name.ToLower().Contains(searchWordLower))
return true;
return false;
}
public static void DrawRect(Rect r, Color c)
{
GUI.color = c;
GUI.DrawTexture(r, EditorGUIUtility.whiteTexture);
GUI.color = Color.white;
}
public static void DrawLineH(float x, float y, float width, Color c)
{
DrawRect(new Rect(x, y, width, 1), c);
}
public override Vector2 GetWindowSize()
{
return new Vector2(
BUTTON_SIZE * COLUMNS + BUTTON_SIZE,
HEADER_HEIGHT + BODY_HEIGHT + BOTTOM_HEIGHT
);
}
void AssignIconAndRecordUndo(Texture2D newIcon)
{
if (m_iconProperty.objectReferenceValue != newIcon)
{
if (m_myUndoGroup == -1)
{
Undo.IncrementCurrentGroup();
m_myUndoGroup = Undo.GetCurrentGroup();
}
m_iconProperty.objectReferenceValue = newIcon;
m_iconProperty.serializedObject.ApplyModifiedProperties();
// repaint the hierarchy
EditorApplication.RepaintHierarchyWindow();
}
}
void AssignIconAndRecordUndo(int newBuiltinIconIndex)
{
AssignIconAndRecordUndo(GetIcon(newBuiltinIconIndex));
}
public override void OnClose()
{
Undo.CollapseUndoOperations(m_myUndoGroup);
}
static Texture2D GetIcon(int index)
{
LoadIcons(false);
if (index >= 0 && index < s_IconContents.Length)
return (Texture2D) s_IconContents[index].image;
return null;
}
static void LoadIcons(bool showAllChanged)
{
if (s_IconContents == null || showAllChanged)
{
LoadAssetPreviews();
List<GUIContent> listIcons = new List<GUIContent>();
// find all unity textures
Texture[] textures = Resources.FindObjectsOfTypeAll<Texture>();
Array.Sort(textures, (pA, pB) => string.Compare(pA.name, pB.name, StringComparison.OrdinalIgnoreCase));
string ICON_TEXT = "icon";
foreach (Texture texture in textures)
{
string name = texture.name;
if (name == string.Empty) continue;
if (!s_loadAllIcons && !name.ToLower().Contains(ICON_TEXT)) continue;
listIcons.Add(new GUIContent(texture, name));
}
s_IconContents = listIcons.ToArray();
}
}
/// <summary>
/// Load all assets preview so that we can find it
/// </summary>
static void LoadAssetPreviews()
{
foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
{
if (!assembly.FullName.StartsWith("UnityEngine")) // load only unity engine assemblies
continue;
foreach (Type type in assembly.GetTypes())
AssetPreview.GetMiniTypeThumbnail(type);
}
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: dbacac9f543a9704c88d5ca00050213c
timeCreated: 1519023455
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: