Esempio n. 1
0
 public override void OnGUI()
 {
     enabled = EditorGUILayout.BeginToggleGroup("Materials", enabled);
     EditorGUI.indentLevel += 1;
     if (hasRun)
     {
         EditorGUILayout.LabelField(string.Format("{0:n0} Renderers", rendererCount));
         EditorGUILayout.LabelField(string.Format("{0:n0} Materials", materialCount));
         EditorGUILayout.LabelField(string.Format("{0:n0} Passes (minimum)", passCount));
         if (enabled)
         {
             EditorGUI.indentLevel += 1;
             foreach (var usage in usedMaterials)
             {
                 if (Selection.activeObject == usage.material)
                 {
                     GUI.backgroundColor = Color.HSVToRGB(0, 0, 0.6f);
                 }
                 else
                 {
                     GUI.backgroundColor = Color.white;
                 }
                 EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                 GUI.backgroundColor = Color.white;
                 EditorGUILayout.BeginHorizontal();
                 EditorGUILayout.LabelField(usage.material.name, EditorStyles.boldLabel);
                 if (GUILayout.Button("Highlight", EditorStyles.miniButton))
                 {
                     EditorGUIUtility.PingObject(usage.material);
                 }
                 if (GUILayout.Button("Find in Scene", EditorStyles.miniButton))
                 {
                     var searchPath = AssetDatabase.GetAssetPath(usage.material).Substring("Assets/".Length);
                     SceneStatsWindow.SetSearchFilter(string.Format("ref:\"{0}\"", searchPath), 0);
                 }
                 if (GUILayout.Button("Select", EditorStyles.miniButton))
                 {
                     EditorGUIUtility.PingObject(usage.material);
                     Selection.activeObject = usage.material;
                 }
                 EditorGUILayout.EndHorizontal();
                 EditorGUILayout.LabelField(string.Format("{0} ({1})", AssetDatabase.GetAssetPath(usage.material), usage.material.name), EditorStyles.miniLabel);
                 EditorGUILayout.LabelField(usage.material.shader.name, EditorStyles.miniBoldLabel);
                 EditorGUILayout.LabelField(AssetDatabase.GetAssetPath(usage.material.shader), EditorStyles.miniLabel);
                 EditorGUILayout.LabelField(string.Format("{0:n0} times, {1:n0} passes", usage.count, usage.material?.passCount ?? 0), EditorStyles.miniLabel);
                 EditorGUILayout.EndVertical();
             }
             EditorGUI.indentLevel -= 1;
         }
     }
     else
     {
         EditorGUILayout.LabelField("Not scanned yet.");
     }
     EditorGUI.indentLevel -= 1;
     EditorGUILayout.EndToggleGroup();
 }
Esempio n. 2
0
 public override void OnGUI()
 {
     enabled = EditorGUILayout.BeginToggleGroup("Meshes", enabled);
     EditorGUI.indentLevel += 1;
     if (hasRun)
     {
         EditorGUILayout.LabelField(string.Format("{0:n0} MeshFilters", filterCount));
         EditorGUILayout.LabelField(string.Format("{0:n0} Meshes", meshCount));
         EditorGUILayout.LabelField(string.Format("{0:n0} Triangles in Scene", triangleCount));
         if (enabled)
         {
             EditorGUI.indentLevel += 1;
             foreach (var usage in usedMeshes)
             {
                 if (Selection.activeObject == usage.mesh)
                 {
                     GUI.backgroundColor = Color.HSVToRGB(0, 0, 0.6f);
                 }
                 else
                 {
                     GUI.backgroundColor = Color.white;
                 }
                 EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                 GUI.backgroundColor = Color.white;
                 EditorGUILayout.BeginHorizontal();
                 EditorGUILayout.LabelField(usage.mesh.name, EditorStyles.boldLabel);
                 if (GUILayout.Button("Highlight", EditorStyles.miniButton))
                 {
                     EditorGUIUtility.PingObject(usage.mesh);
                 }
                 if (GUILayout.Button("Find in Scene", EditorStyles.miniButton))
                 {
                     var searchPath = AssetDatabase.GetAssetPath(usage.mesh).Substring("Assets/".Length);
                     SceneStatsWindow.SetSearchFilter(string.Format("ref:{0}:\"{1}\"", usage.mesh.GetInstanceID(), searchPath), 0);
                 }
                 if (GUILayout.Button("Select", EditorStyles.miniButton))
                 {
                     EditorGUIUtility.PingObject(usage.mesh);
                     Selection.activeObject = usage.mesh;
                 }
                 EditorGUILayout.EndHorizontal();
                 EditorGUILayout.LabelField(AssetDatabase.GetAssetPath(usage.mesh), EditorStyles.miniLabel);
                 EditorGUILayout.LabelField(string.Format("{0:n0} total triangles ({1:n0} triangles * {2:n0} usages)", usage.sceneTriangles, usage.triangleCount, usage.count), EditorStyles.miniLabel);
                 EditorGUILayout.EndVertical();
             }
             EditorGUI.indentLevel -= 1;
         }
     }
     else
     {
         EditorGUILayout.LabelField("Not scanned yet.");
     }
     EditorGUI.indentLevel -= 1;
     EditorGUILayout.EndToggleGroup();
 }
Esempio n. 3
0
        static void Init()
        {
            SceneStatsWindow window = GetWindow <SceneStatsWindow>(false, "Scene Stats", true);

            window.Show();
        }