@@ -153,6 +153,42 @@ void InstallSample(string sampleName)
153153
154154 private static readonly ProfilerMarker AddGroupsMarker = new ProfilerMarker ( "AddGroups" ) ;
155155 private static readonly ProfilerMarker AddStickyNotesMarker = new ProfilerMarker ( "AddStickyNotes" ) ;
156+
157+ static GUIContent saveIcon ;
158+ static GUIContent SaveIcon =>
159+ saveIcon ??= new GUIContent ( EditorGUIUtility . IconContent ( "SaveActive" ) . image , "Save" ) ;
160+
161+ static GUIContent dropdownIcon ;
162+ static GUIContent DropdownIcon =>
163+ dropdownIcon ??= EditorGUIUtility . IconContent ( "Dropdown" ) ;
164+
165+ static GUIContent blackboardIcon ;
166+ static GUIContent BlackboardIcon
167+ {
168+ get
169+ {
170+ if ( blackboardIcon == null )
171+ {
172+ var suffix = ( EditorGUIUtility . isProSkin ? "_dark" : "" ) + ( EditorGUIUtility . pixelsPerPoint >= 2 ? "@2x" : "" ) ;
173+ var path = $ "Icons/blackboard{ suffix } ";
174+ blackboardIcon = new GUIContent ( Resources . Load < Texture2D > ( path ) , "Blackboard" ) ;
175+ }
176+ return blackboardIcon ;
177+ }
178+ }
179+
180+ static GUIContent inspectorIcon ;
181+ static GUIContent InspectorIcon =>
182+ inspectorIcon ??= new GUIContent ( EditorGUIUtility . IconContent ( "UnityEditor.InspectorWindow" ) . image , "Graph Inspector" ) ;
183+
184+ static GUIContent previewIcon ;
185+ static GUIContent PreviewIcon =>
186+ previewIcon ??= new GUIContent ( EditorGUIUtility . IconContent ( "PreMatSphere" ) . image , "Main Preview" ) ;
187+
188+ static GUIContent helpIcon ;
189+ static GUIContent HelpIcon =>
190+ helpIcon ??= new GUIContent ( EditorGUIUtility . IconContent ( "_Help" ) . image , "Open Shader Graph User Manual" ) ;
191+
156192 public GraphEditorView ( EditorWindow editorWindow , GraphData graph , MessageManager messageManager , string graphName )
157193 {
158194 m_GraphViewGroupTitleChanged = OnGroupTitleChanged ;
@@ -172,7 +208,6 @@ public GraphEditorView(EditorWindow editorWindow, GraphData graph, MessageManage
172208 m_UserViewSettings = JsonUtility . FromJson < UserViewSettings > ( serializedSettings ) ?? new UserViewSettings ( ) ;
173209 m_ColorManager = new ColorManager ( m_UserViewSettings . colorProvider ) ;
174210
175-
176211 List < IShaderGraphToolbarExtension > toolbarExtensions = new ( ) ;
177212 foreach ( var type in TypeCache . GetTypesDerivedFrom ( typeof ( IShaderGraphToolbarExtension ) ) . Where ( e => ! e . IsGenericType ) )
178213 {
@@ -183,12 +218,12 @@ public GraphEditorView(EditorWindow editorWindow, GraphData graph, MessageManage
183218 var toolbar = new IMGUIContainer ( ( ) =>
184219 {
185220 GUILayout . BeginHorizontal ( EditorStyles . toolbar ) ;
186- if ( GUILayout . Button ( new GUIContent ( EditorGUIUtility . FindTexture ( "SaveActive" ) , "Save" ) , EditorStyles . toolbarButton ) )
221+ if ( GUILayout . Button ( SaveIcon , EditorStyles . toolbarButton ) )
187222 {
188223 if ( saveRequested != null )
189224 saveRequested ( ) ;
190225 }
191- if ( GUILayout . Button ( EditorResources . Load < Texture > ( "d_dropdown" ) , EditorStyles . toolbarButton ) )
226+ if ( GUILayout . Button ( DropdownIcon , EditorStyles . toolbarButton ) )
192227 {
193228 GenericMenu menu = new GenericMenu ( ) ;
194229 menu . AddItem ( new GUIContent ( "Save As..." ) , false , ( ) => saveAsRequested ( ) ) ;
@@ -218,22 +253,22 @@ public GraphEditorView(EditorWindow editorWindow, GraphData graph, MessageManage
218253 GUILayout . Label ( "Color Mode" ) ;
219254 var newColorIndex = EditorGUILayout . Popup ( m_ColorManager . activeIndex , colorProviders , GUILayout . Width ( 100f ) ) ;
220255 GUILayout . Space ( 4 ) ;
221- m_UserViewSettings . isBlackboardVisible = GUILayout . Toggle ( m_UserViewSettings . isBlackboardVisible , new GUIContent ( Resources . Load < Texture2D > ( "Icons/blackboard" ) , "Blackboard" ) , EditorStyles . toolbarButton ) ;
256+
257+ m_UserViewSettings . isBlackboardVisible = GUILayout . Toggle ( m_UserViewSettings . isBlackboardVisible , BlackboardIcon , EditorStyles . toolbarButton ) ;
222258
223259 GUILayout . Space ( 6 ) ;
224260
225- m_UserViewSettings . isInspectorVisible = GUILayout . Toggle ( m_UserViewSettings . isInspectorVisible , new GUIContent ( EditorGUIUtility . TrIconContent ( "d_UnityEditor.InspectorWindow" ) . image , "Graph Inspector" ) , EditorStyles . toolbarButton ) ;
261+ m_UserViewSettings . isInspectorVisible = GUILayout . Toggle ( m_UserViewSettings . isInspectorVisible , InspectorIcon , EditorStyles . toolbarButton ) ;
226262
227263 GUILayout . Space ( 6 ) ;
228264
229- m_UserViewSettings . isPreviewVisible = GUILayout . Toggle ( m_UserViewSettings . isPreviewVisible , new GUIContent ( EditorGUIUtility . FindTexture ( "PreMatSphere" ) , "Main Preview" ) , EditorStyles . toolbarButton ) ;
265+ m_UserViewSettings . isPreviewVisible = GUILayout . Toggle ( m_UserViewSettings . isPreviewVisible , PreviewIcon , EditorStyles . toolbarButton ) ;
230266
231- if ( GUILayout . Button ( new GUIContent ( EditorGUIUtility . TrIconContent ( "_Help" ) . image , "Open Shader Graph User Manual" ) , EditorStyles . toolbarButton ) )
267+ if ( GUILayout . Button ( HelpIcon , EditorStyles . toolbarButton ) )
232268 {
233269 Application . OpenURL ( UnityEngine . Rendering . ShaderGraph . Documentation . GetPageLink ( "index" ) ) ;
234- //Application.OpenURL("https://docs.unity3d.com/Packages/[email protected] /manual/index.html"); // TODO : point to latest? 235270 }
236- if ( GUILayout . Button ( EditorResources . Load < Texture > ( "d_dropdown" ) , EditorStyles . toolbarButton ) )
271+ if ( GUILayout . Button ( DropdownIcon , EditorStyles . toolbarButton ) )
237272 {
238273 GenericMenu menu = new GenericMenu ( ) ;
239274 menu . AddItem ( new GUIContent ( "Shader Graph Samples" ) , false , ( ) =>
@@ -257,10 +292,6 @@ public GraphEditorView(EditorWindow editorWindow, GraphData graph, MessageManage
257292 {
258293 Application . OpenURL ( "https://forum.unity.com/forums/shader-graph.346/" ) ;
259294 } ) ;
260- menu . AddItem ( new GUIContent ( "Shader Graph Roadmap" ) , false , ( ) =>
261- {
262- Application . OpenURL ( "https://portal.productboard.com/unity/1-unity-platform-rendering-visual-effects/tabs/7-shader-graph" ) ;
263- } ) ;
264295 menu . ShowAsContext ( ) ;
265296 }
266297
0 commit comments