77using UnityEditor ;
88using UnityEditor . IMGUI . Controls ;
99using UnityEngine ;
10- using UnityEngine . Experimental . Rendering ;
1110using UnityHierarchyFolders . Runtime ;
1211using Object = UnityEngine . Object ;
1312
@@ -74,46 +73,6 @@ private static void Startup()
7473 EditorApplication . hierarchyWindowItemOnGUI += RefreshFolderIcons ;
7574 }
7675
77- private static Texture2D GetTintedTexture ( Texture2D original , Color tint , string name )
78- {
79- var material = new Material ( Shader . Find ( "UI/Default" ) ) { color = tint } ;
80- return GetTextureWithMaterial ( original , material , name ) ;
81- }
82-
83- private static Texture2D GetWhiteTexture ( Texture2D original , string name )
84- {
85- var material = new Material ( Shader . Find ( "UI/Replace color" ) ) { color = Color . white } ;
86- return GetTextureWithMaterial ( original , material , name ) ;
87- }
88-
89- private static Texture2D GetTextureWithMaterial ( Texture2D original , Material material , string name )
90- {
91- Texture2D newTexture ;
92-
93- using ( new TextureHelper . SRGBWriteScope ( true ) )
94- {
95- using ( var temporary = new TextureHelper . TemporaryActiveTexture ( original . width , original . height , 0 ) )
96- {
97- GL . Clear ( false , true , new Color ( 1f , 1f , 1f , 0f ) ) ;
98-
99- Graphics . Blit ( original , temporary , material ) ;
100-
101- newTexture = new Texture2D ( original . width , original . width , TextureFormat . ARGB32 , false , true )
102- {
103- name = name ,
104- filterMode = FilterMode . Bilinear ,
105- hideFlags = HideFlags . DontSave
106- } ;
107-
108- newTexture . ReadPixels ( new Rect ( 0.0f , 0.0f , original . width , original . width ) , 0 , 0 ) ;
109- newTexture . alphaIsTransparency = true ;
110- newTexture . Apply ( ) ;
111- }
112- }
113-
114- return newTexture ;
115- }
116-
11776 private static void InitIfNeeded ( )
11877 {
11978 if ( _isInitialized ) { return ; }
@@ -124,8 +83,8 @@ private static void InitIfNeeded()
12483 // We could use the actual white folder icons but I prefer the look of the tinted white folder icon
12584 // To use the actual white version:
12685 // texture = (Texture2D) EditorGUIUtility.IconContent($"{OpenedFolderPrefix | ClosedFolderPrefix} On Icon").image;
127- _openFolderSelectedTexture = GetWhiteTexture ( _openFolderTexture , $ "{ _openedFolderPrefix } Icon White") ;
128- _closedFolderSelectedTexture = GetWhiteTexture ( _closedFolderTexture , $ "{ _closedFolderPrefix } Icon White") ;
86+ _openFolderSelectedTexture = TextureHelper . GetWhiteTexture ( _openFolderTexture , $ "{ _openedFolderPrefix } Icon White") ;
87+ _closedFolderSelectedTexture = TextureHelper . GetWhiteTexture ( _closedFolderTexture , $ "{ _closedFolderPrefix } Icon White") ;
12988
13089 _coloredFolderIcons = new ( Texture2D , Texture2D ) [ ] { ( _openFolderTexture , _closedFolderTexture ) } ;
13190
@@ -136,9 +95,9 @@ private static void InitIfNeeded()
13695 int index = 1 + column + row * IconColumnCount ;
13796 var color = IconColors [ column , row ] ;
13897
139- var openFolderIcon = GetTintedTexture ( _openFolderSelectedTexture ,
98+ var openFolderIcon = TextureHelper . GetTintedTexture ( _openFolderSelectedTexture ,
14099 color , $ "{ _openFolderSelectedTexture . name } { index } ") ;
141- var closedFolderIcon = GetTintedTexture ( _closedFolderSelectedTexture ,
100+ var closedFolderIcon = TextureHelper . GetTintedTexture ( _closedFolderSelectedTexture ,
142101 color , $ "{ _closedFolderSelectedTexture . name } { index } ") ;
143102
144103 ArrayUtility . Add ( ref _coloredFolderIcons , ( openFolderIcon , closedFolderIcon ) ) ;
0 commit comments