From 3d86accbefbda1e91f18066b3ce8bf5f4e8f334e Mon Sep 17 00:00:00 2001 From: jafarovja Date: Tue, 21 Oct 2025 21:30:02 +0700 Subject: [PATCH 1/8] base structure --- MaterialDetails.cs | 22 +++++++ MaterialDetails.cs.meta | 3 + MeshDetails.cs | 18 ++++++ MeshDetails.cs.meta | 3 + MissingGraphic.cs | 7 +++ MissingGraphic.cs.meta | 3 + README => README.MD | 0 README.MD.meta | 7 +++ ResourceChecker.cs | 86 +------------------------- ResourceChecker.cs.meta | 11 ++++ TextureDetails.cs | 38 ++++++++++++ TextureDetails.cs.meta | 3 + handcircus.ResourceChecker.asmdef | 14 +++++ handcircus.ResourceChecker.asmdef.meta | 7 +++ 14 files changed, 138 insertions(+), 84 deletions(-) create mode 100644 MaterialDetails.cs create mode 100644 MaterialDetails.cs.meta create mode 100644 MeshDetails.cs create mode 100644 MeshDetails.cs.meta create mode 100644 MissingGraphic.cs create mode 100644 MissingGraphic.cs.meta rename README => README.MD (100%) create mode 100644 README.MD.meta create mode 100644 ResourceChecker.cs.meta create mode 100644 TextureDetails.cs create mode 100644 TextureDetails.cs.meta create mode 100644 handcircus.ResourceChecker.asmdef create mode 100644 handcircus.ResourceChecker.asmdef.meta diff --git a/MaterialDetails.cs b/MaterialDetails.cs new file mode 100644 index 0000000..b1b4702 --- /dev/null +++ b/MaterialDetails.cs @@ -0,0 +1,22 @@ +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.UI; + +public class MaterialDetails +{ + + public Material material; + + public List FoundInRenderers=new List(); + public List FoundInGraphics=new List(); + public bool instance; + public bool isgui; + public bool isSky; + + public MaterialDetails() + { + instance = false; + isgui = false; + isSky = false; + } +}; \ No newline at end of file diff --git a/MaterialDetails.cs.meta b/MaterialDetails.cs.meta new file mode 100644 index 0000000..339dbb2 --- /dev/null +++ b/MaterialDetails.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 36ec4c8520024ce2bc94bca2cf840ad9 +timeCreated: 1761056504 \ No newline at end of file diff --git a/MeshDetails.cs b/MeshDetails.cs new file mode 100644 index 0000000..7ba52a3 --- /dev/null +++ b/MeshDetails.cs @@ -0,0 +1,18 @@ +using System.Collections.Generic; +using UnityEngine; + +public class MeshDetails +{ + + public Mesh mesh; + + public List FoundInMeshFilters=new List(); + public List FoundInSkinnedMeshRenderer=new List(); + public List StaticBatchingEnabled =new List(); + public bool instance; + + public MeshDetails() + { + instance = false; + } +}; \ No newline at end of file diff --git a/MeshDetails.cs.meta b/MeshDetails.cs.meta new file mode 100644 index 0000000..94d7640 --- /dev/null +++ b/MeshDetails.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 5fde582a9b6744968d6607a4d3fb992e +timeCreated: 1761056491 \ No newline at end of file diff --git a/MissingGraphic.cs b/MissingGraphic.cs new file mode 100644 index 0000000..df2b4d1 --- /dev/null +++ b/MissingGraphic.cs @@ -0,0 +1,7 @@ +using UnityEngine; + +public class MissingGraphic{ + public Transform Object; + public string type; + public string name; +} \ No newline at end of file diff --git a/MissingGraphic.cs.meta b/MissingGraphic.cs.meta new file mode 100644 index 0000000..89da3b8 --- /dev/null +++ b/MissingGraphic.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 02ef9e2e57df4a3b865c9862fb152b43 +timeCreated: 1761056498 \ No newline at end of file diff --git a/README b/README.MD similarity index 100% rename from README rename to README.MD diff --git a/README.MD.meta b/README.MD.meta new file mode 100644 index 0000000..cf83a65 --- /dev/null +++ b/README.MD.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 41bb0841aa928d643b31615c09d8c044 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ResourceChecker.cs b/ResourceChecker.cs index aa692ee..f4bc80a 100755 --- a/ResourceChecker.cs +++ b/ResourceChecker.cs @@ -5,7 +5,6 @@ // This comes with no warranty, use at your own risk! // https://github.com/handcircus/Unity-Resource-Checker -using System; using System.Linq; using UnityEngine; using UnityEngine.UI; @@ -14,88 +13,8 @@ using System.Reflection; using Object = UnityEngine.Object; -public class TextureDetails : IEquatable +public class ResourceChecker : EditorWindow { - public bool isCubeMap; - public int memSizeKB; - public Texture texture; - public TextureFormat format; - public int mipMapCount; - public List FoundInMaterials=new List(); - public List FoundInRenderers=new List(); - public List FoundInAnimators = new List(); - public List FoundInScripts = new List(); - public List FoundInGraphics = new List(); - public List FoundInButtons = new List(); - public bool isSky; - public bool instance; - public bool isgui; - public TextureDetails() - { - - } - - public bool Equals(TextureDetails other) - { - return texture != null && other.texture != null && - texture.GetNativeTexturePtr() == other.texture.GetNativeTexturePtr(); - } - - public override int GetHashCode() - { - return (int)texture.GetNativeTexturePtr(); - } - - public override bool Equals(object obj) - { - return Equals(obj as TextureDetails); - } -}; - -public class MaterialDetails -{ - - public Material material; - - public List FoundInRenderers=new List(); - public List FoundInGraphics=new List(); - public bool instance; - public bool isgui; - public bool isSky; - - public MaterialDetails() - { - instance = false; - isgui = false; - isSky = false; - } -}; - -public class MeshDetails -{ - - public Mesh mesh; - - public List FoundInMeshFilters=new List(); - public List FoundInSkinnedMeshRenderer=new List(); - public List StaticBatchingEnabled =new List(); - public bool instance; - - public MeshDetails() - { - instance = false; - } -}; - -public class MissingGraphic{ - public Transform Object; - public string type; - public string name; -} - -public class ResourceChecker : EditorWindow { - - string[] inspectToolbarStrings = {"Textures", "Materials","Meshes"}; string[] inspectToolbarStrings2 = {"Textures", "Materials","Meshes", "Missing"}; @@ -1178,5 +1097,4 @@ private TextureDetails GetTextureDetail(Texture tTexture) return tTextureDetails; } - -} +} \ No newline at end of file diff --git a/ResourceChecker.cs.meta b/ResourceChecker.cs.meta new file mode 100644 index 0000000..e189b95 --- /dev/null +++ b/ResourceChecker.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c8d2f2408f99aae4e98df732ac787c4e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/TextureDetails.cs b/TextureDetails.cs new file mode 100644 index 0000000..8fd38ef --- /dev/null +++ b/TextureDetails.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using UnityEngine; +using Object = UnityEngine.Object; + +public class TextureDetails : IEquatable +{ + public bool isCubeMap; + public int memSizeKB; + public Texture texture; + public TextureFormat format; + public int mipMapCount; + public List FoundInMaterials = new List(); + public List FoundInRenderers = new List(); + public List FoundInAnimators = new List(); + public List FoundInScripts = new List(); + public List FoundInGraphics = new List(); + public List FoundInButtons = new List(); + public bool isSky; + public bool instance; + public bool isgui; + + public bool Equals(TextureDetails other) + { + return texture != null && other.texture != null && + texture.GetNativeTexturePtr() == other.texture.GetNativeTexturePtr(); + } + + public override int GetHashCode() + { + return (int)texture.GetNativeTexturePtr(); + } + + public override bool Equals(object obj) + { + return Equals(obj as TextureDetails); + } +} \ No newline at end of file diff --git a/TextureDetails.cs.meta b/TextureDetails.cs.meta new file mode 100644 index 0000000..bc620e7 --- /dev/null +++ b/TextureDetails.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: e728f70ab27d45faaa01fc9587ea8537 +timeCreated: 1761055309 \ No newline at end of file diff --git a/handcircus.ResourceChecker.asmdef b/handcircus.ResourceChecker.asmdef new file mode 100644 index 0000000..612b8f6 --- /dev/null +++ b/handcircus.ResourceChecker.asmdef @@ -0,0 +1,14 @@ +{ + "name": "handcircus.ResoourceChecker", + "rootNamespace": "handcircus.ResourceChecker", + "references": [], + "includePlatforms": [], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/handcircus.ResourceChecker.asmdef.meta b/handcircus.ResourceChecker.asmdef.meta new file mode 100644 index 0000000..f9f10d1 --- /dev/null +++ b/handcircus.ResourceChecker.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: c793e3c52fa7f0d4183718dc5c3c2469 +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: From e6bf1b340dccbf37e11b665e8043a30e4e8df8e1 Mon Sep 17 00:00:00 2001 From: jafarovja Date: Tue, 21 Oct 2025 21:33:56 +0700 Subject: [PATCH 2/8] sort components --- Components.meta | 8 ++++++++ MaterialDetails.cs => Components/MaterialDetails.cs | 0 .../MaterialDetails.cs.meta | 0 MeshDetails.cs => Components/MeshDetails.cs | 0 MeshDetails.cs.meta => Components/MeshDetails.cs.meta | 0 MissingGraphic.cs => Components/MissingGraphic.cs | 0 .../MissingGraphic.cs.meta | 0 TextureDetails.cs => Components/TextureDetails.cs | 0 .../TextureDetails.cs.meta | 0 9 files changed, 8 insertions(+) create mode 100644 Components.meta rename MaterialDetails.cs => Components/MaterialDetails.cs (100%) rename MaterialDetails.cs.meta => Components/MaterialDetails.cs.meta (100%) rename MeshDetails.cs => Components/MeshDetails.cs (100%) rename MeshDetails.cs.meta => Components/MeshDetails.cs.meta (100%) rename MissingGraphic.cs => Components/MissingGraphic.cs (100%) rename MissingGraphic.cs.meta => Components/MissingGraphic.cs.meta (100%) rename TextureDetails.cs => Components/TextureDetails.cs (100%) rename TextureDetails.cs.meta => Components/TextureDetails.cs.meta (100%) diff --git a/Components.meta b/Components.meta new file mode 100644 index 0000000..88cfd8a --- /dev/null +++ b/Components.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1e04f6a118a29b24493134e4c98b3776 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/MaterialDetails.cs b/Components/MaterialDetails.cs similarity index 100% rename from MaterialDetails.cs rename to Components/MaterialDetails.cs diff --git a/MaterialDetails.cs.meta b/Components/MaterialDetails.cs.meta similarity index 100% rename from MaterialDetails.cs.meta rename to Components/MaterialDetails.cs.meta diff --git a/MeshDetails.cs b/Components/MeshDetails.cs similarity index 100% rename from MeshDetails.cs rename to Components/MeshDetails.cs diff --git a/MeshDetails.cs.meta b/Components/MeshDetails.cs.meta similarity index 100% rename from MeshDetails.cs.meta rename to Components/MeshDetails.cs.meta diff --git a/MissingGraphic.cs b/Components/MissingGraphic.cs similarity index 100% rename from MissingGraphic.cs rename to Components/MissingGraphic.cs diff --git a/MissingGraphic.cs.meta b/Components/MissingGraphic.cs.meta similarity index 100% rename from MissingGraphic.cs.meta rename to Components/MissingGraphic.cs.meta diff --git a/TextureDetails.cs b/Components/TextureDetails.cs similarity index 100% rename from TextureDetails.cs rename to Components/TextureDetails.cs diff --git a/TextureDetails.cs.meta b/Components/TextureDetails.cs.meta similarity index 100% rename from TextureDetails.cs.meta rename to Components/TextureDetails.cs.meta From 9dd5e164dd4f0d08a4d1b62ca68c2ba859bb896a Mon Sep 17 00:00:00 2001 From: jafarovja Date: Tue, 21 Oct 2025 21:38:29 +0700 Subject: [PATCH 3/8] add namespaces --- Components/MaterialDetails.cs | 25 ++++++-------- Components/MeshDetails.cs | 21 +++++------- Components/MissingGraphic.cs | 12 ++++--- Components/TextureDetails.cs | 57 ++++++++++++++++--------------- ResourceChecker.cs | 3 ++ handcircus.ResourceChecker.asmdef | 2 +- 6 files changed, 61 insertions(+), 59 deletions(-) diff --git a/Components/MaterialDetails.cs b/Components/MaterialDetails.cs index b1b4702..ede36e0 100644 --- a/Components/MaterialDetails.cs +++ b/Components/MaterialDetails.cs @@ -2,21 +2,16 @@ using UnityEngine; using UnityEngine.UI; -public class MaterialDetails +namespace handcircus.ResourceCheck { - - public Material material; - - public List FoundInRenderers=new List(); - public List FoundInGraphics=new List(); - public bool instance; - public bool isgui; - public bool isSky; - - public MaterialDetails() + public class MaterialDetails { - instance = false; - isgui = false; - isSky = false; + public Material material; + + public List FoundInRenderers = new List(); + public List FoundInGraphics = new List(); + public bool instance = false; + public bool isgui = false; + public bool isSky = false; } -}; \ No newline at end of file +} \ No newline at end of file diff --git a/Components/MeshDetails.cs b/Components/MeshDetails.cs index 7ba52a3..e0ce6c7 100644 --- a/Components/MeshDetails.cs +++ b/Components/MeshDetails.cs @@ -1,18 +1,15 @@ using System.Collections.Generic; using UnityEngine; -public class MeshDetails +namespace handcircus.ResourceCheck { - - public Mesh mesh; - - public List FoundInMeshFilters=new List(); - public List FoundInSkinnedMeshRenderer=new List(); - public List StaticBatchingEnabled =new List(); - public bool instance; - - public MeshDetails() + public class MeshDetails { - instance = false; + public Mesh mesh; + + public List FoundInMeshFilters = new List(); + public List FoundInSkinnedMeshRenderer = new List(); + public List StaticBatchingEnabled = new List(); + public bool instance = false; } -}; \ No newline at end of file +} \ No newline at end of file diff --git a/Components/MissingGraphic.cs b/Components/MissingGraphic.cs index df2b4d1..a6a5177 100644 --- a/Components/MissingGraphic.cs +++ b/Components/MissingGraphic.cs @@ -1,7 +1,11 @@ using UnityEngine; -public class MissingGraphic{ - public Transform Object; - public string type; - public string name; +namespace handcircus.ResourceCheck +{ + public class MissingGraphic + { + public Transform Object; + public string type; + public string name; + } } \ No newline at end of file diff --git a/Components/TextureDetails.cs b/Components/TextureDetails.cs index 8fd38ef..867e5a7 100644 --- a/Components/TextureDetails.cs +++ b/Components/TextureDetails.cs @@ -3,36 +3,39 @@ using UnityEngine; using Object = UnityEngine.Object; -public class TextureDetails : IEquatable +namespace handcircus.ResourceCheck { - public bool isCubeMap; - public int memSizeKB; - public Texture texture; - public TextureFormat format; - public int mipMapCount; - public List FoundInMaterials = new List(); - public List FoundInRenderers = new List(); - public List FoundInAnimators = new List(); - public List FoundInScripts = new List(); - public List FoundInGraphics = new List(); - public List FoundInButtons = new List(); - public bool isSky; - public bool instance; - public bool isgui; - - public bool Equals(TextureDetails other) + public class TextureDetails : IEquatable { - return texture != null && other.texture != null && - texture.GetNativeTexturePtr() == other.texture.GetNativeTexturePtr(); - } + public bool isCubeMap; + public int memSizeKB; + public Texture texture; + public TextureFormat format; + public int mipMapCount; + public List FoundInMaterials = new List(); + public List FoundInRenderers = new List(); + public List FoundInAnimators = new List(); + public List FoundInScripts = new List(); + public List FoundInGraphics = new List(); + public List FoundInButtons = new List(); + public bool isSky; + public bool instance; + public bool isgui; - public override int GetHashCode() - { - return (int)texture.GetNativeTexturePtr(); - } + public bool Equals(TextureDetails other) + { + return texture != null && other.texture != null && + texture.GetNativeTexturePtr() == other.texture.GetNativeTexturePtr(); + } - public override bool Equals(object obj) - { - return Equals(obj as TextureDetails); + public override int GetHashCode() + { + return (int)texture.GetNativeTexturePtr(); + } + + public override bool Equals(object obj) + { + return Equals(obj as TextureDetails); + } } } \ No newline at end of file diff --git a/ResourceChecker.cs b/ResourceChecker.cs index f4bc80a..42b3831 100755 --- a/ResourceChecker.cs +++ b/ResourceChecker.cs @@ -13,6 +13,8 @@ using System.Reflection; using Object = UnityEngine.Object; +namespace handcircus.ResourceCheck +{ public class ResourceChecker : EditorWindow { string[] inspectToolbarStrings = {"Textures", "Materials","Meshes"}; @@ -1097,4 +1099,5 @@ private TextureDetails GetTextureDetail(Texture tTexture) return tTextureDetails; } +} } \ No newline at end of file diff --git a/handcircus.ResourceChecker.asmdef b/handcircus.ResourceChecker.asmdef index 612b8f6..146391a 100644 --- a/handcircus.ResourceChecker.asmdef +++ b/handcircus.ResourceChecker.asmdef @@ -1,6 +1,6 @@ { "name": "handcircus.ResoourceChecker", - "rootNamespace": "handcircus.ResourceChecker", + "rootNamespace": "handcircus.ResourceCheck", "references": [], "includePlatforms": [], "excludePlatforms": [], From 8680f4fac7c7f4eedf3e647d05506965d8b90287 Mon Sep 17 00:00:00 2001 From: jafarovja Date: Tue, 21 Oct 2025 21:41:00 +0700 Subject: [PATCH 4/8] make components internal --- Components/MaterialDetails.cs | 2 +- Components/MeshDetails.cs | 2 +- Components/MissingGraphic.cs | 2 +- Components/TextureDetails.cs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Components/MaterialDetails.cs b/Components/MaterialDetails.cs index ede36e0..4e66cfb 100644 --- a/Components/MaterialDetails.cs +++ b/Components/MaterialDetails.cs @@ -4,7 +4,7 @@ namespace handcircus.ResourceCheck { - public class MaterialDetails + internal class MaterialDetails { public Material material; diff --git a/Components/MeshDetails.cs b/Components/MeshDetails.cs index e0ce6c7..675ee4e 100644 --- a/Components/MeshDetails.cs +++ b/Components/MeshDetails.cs @@ -3,7 +3,7 @@ namespace handcircus.ResourceCheck { - public class MeshDetails + internal class MeshDetails { public Mesh mesh; diff --git a/Components/MissingGraphic.cs b/Components/MissingGraphic.cs index a6a5177..ec3b04c 100644 --- a/Components/MissingGraphic.cs +++ b/Components/MissingGraphic.cs @@ -2,7 +2,7 @@ namespace handcircus.ResourceCheck { - public class MissingGraphic + internal class MissingGraphic { public Transform Object; public string type; diff --git a/Components/TextureDetails.cs b/Components/TextureDetails.cs index 867e5a7..461e1ed 100644 --- a/Components/TextureDetails.cs +++ b/Components/TextureDetails.cs @@ -5,7 +5,7 @@ namespace handcircus.ResourceCheck { - public class TextureDetails : IEquatable + internal class TextureDetails : IEquatable { public bool isCubeMap; public int memSizeKB; From 6885653ed568657926aa4502590ecaca9def6701 Mon Sep 17 00:00:00 2001 From: jafarovja Date: Tue, 21 Oct 2025 22:47:26 +0700 Subject: [PATCH 5/8] spaces --- ResourceChecker.cs | 1734 ++++++++++++++++++++++---------------------- 1 file changed, 867 insertions(+), 867 deletions(-) diff --git a/ResourceChecker.cs b/ResourceChecker.cs index 42b3831..3786e8e 100755 --- a/ResourceChecker.cs +++ b/ResourceChecker.cs @@ -15,353 +15,287 @@ namespace handcircus.ResourceCheck { -public class ResourceChecker : EditorWindow -{ - string[] inspectToolbarStrings = {"Textures", "Materials","Meshes"}; - string[] inspectToolbarStrings2 = {"Textures", "Materials","Meshes", "Missing"}; - - enum InspectType + public class ResourceChecker : EditorWindow { - Textures,Materials,Meshes,Missing - }; + string[] inspectToolbarStrings = {"Textures", "Materials","Meshes"}; + string[] inspectToolbarStrings2 = {"Textures", "Materials","Meshes", "Missing"}; - bool IncludeDisabledObjects=true; - bool IncludeSpriteAnimations=true; - bool IncludeScriptReferences=true; - bool IncludeGuiElements=true; - bool IncludeLightmapTextures=true; - bool thingsMissing = false; + enum InspectType + { + Textures,Materials,Meshes,Missing + }; - InspectType ActiveInspectType=InspectType.Textures; + bool IncludeDisabledObjects=true; + bool IncludeSpriteAnimations=true; + bool IncludeScriptReferences=true; + bool IncludeGuiElements=true; + bool IncludeLightmapTextures=true; + bool thingsMissing = false; - float ThumbnailWidth=40; - float ThumbnailHeight=40; + InspectType ActiveInspectType=InspectType.Textures; - List ActiveTextures=new List(); - List ActiveMaterials=new List(); - List ActiveMeshDetails=new List(); - List MissingObjects = new List (); + float ThumbnailWidth=40; + float ThumbnailHeight=40; - Vector2 textureListScrollPos=new Vector2(0,0); - Vector2 materialListScrollPos=new Vector2(0,0); - Vector2 meshListScrollPos=new Vector2(0,0); - Vector2 missingListScrollPos = new Vector2 (0,0); + List ActiveTextures=new List(); + List ActiveMaterials=new List(); + List ActiveMeshDetails=new List(); + List MissingObjects = new List (); - int TotalTextureMemory=0; - int TotalMeshVertices=0; + Vector2 textureListScrollPos=new Vector2(0,0); + Vector2 materialListScrollPos=new Vector2(0,0); + Vector2 meshListScrollPos=new Vector2(0,0); + Vector2 missingListScrollPos = new Vector2 (0,0); - bool ctrlPressed=false; + int TotalTextureMemory=0; + int TotalMeshVertices=0; - static int MinWidth=475; - Color defColor; + bool ctrlPressed=false; - bool collectedInPlayingMode; + static int MinWidth=475; + Color defColor; - [MenuItem ("Window/Resource Checker")] - static void Init () - { - ResourceChecker window = (ResourceChecker) EditorWindow.GetWindow (typeof (ResourceChecker)); - window.CheckResources(); - window.minSize=new Vector2(MinWidth,475); - } + bool collectedInPlayingMode; - void OnGUI () - { - defColor = GUI.color; - IncludeDisabledObjects = GUILayout.Toggle(IncludeDisabledObjects, "Include disabled objects", GUILayout.Width(300)); - IncludeSpriteAnimations = GUILayout.Toggle(IncludeSpriteAnimations, "Look in sprite animations", GUILayout.Width(300)); - GUI.color = new Color (0.8f, 0.8f, 1.0f, 1.0f); - IncludeScriptReferences = GUILayout.Toggle(IncludeScriptReferences, "Look in behavior fields", GUILayout.Width(300)); - GUI.color = new Color (1.0f, 0.95f, 0.8f, 1.0f); - IncludeGuiElements = GUILayout.Toggle(IncludeGuiElements, "Look in GUI elements", GUILayout.Width(300)); - IncludeLightmapTextures = GUILayout.Toggle(IncludeLightmapTextures, "Look in Lightmap textures", GUILayout.Width(300)); - GUI.color = defColor; - GUILayout.BeginArea(new Rect(position.width-85,5,100,65)); - if (GUILayout.Button("Calculate",GUILayout.Width(80), GUILayout.Height(40))) - CheckResources(); - if (GUILayout.Button("CleanUp",GUILayout.Width(80), GUILayout.Height(20))) - Resources.UnloadUnusedAssets(); - GUILayout.EndArea(); - RemoveDestroyedResources(); - - GUILayout.Space(30); - if (thingsMissing == true) { - EditorGUI.HelpBox (new Rect(8,93,300,25),"Some GameObjects are missing graphical elements.", MessageType.Error); - } - GUILayout.BeginHorizontal(); - GUILayout.Label("Textures "+ActiveTextures.Count+" - "+FormatSizeString(TotalTextureMemory)); - GUILayout.Label("Materials "+ActiveMaterials.Count); - GUILayout.Label("Meshes "+ActiveMeshDetails.Count+" - "+TotalMeshVertices+" verts"); - GUILayout.EndHorizontal(); - if (thingsMissing == true) { - ActiveInspectType = (InspectType)GUILayout.Toolbar ((int)ActiveInspectType, inspectToolbarStrings2); - } else { - ActiveInspectType = (InspectType)GUILayout.Toolbar ((int)ActiveInspectType, inspectToolbarStrings); + [MenuItem ("Window/Resource Checker")] + static void Init () + { + ResourceChecker window = (ResourceChecker) EditorWindow.GetWindow (typeof (ResourceChecker)); + window.CheckResources(); + window.minSize=new Vector2(MinWidth,475); } - ctrlPressed=Event.current.control || Event.current.command; - - switch (ActiveInspectType) + void OnGUI () { - case InspectType.Textures: - ListTextures(); - break; - case InspectType.Materials: - ListMaterials(); - break; - case InspectType.Meshes: - ListMeshes(); - break; - case InspectType.Missing: - ListMissing(); - break; - } - } + defColor = GUI.color; + IncludeDisabledObjects = GUILayout.Toggle(IncludeDisabledObjects, "Include disabled objects", GUILayout.Width(300)); + IncludeSpriteAnimations = GUILayout.Toggle(IncludeSpriteAnimations, "Look in sprite animations", GUILayout.Width(300)); + GUI.color = new Color (0.8f, 0.8f, 1.0f, 1.0f); + IncludeScriptReferences = GUILayout.Toggle(IncludeScriptReferences, "Look in behavior fields", GUILayout.Width(300)); + GUI.color = new Color (1.0f, 0.95f, 0.8f, 1.0f); + IncludeGuiElements = GUILayout.Toggle(IncludeGuiElements, "Look in GUI elements", GUILayout.Width(300)); + IncludeLightmapTextures = GUILayout.Toggle(IncludeLightmapTextures, "Look in Lightmap textures", GUILayout.Width(300)); + GUI.color = defColor; + GUILayout.BeginArea(new Rect(position.width-85,5,100,65)); + if (GUILayout.Button("Calculate",GUILayout.Width(80), GUILayout.Height(40))) + CheckResources(); + if (GUILayout.Button("CleanUp",GUILayout.Width(80), GUILayout.Height(20))) + Resources.UnloadUnusedAssets(); + GUILayout.EndArea(); + RemoveDestroyedResources(); + + GUILayout.Space(30); + if (thingsMissing == true) { + EditorGUI.HelpBox (new Rect(8,93,300,25),"Some GameObjects are missing graphical elements.", MessageType.Error); + } + GUILayout.BeginHorizontal(); + GUILayout.Label("Textures "+ActiveTextures.Count+" - "+FormatSizeString(TotalTextureMemory)); + GUILayout.Label("Materials "+ActiveMaterials.Count); + GUILayout.Label("Meshes "+ActiveMeshDetails.Count+" - "+TotalMeshVertices+" verts"); + GUILayout.EndHorizontal(); + if (thingsMissing == true) { + ActiveInspectType = (InspectType)GUILayout.Toolbar ((int)ActiveInspectType, inspectToolbarStrings2); + } else { + ActiveInspectType = (InspectType)GUILayout.Toolbar ((int)ActiveInspectType, inspectToolbarStrings); + } - private void RemoveDestroyedResources() - { - if (collectedInPlayingMode != Application.isPlaying) - { - ActiveTextures.Clear(); - ActiveMaterials.Clear(); - ActiveMeshDetails.Clear(); - MissingObjects.Clear (); - thingsMissing = false; - collectedInPlayingMode = Application.isPlaying; - } - - ActiveTextures.RemoveAll(x => !x.texture); - ActiveTextures.ForEach(delegate(TextureDetails obj) { - obj.FoundInAnimators.RemoveAll(x => !x); - obj.FoundInMaterials.RemoveAll(x => !x); - obj.FoundInRenderers.RemoveAll(x => !x); - obj.FoundInScripts.RemoveAll(x => !x); - obj.FoundInGraphics.RemoveAll(x => !x); - }); - - ActiveMaterials.RemoveAll(x => !x.material); - ActiveMaterials.ForEach(delegate(MaterialDetails obj) { - obj.FoundInRenderers.RemoveAll(x => !x); - obj.FoundInGraphics.RemoveAll(x => !x); - }); - - ActiveMeshDetails.RemoveAll(x => !x.mesh); - ActiveMeshDetails.ForEach(delegate(MeshDetails obj) { - obj.FoundInMeshFilters.RemoveAll(x => !x); - obj.FoundInSkinnedMeshRenderer.RemoveAll(x => !x); - obj.StaticBatchingEnabled.RemoveAll(x => !x); - }); - - TotalTextureMemory = 0; - foreach (TextureDetails tTextureDetails in ActiveTextures) TotalTextureMemory += tTextureDetails.memSizeKB; - - TotalMeshVertices = 0; - foreach (MeshDetails tMeshDetails in ActiveMeshDetails) TotalMeshVertices += tMeshDetails.mesh.vertexCount; - } + ctrlPressed=Event.current.control || Event.current.command; - int GetBitsPerPixel(TextureFormat format) - { - switch (format) - { - case TextureFormat.Alpha8: // Alpha-only texture format. - return 8; - case TextureFormat.ARGB4444: // A 16 bits/pixel texture format. Texture stores color with an alpha channel. - return 16; - case TextureFormat.RGBA4444: // A 16 bits/pixel texture format. - return 16; - case TextureFormat.RGB24: // A color texture format. - return 24; - case TextureFormat.RGBA32: //Color with an alpha channel texture format. - return 32; - case TextureFormat.ARGB32: //Color with an alpha channel texture format. - return 32; - case TextureFormat.RGB565: // A 16 bit color texture format. - return 16; - case TextureFormat.DXT1: // Compressed color texture format. - return 4; - case TextureFormat.DXT5: // Compressed color with alpha channel texture format. - return 8; - /* - case TextureFormat.WiiI4: // Wii texture format. - case TextureFormat.WiiI8: // Wii texture format. Intensity 8 bit. - case TextureFormat.WiiIA4: // Wii texture format. Intensity + Alpha 8 bit (4 + 4). - case TextureFormat.WiiIA8: // Wii texture format. Intensity + Alpha 16 bit (8 + 8). - case TextureFormat.WiiRGB565: // Wii texture format. RGB 16 bit (565). - case TextureFormat.WiiRGB5A3: // Wii texture format. RGBA 16 bit (4443). - case TextureFormat.WiiRGBA8: // Wii texture format. RGBA 32 bit (8888). - case TextureFormat.WiiCMPR: // Compressed Wii texture format. 4 bits/texel, ~RGB8A1 (Outline alpha is not currently supported). - return 0; //Not supported yet - */ - case TextureFormat.PVRTC_RGB2:// PowerVR (iOS) 2 bits/pixel compressed color texture format. - return 2; - case TextureFormat.PVRTC_RGBA2:// PowerVR (iOS) 2 bits/pixel compressed with alpha channel texture format - return 2; - case TextureFormat.PVRTC_RGB4:// PowerVR (iOS) 4 bits/pixel compressed color texture format. - return 4; - case TextureFormat.PVRTC_RGBA4:// PowerVR (iOS) 4 bits/pixel compressed with alpha channel texture format - return 4; - case TextureFormat.ETC_RGB4:// ETC (GLES2.0) 4 bits/pixel compressed RGB texture format. - return 4; - case TextureFormat.ETC2_RGBA8: - return 8; - case TextureFormat.EAC_R: - return 4; - case TextureFormat.BGRA32:// Format returned by iPhone camera - return 32; + switch (ActiveInspectType) + { + case InspectType.Textures: + ListTextures(); + break; + case InspectType.Materials: + ListMaterials(); + break; + case InspectType.Meshes: + ListMeshes(); + break; + case InspectType.Missing: + ListMissing(); + break; + } } - return 0; - } - - int CalculateTextureSizeBytes(Texture tTexture) - { - int tWidth=tTexture.width; - int tHeight=tTexture.height; - if (tTexture is Texture2D) + private void RemoveDestroyedResources() { - Texture2D tTex2D=tTexture as Texture2D; - int bitsPerPixel=GetBitsPerPixel(tTex2D.format); - int mipMapCount=tTex2D.mipmapCount; - int mipLevel=1; - int tSize=0; - while (mipLevel<=mipMapCount) + if (collectedInPlayingMode != Application.isPlaying) { - tSize+=tWidth*tHeight*bitsPerPixel/8; - tWidth=tWidth/2; - tHeight=tHeight/2; - mipLevel++; + ActiveTextures.Clear(); + ActiveMaterials.Clear(); + ActiveMeshDetails.Clear(); + MissingObjects.Clear (); + thingsMissing = false; + collectedInPlayingMode = Application.isPlaying; } - return tSize; + + ActiveTextures.RemoveAll(x => !x.texture); + ActiveTextures.ForEach(delegate(TextureDetails obj) { + obj.FoundInAnimators.RemoveAll(x => !x); + obj.FoundInMaterials.RemoveAll(x => !x); + obj.FoundInRenderers.RemoveAll(x => !x); + obj.FoundInScripts.RemoveAll(x => !x); + obj.FoundInGraphics.RemoveAll(x => !x); + }); + + ActiveMaterials.RemoveAll(x => !x.material); + ActiveMaterials.ForEach(delegate(MaterialDetails obj) { + obj.FoundInRenderers.RemoveAll(x => !x); + obj.FoundInGraphics.RemoveAll(x => !x); + }); + + ActiveMeshDetails.RemoveAll(x => !x.mesh); + ActiveMeshDetails.ForEach(delegate(MeshDetails obj) { + obj.FoundInMeshFilters.RemoveAll(x => !x); + obj.FoundInSkinnedMeshRenderer.RemoveAll(x => !x); + obj.StaticBatchingEnabled.RemoveAll(x => !x); + }); + + TotalTextureMemory = 0; + foreach (TextureDetails tTextureDetails in ActiveTextures) TotalTextureMemory += tTextureDetails.memSizeKB; + + TotalMeshVertices = 0; + foreach (MeshDetails tMeshDetails in ActiveMeshDetails) TotalMeshVertices += tMeshDetails.mesh.vertexCount; } - if (tTexture is Texture2DArray) + + int GetBitsPerPixel(TextureFormat format) { - Texture2DArray tTex2D=tTexture as Texture2DArray; - int bitsPerPixel=GetBitsPerPixel(tTex2D.format); - int mipMapCount=10; - int mipLevel=1; - int tSize=0; - while (mipLevel<=mipMapCount) + switch (format) { - tSize+=tWidth*tHeight*bitsPerPixel/8; - tWidth=tWidth/2; - tHeight=tHeight/2; - mipLevel++; + case TextureFormat.Alpha8: // Alpha-only texture format. + return 8; + case TextureFormat.ARGB4444: // A 16 bits/pixel texture format. Texture stores color with an alpha channel. + return 16; + case TextureFormat.RGBA4444: // A 16 bits/pixel texture format. + return 16; + case TextureFormat.RGB24: // A color texture format. + return 24; + case TextureFormat.RGBA32: //Color with an alpha channel texture format. + return 32; + case TextureFormat.ARGB32: //Color with an alpha channel texture format. + return 32; + case TextureFormat.RGB565: // A 16 bit color texture format. + return 16; + case TextureFormat.DXT1: // Compressed color texture format. + return 4; + case TextureFormat.DXT5: // Compressed color with alpha channel texture format. + return 8; + /* + case TextureFormat.WiiI4: // Wii texture format. + case TextureFormat.WiiI8: // Wii texture format. Intensity 8 bit. + case TextureFormat.WiiIA4: // Wii texture format. Intensity + Alpha 8 bit (4 + 4). + case TextureFormat.WiiIA8: // Wii texture format. Intensity + Alpha 16 bit (8 + 8). + case TextureFormat.WiiRGB565: // Wii texture format. RGB 16 bit (565). + case TextureFormat.WiiRGB5A3: // Wii texture format. RGBA 16 bit (4443). + case TextureFormat.WiiRGBA8: // Wii texture format. RGBA 32 bit (8888). + case TextureFormat.WiiCMPR: // Compressed Wii texture format. 4 bits/texel, ~RGB8A1 (Outline alpha is not currently supported). + return 0; //Not supported yet + */ + case TextureFormat.PVRTC_RGB2:// PowerVR (iOS) 2 bits/pixel compressed color texture format. + return 2; + case TextureFormat.PVRTC_RGBA2:// PowerVR (iOS) 2 bits/pixel compressed with alpha channel texture format + return 2; + case TextureFormat.PVRTC_RGB4:// PowerVR (iOS) 4 bits/pixel compressed color texture format. + return 4; + case TextureFormat.PVRTC_RGBA4:// PowerVR (iOS) 4 bits/pixel compressed with alpha channel texture format + return 4; + case TextureFormat.ETC_RGB4:// ETC (GLES2.0) 4 bits/pixel compressed RGB texture format. + return 4; + case TextureFormat.ETC2_RGBA8: + return 8; + case TextureFormat.EAC_R: + return 4; + case TextureFormat.BGRA32:// Format returned by iPhone camera + return 32; } - return tSize*((Texture2DArray)tTex2D).depth; - } - if (tTexture is Cubemap) { - Cubemap tCubemap = tTexture as Cubemap; - int bitsPerPixel = GetBitsPerPixel (tCubemap.format); - return tWidth * tHeight * 6 * bitsPerPixel / 8; + return 0; } - return 0; - } - - void SelectObject(Object selectedObject,bool append) - { - if (append) + int CalculateTextureSizeBytes(Texture tTexture) { - List currentSelection=new List(Selection.objects); - // Allow toggle selection - if (currentSelection.Contains(selectedObject)) currentSelection.Remove(selectedObject); - else currentSelection.Add(selectedObject); - Selection.objects=currentSelection.ToArray(); - } - else Selection.activeObject=selectedObject; - } - - void SelectObjects(List selectedObjects,bool append) - { - if (append) - { - List currentSelection=new List(Selection.objects); - currentSelection.AddRange(selectedObjects); - Selection.objects=currentSelection.ToArray(); - } - else Selection.objects=selectedObjects.ToArray(); - } - - void ListTextures() - { - textureListScrollPos = EditorGUILayout.BeginScrollView(textureListScrollPos); - - foreach (TextureDetails tDetails in ActiveTextures) - { - - GUILayout.BeginHorizontal (); - Texture tex =tDetails.texture; - if(tDetails.texture.GetType() == typeof(Texture2DArray) || tDetails.texture.GetType() == typeof(Cubemap)){ - tex = AssetPreview.GetMiniThumbnail(tDetails.texture); + int tWidth=tTexture.width; + int tHeight=tTexture.height; + if (tTexture is Texture2D) + { + Texture2D tTex2D=tTexture as Texture2D; + int bitsPerPixel=GetBitsPerPixel(tTex2D.format); + int mipMapCount=tTex2D.mipmapCount; + int mipLevel=1; + int tSize=0; + while (mipLevel<=mipMapCount) + { + tSize+=tWidth*tHeight*bitsPerPixel/8; + tWidth=tWidth/2; + tHeight=tHeight/2; + mipLevel++; + } + return tSize; } - GUILayout.Box(tex, GUILayout.Width(ThumbnailWidth), GUILayout.Height(ThumbnailHeight)); - - if (tDetails.instance == true) - GUI.color = new Color (0.8f, 0.8f, defColor.b, 1.0f); - if (tDetails.isgui == true) - GUI.color = new Color (defColor.r, 0.95f, 0.8f, 1.0f); - if (tDetails.isSky) - GUI.color = new Color (0.9f, defColor.g, defColor.b, 1.0f); - if(GUILayout.Button(tDetails.texture.name,GUILayout.Width(150))) + if (tTexture is Texture2DArray) { - SelectObject(tDetails.texture,ctrlPressed); + Texture2DArray tTex2D=tTexture as Texture2DArray; + int bitsPerPixel=GetBitsPerPixel(tTex2D.format); + int mipMapCount=10; + int mipLevel=1; + int tSize=0; + while (mipLevel<=mipMapCount) + { + tSize+=tWidth*tHeight*bitsPerPixel/8; + tWidth=tWidth/2; + tHeight=tHeight/2; + mipLevel++; + } + return tSize*((Texture2DArray)tTex2D).depth; } - GUI.color = defColor; - - string sizeLabel=""+tDetails.texture.width+"x"+tDetails.texture.height; - if (tDetails.isCubeMap) sizeLabel+="x6"; - if (tDetails.texture.GetType () == typeof(Texture2DArray)) - sizeLabel+= "[]\n" + ((Texture2DArray)tDetails.texture).depth+"depths"; - sizeLabel+=" - "+tDetails.mipMapCount+"mip\n"+FormatSizeString(tDetails.memSizeKB)+" - "+tDetails.format; + if (tTexture is Cubemap) { + Cubemap tCubemap = tTexture as Cubemap; + int bitsPerPixel = GetBitsPerPixel (tCubemap.format); + return tWidth * tHeight * 6 * bitsPerPixel / 8; + } + return 0; + } - GUILayout.Label (sizeLabel,GUILayout.Width(120)); - if(GUILayout.Button(tDetails.FoundInMaterials.Count+" Mat",GUILayout.Width(50))) + void SelectObject(Object selectedObject,bool append) + { + if (append) { - SelectObjects(tDetails.FoundInMaterials,ctrlPressed); - } + List currentSelection=new List(Selection.objects); + // Allow toggle selection + if (currentSelection.Contains(selectedObject)) currentSelection.Remove(selectedObject); + else currentSelection.Add(selectedObject); - HashSet FoundObjects = new HashSet(); - foreach (Renderer renderer in tDetails.FoundInRenderers) FoundObjects.Add(renderer.gameObject); - foreach (Animator animator in tDetails.FoundInAnimators) FoundObjects.Add(animator.gameObject); - foreach (Graphic graphic in tDetails.FoundInGraphics) FoundObjects.Add(graphic.gameObject); - foreach (Button button in tDetails.FoundInButtons) FoundObjects.Add(button.gameObject); - foreach (MonoBehaviour script in tDetails.FoundInScripts) FoundObjects.Add(script.gameObject); - if (GUILayout.Button(FoundObjects.Count+" GO",GUILayout.Width(50))) - { - SelectObjects(new List(FoundObjects),ctrlPressed); + Selection.objects=currentSelection.ToArray(); } - - GUILayout.EndHorizontal(); + else Selection.activeObject=selectedObject; } - if (ActiveTextures.Count>0) + + void SelectObjects(List selectedObjects,bool append) { - EditorGUILayout.Space(); - GUILayout.BeginHorizontal (); - //GUILayout.Box(" ",GUILayout.Width(ThumbnailWidth),GUILayout.Height(ThumbnailHeight)); - if(GUILayout.Button("Select \n All",GUILayout.Width(ThumbnailWidth*2))) + if (append) { - List AllTextures=new List(); - foreach (TextureDetails tDetails in ActiveTextures) AllTextures.Add(tDetails.texture); - SelectObjects(AllTextures,ctrlPressed); + List currentSelection=new List(Selection.objects); + currentSelection.AddRange(selectedObjects); + Selection.objects=currentSelection.ToArray(); } - EditorGUILayout.EndHorizontal(); + else Selection.objects=selectedObjects.ToArray(); } - EditorGUILayout.EndScrollView(); - } - void ListMaterials() - { - materialListScrollPos = EditorGUILayout.BeginScrollView(materialListScrollPos); + void ListTextures() + { + textureListScrollPos = EditorGUILayout.BeginScrollView(textureListScrollPos); - foreach (MaterialDetails tDetails in ActiveMaterials) - { - if (tDetails.material!=null) - { - GUILayout.BeginHorizontal (); + foreach (TextureDetails tDetails in ActiveTextures) + { - GUILayout.Box(AssetPreview.GetAssetPreview(tDetails.material), GUILayout.Width(ThumbnailWidth), GUILayout.Height(ThumbnailHeight)); + GUILayout.BeginHorizontal (); + Texture tex =tDetails.texture; + if(tDetails.texture.GetType() == typeof(Texture2DArray) || tDetails.texture.GetType() == typeof(Cubemap)){ + tex = AssetPreview.GetMiniThumbnail(tDetails.texture); + } + GUILayout.Box(tex, GUILayout.Width(ThumbnailWidth), GUILayout.Height(ThumbnailHeight)); if (tDetails.instance == true) GUI.color = new Color (0.8f, 0.8f, defColor.b, 1.0f); @@ -369,735 +303,801 @@ void ListMaterials() GUI.color = new Color (defColor.r, 0.95f, 0.8f, 1.0f); if (tDetails.isSky) GUI.color = new Color (0.9f, defColor.g, defColor.b, 1.0f); - if(GUILayout.Button(tDetails.material.name,GUILayout.Width(150))) + if(GUILayout.Button(tDetails.texture.name,GUILayout.Width(150))) { - SelectObject(tDetails.material,ctrlPressed); + SelectObject(tDetails.texture,ctrlPressed); } GUI.color = defColor; - string shaderLabel = tDetails.material.shader != null ? tDetails.material.shader.name : "no shader"; - GUILayout.Label (shaderLabel, GUILayout.Width(200)); + string sizeLabel=""+tDetails.texture.width+"x"+tDetails.texture.height; + if (tDetails.isCubeMap) sizeLabel+="x6"; + if (tDetails.texture.GetType () == typeof(Texture2DArray)) + sizeLabel+= "[]\n" + ((Texture2DArray)tDetails.texture).depth+"depths"; + sizeLabel+=" - "+tDetails.mipMapCount+"mip\n"+FormatSizeString(tDetails.memSizeKB)+" - "+tDetails.format; + + GUILayout.Label (sizeLabel,GUILayout.Width(120)); - if(GUILayout.Button((tDetails.FoundInRenderers.Count + tDetails.FoundInGraphics.Count) +" GO",GUILayout.Width(50))) + if(GUILayout.Button(tDetails.FoundInMaterials.Count+" Mat",GUILayout.Width(50))) { - List FoundObjects=new List(); - foreach (Renderer renderer in tDetails.FoundInRenderers) FoundObjects.Add(renderer.gameObject); - foreach (Graphic graphic in tDetails.FoundInGraphics) FoundObjects.Add(graphic.gameObject); - SelectObjects(FoundObjects,ctrlPressed); + SelectObjects(tDetails.FoundInMaterials,ctrlPressed); } - var queue = tDetails.material.renderQueue; - EditorGUI.BeginChangeCheck(); - queue = EditorGUILayout.DelayedIntField(queue, GUILayout.Width(35)); - if (EditorGUI.EndChangeCheck()) + HashSet FoundObjects = new HashSet(); + foreach (Renderer renderer in tDetails.FoundInRenderers) FoundObjects.Add(renderer.gameObject); + foreach (Animator animator in tDetails.FoundInAnimators) FoundObjects.Add(animator.gameObject); + foreach (Graphic graphic in tDetails.FoundInGraphics) FoundObjects.Add(graphic.gameObject); + foreach (Button button in tDetails.FoundInButtons) FoundObjects.Add(button.gameObject); + foreach (MonoBehaviour script in tDetails.FoundInScripts) FoundObjects.Add(script.gameObject); + if (GUILayout.Button(FoundObjects.Count+" GO",GUILayout.Width(50))) { - tDetails.material.renderQueue = queue; - ActiveMaterials.Sort(MaterialSorter); - GUIUtility.ExitGUI(); - break; + SelectObjects(new List(FoundObjects),ctrlPressed); } - + GUILayout.EndHorizontal(); } - } - EditorGUILayout.EndScrollView(); - } - - /// - /// Sort by RenderQueue - /// - static int MaterialSorter(MaterialDetails first, MaterialDetails second) - { - var firstIsNull = first.material == null; - var secondIsNull = second.material == null; - - if (firstIsNull && secondIsNull) return 0; - if (firstIsNull) return int.MaxValue; - if (secondIsNull) return int.MinValue; - - return first.material.renderQueue - second.material.renderQueue; - } - - void ListMeshes() - { - meshListScrollPos = EditorGUILayout.BeginScrollView(meshListScrollPos); - - foreach (MeshDetails tDetails in ActiveMeshDetails) - { - if (tDetails.mesh!=null) + if (ActiveTextures.Count>0) { + EditorGUILayout.Space(); GUILayout.BeginHorizontal (); - string name = tDetails.mesh.name; - if (name == null || name.Count() < 1) - name = tDetails.FoundInMeshFilters[0].gameObject.name; - if (tDetails.instance == true) - GUI.color = new Color (0.8f, 0.8f, defColor.b, 1.0f); - if(GUILayout.Button(name,GUILayout.Width(150))) + //GUILayout.Box(" ",GUILayout.Width(ThumbnailWidth),GUILayout.Height(ThumbnailHeight)); + if(GUILayout.Button("Select \n All",GUILayout.Width(ThumbnailWidth*2))) { - SelectObject(tDetails.mesh,ctrlPressed); + List AllTextures=new List(); + foreach (TextureDetails tDetails in ActiveTextures) AllTextures.Add(tDetails.texture); + SelectObjects(AllTextures,ctrlPressed); } - GUI.color = defColor; - string sizeLabel=""+tDetails.mesh.vertexCount+" vert"; - - GUILayout.Label (sizeLabel,GUILayout.Width(100)); + EditorGUILayout.EndHorizontal(); + } + EditorGUILayout.EndScrollView(); + } + void ListMaterials() + { + materialListScrollPos = EditorGUILayout.BeginScrollView(materialListScrollPos); - if(GUILayout.Button(tDetails.FoundInMeshFilters.Count + " GO",GUILayout.Width(50))) + foreach (MaterialDetails tDetails in ActiveMaterials) + { + if (tDetails.material!=null) { - List FoundObjects=new List(); - foreach (MeshFilter meshFilter in tDetails.FoundInMeshFilters) FoundObjects.Add(meshFilter.gameObject); - SelectObjects(FoundObjects,ctrlPressed); - } - if (tDetails.FoundInSkinnedMeshRenderer.Count > 0) { - if (GUILayout.Button (tDetails.FoundInSkinnedMeshRenderer.Count + " skinned mesh GO", GUILayout.Width (140))) { - List FoundObjects = new List (); - foreach (SkinnedMeshRenderer skinnedMeshRenderer in tDetails.FoundInSkinnedMeshRenderer) - FoundObjects.Add (skinnedMeshRenderer.gameObject); - SelectObjects (FoundObjects, ctrlPressed); + GUILayout.BeginHorizontal (); + + GUILayout.Box(AssetPreview.GetAssetPreview(tDetails.material), GUILayout.Width(ThumbnailWidth), GUILayout.Height(ThumbnailHeight)); + + if (tDetails.instance == true) + GUI.color = new Color (0.8f, 0.8f, defColor.b, 1.0f); + if (tDetails.isgui == true) + GUI.color = new Color (defColor.r, 0.95f, 0.8f, 1.0f); + if (tDetails.isSky) + GUI.color = new Color (0.9f, defColor.g, defColor.b, 1.0f); + if(GUILayout.Button(tDetails.material.name,GUILayout.Width(150))) + { + SelectObject(tDetails.material,ctrlPressed); } - } else { - GUI.color = new Color (defColor.r, defColor.g, defColor.b, 0.5f); - GUILayout.Label(" 0 skinned mesh"); GUI.color = defColor; + + string shaderLabel = tDetails.material.shader != null ? tDetails.material.shader.name : "no shader"; + GUILayout.Label (shaderLabel, GUILayout.Width(200)); + + if(GUILayout.Button((tDetails.FoundInRenderers.Count + tDetails.FoundInGraphics.Count) +" GO",GUILayout.Width(50))) + { + List FoundObjects=new List(); + foreach (Renderer renderer in tDetails.FoundInRenderers) FoundObjects.Add(renderer.gameObject); + foreach (Graphic graphic in tDetails.FoundInGraphics) FoundObjects.Add(graphic.gameObject); + SelectObjects(FoundObjects,ctrlPressed); + } + + var queue = tDetails.material.renderQueue; + EditorGUI.BeginChangeCheck(); + queue = EditorGUILayout.DelayedIntField(queue, GUILayout.Width(35)); + if (EditorGUI.EndChangeCheck()) + { + tDetails.material.renderQueue = queue; + ActiveMaterials.Sort(MaterialSorter); + GUIUtility.ExitGUI(); + break; + } + + GUILayout.EndHorizontal(); } - - if (tDetails.StaticBatchingEnabled.Count > 0) { - if (GUILayout.Button (tDetails.StaticBatchingEnabled.Count + " Static Batching", GUILayout.Width (140))) { - List FoundObjects = new List (); - foreach (var obj in tDetails.StaticBatchingEnabled) - FoundObjects.Add (obj); - SelectObjects (FoundObjects, ctrlPressed); + } + EditorGUILayout.EndScrollView(); + } + + /// + /// Sort by RenderQueue + /// + static int MaterialSorter(MaterialDetails first, MaterialDetails second) + { + var firstIsNull = first.material == null; + var secondIsNull = second.material == null; + + if (firstIsNull && secondIsNull) return 0; + if (firstIsNull) return int.MaxValue; + if (secondIsNull) return int.MinValue; + + return first.material.renderQueue - second.material.renderQueue; + } + + void ListMeshes() + { + meshListScrollPos = EditorGUILayout.BeginScrollView(meshListScrollPos); + + foreach (MeshDetails tDetails in ActiveMeshDetails) + { + if (tDetails.mesh!=null) + { + GUILayout.BeginHorizontal (); + string name = tDetails.mesh.name; + if (name == null || name.Count() < 1) + name = tDetails.FoundInMeshFilters[0].gameObject.name; + if (tDetails.instance == true) + GUI.color = new Color (0.8f, 0.8f, defColor.b, 1.0f); + if(GUILayout.Button(name,GUILayout.Width(150))) + { + SelectObject(tDetails.mesh,ctrlPressed); } - } else { - GUI.color = new Color (defColor.r, defColor.g, defColor.b, 0.5f); - GUILayout.Label(" 0 static batching"); GUI.color = defColor; - } + string sizeLabel=""+tDetails.mesh.vertexCount+" vert"; + GUILayout.Label (sizeLabel,GUILayout.Width(100)); - GUILayout.EndHorizontal(); + + if(GUILayout.Button(tDetails.FoundInMeshFilters.Count + " GO",GUILayout.Width(50))) + { + List FoundObjects=new List(); + foreach (MeshFilter meshFilter in tDetails.FoundInMeshFilters) FoundObjects.Add(meshFilter.gameObject); + SelectObjects(FoundObjects,ctrlPressed); + } + if (tDetails.FoundInSkinnedMeshRenderer.Count > 0) { + if (GUILayout.Button (tDetails.FoundInSkinnedMeshRenderer.Count + " skinned mesh GO", GUILayout.Width (140))) { + List FoundObjects = new List (); + foreach (SkinnedMeshRenderer skinnedMeshRenderer in tDetails.FoundInSkinnedMeshRenderer) + FoundObjects.Add (skinnedMeshRenderer.gameObject); + SelectObjects (FoundObjects, ctrlPressed); + } + } else { + GUI.color = new Color (defColor.r, defColor.g, defColor.b, 0.5f); + GUILayout.Label(" 0 skinned mesh"); + GUI.color = defColor; + } + + if (tDetails.StaticBatchingEnabled.Count > 0) { + if (GUILayout.Button (tDetails.StaticBatchingEnabled.Count + " Static Batching", GUILayout.Width (140))) { + List FoundObjects = new List (); + foreach (var obj in tDetails.StaticBatchingEnabled) + FoundObjects.Add (obj); + SelectObjects (FoundObjects, ctrlPressed); + } + } else { + GUI.color = new Color (defColor.r, defColor.g, defColor.b, 0.5f); + GUILayout.Label(" 0 static batching"); + GUI.color = defColor; + } + + + GUILayout.EndHorizontal(); + } } + EditorGUILayout.EndScrollView(); } - EditorGUILayout.EndScrollView(); - } - void ListMissing(){ - missingListScrollPos = EditorGUILayout.BeginScrollView(missingListScrollPos); - foreach (MissingGraphic dMissing in MissingObjects) { - GUILayout.BeginHorizontal (); - if (GUILayout.Button (dMissing.name, GUILayout.Width (150))) - SelectObject (dMissing.Object, ctrlPressed); - GUILayout.Label ("missing ", GUILayout.Width(48)); - switch (dMissing.type) { - case "mesh": - GUI.color = new Color (0.8f, 0.8f, defColor.b, 1.0f); - break; - case "sprite": - GUI.color = new Color (defColor.r, 0.8f, 0.8f, 1.0f); - break; - case "material": - GUI.color = new Color (0.8f, defColor.g, 0.8f, 1.0f); - break; + void ListMissing(){ + missingListScrollPos = EditorGUILayout.BeginScrollView(missingListScrollPos); + foreach (MissingGraphic dMissing in MissingObjects) { + GUILayout.BeginHorizontal (); + if (GUILayout.Button (dMissing.name, GUILayout.Width (150))) + SelectObject (dMissing.Object, ctrlPressed); + GUILayout.Label ("missing ", GUILayout.Width(48)); + switch (dMissing.type) { + case "mesh": + GUI.color = new Color (0.8f, 0.8f, defColor.b, 1.0f); + break; + case "sprite": + GUI.color = new Color (defColor.r, 0.8f, 0.8f, 1.0f); + break; + case "material": + GUI.color = new Color (0.8f, defColor.g, 0.8f, 1.0f); + break; + } + GUILayout.Label (dMissing.type); + GUI.color = defColor; + GUILayout.EndHorizontal (); } - GUILayout.Label (dMissing.type); - GUI.color = defColor; - GUILayout.EndHorizontal (); + EditorGUILayout.EndScrollView(); } - EditorGUILayout.EndScrollView(); - } - string FormatSizeString(int memSizeKB) - { - if (memSizeKB<1024) return ""+memSizeKB+"k"; - else + string FormatSizeString(int memSizeKB) { - float memSizeMB=((float)memSizeKB)/1024.0f; - return memSizeMB.ToString("0.00")+"Mb"; + if (memSizeKB<1024) return ""+memSizeKB+"k"; + else + { + float memSizeMB=((float)memSizeKB)/1024.0f; + return memSizeMB.ToString("0.00")+"Mb"; + } } - } - TextureDetails FindTextureDetails(Texture tTexture) - { - foreach (TextureDetails tTextureDetails in ActiveTextures) + TextureDetails FindTextureDetails(Texture tTexture) { - if (tTextureDetails.texture==tTexture) return tTextureDetails; - } - return null; + foreach (TextureDetails tTextureDetails in ActiveTextures) + { + if (tTextureDetails.texture==tTexture) return tTextureDetails; + } + return null; - } + } - MaterialDetails FindMaterialDetails(Material tMaterial) - { - foreach (MaterialDetails tMaterialDetails in ActiveMaterials) + MaterialDetails FindMaterialDetails(Material tMaterial) { - if (tMaterialDetails.material==tMaterial) return tMaterialDetails; - } - return null; + foreach (MaterialDetails tMaterialDetails in ActiveMaterials) + { + if (tMaterialDetails.material==tMaterial) return tMaterialDetails; + } + return null; - } + } - MeshDetails FindMeshDetails(Mesh tMesh) - { - foreach (MeshDetails tMeshDetails in ActiveMeshDetails) + MeshDetails FindMeshDetails(Mesh tMesh) { - if (tMeshDetails.mesh==tMesh) return tMeshDetails; - } - return null; + foreach (MeshDetails tMeshDetails in ActiveMeshDetails) + { + if (tMeshDetails.mesh==tMesh) return tMeshDetails; + } + return null; - } + } - void CheckResources() - { - ActiveTextures.Clear(); - ActiveMaterials.Clear(); - ActiveMeshDetails.Clear(); - MissingObjects.Clear (); - thingsMissing = false; + void CheckResources() + { + ActiveTextures.Clear(); + ActiveMaterials.Clear(); + ActiveMeshDetails.Clear(); + MissingObjects.Clear (); + thingsMissing = false; - Renderer[] renderers = FindObjects(); + Renderer[] renderers = FindObjects(); - MaterialDetails skyMat = new MaterialDetails (); - skyMat.material = RenderSettings.skybox; - skyMat.isSky = true; - ActiveMaterials.Add (skyMat); + MaterialDetails skyMat = new MaterialDetails (); + skyMat.material = RenderSettings.skybox; + skyMat.isSky = true; + ActiveMaterials.Add (skyMat); - //Debug.Log("Total renderers "+renderers.Length); - foreach (Renderer renderer in renderers) - { - //Debug.Log("Renderer is "+renderer.name); - foreach (Material material in renderer.sharedMaterials) + //Debug.Log("Total renderers "+renderers.Length); + foreach (Renderer renderer in renderers) { - - MaterialDetails tMaterialDetails = FindMaterialDetails(material); - if (tMaterialDetails == null) + //Debug.Log("Renderer is "+renderer.name); + foreach (Material material in renderer.sharedMaterials) { - tMaterialDetails = new MaterialDetails(); - tMaterialDetails.material = material; - ActiveMaterials.Add(tMaterialDetails); + + MaterialDetails tMaterialDetails = FindMaterialDetails(material); + if (tMaterialDetails == null) + { + tMaterialDetails = new MaterialDetails(); + tMaterialDetails.material = material; + ActiveMaterials.Add(tMaterialDetails); + } + tMaterialDetails.FoundInRenderers.Add(renderer); } - tMaterialDetails.FoundInRenderers.Add(renderer); - } - if (renderer is SpriteRenderer) - { - SpriteRenderer tSpriteRenderer = (SpriteRenderer)renderer; + if (renderer is SpriteRenderer) + { + SpriteRenderer tSpriteRenderer = (SpriteRenderer)renderer; - if (tSpriteRenderer.sprite != null) { - var tSpriteTextureDetail = GetTextureDetail (tSpriteRenderer.sprite.texture, renderer); - if (!ActiveTextures.Contains (tSpriteTextureDetail)) { - ActiveTextures.Add (tSpriteTextureDetail); + if (tSpriteRenderer.sprite != null) { + var tSpriteTextureDetail = GetTextureDetail (tSpriteRenderer.sprite.texture, renderer); + if (!ActiveTextures.Contains (tSpriteTextureDetail)) { + ActiveTextures.Add (tSpriteTextureDetail); + } + } else if (tSpriteRenderer.sprite == null) { + MissingGraphic tMissing = new MissingGraphic (); + tMissing.Object = tSpriteRenderer.transform; + tMissing.type = "sprite"; + tMissing.name = tSpriteRenderer.transform.name; + MissingObjects.Add (tMissing); + thingsMissing = true; } - } else if (tSpriteRenderer.sprite == null) { - MissingGraphic tMissing = new MissingGraphic (); - tMissing.Object = tSpriteRenderer.transform; - tMissing.type = "sprite"; - tMissing.name = tSpriteRenderer.transform.name; - MissingObjects.Add (tMissing); - thingsMissing = true; } } - } - if (IncludeLightmapTextures) { - LightmapData[] lightmapTextures = LightmapSettings.lightmaps; + if (IncludeLightmapTextures) { + LightmapData[] lightmapTextures = LightmapSettings.lightmaps; - // Unity lightmaps - foreach (LightmapData lightmapData in lightmapTextures) - { - if (lightmapData.lightmapColor != null) - { - var textureDetail = GetTextureDetail (lightmapData.lightmapColor); - - if (!ActiveTextures.Contains (textureDetail)) - ActiveTextures.Add (textureDetail); - } - - if (lightmapData.lightmapDir != null) + // Unity lightmaps + foreach (LightmapData lightmapData in lightmapTextures) { - var textureDetail = GetTextureDetail (lightmapData.lightmapColor); + if (lightmapData.lightmapColor != null) + { + var textureDetail = GetTextureDetail (lightmapData.lightmapColor); + + if (!ActiveTextures.Contains (textureDetail)) + ActiveTextures.Add (textureDetail); + } - if (!ActiveTextures.Contains (textureDetail)) - ActiveTextures.Add (textureDetail); - } - - if (lightmapData.shadowMask != null) - { - var textureDetail = GetTextureDetail (lightmapData.shadowMask); + if (lightmapData.lightmapDir != null) + { + var textureDetail = GetTextureDetail (lightmapData.lightmapColor); + + if (!ActiveTextures.Contains (textureDetail)) + ActiveTextures.Add (textureDetail); + } - if (!ActiveTextures.Contains (textureDetail)) - ActiveTextures.Add (textureDetail); + if (lightmapData.shadowMask != null) + { + var textureDetail = GetTextureDetail (lightmapData.shadowMask); + + if (!ActiveTextures.Contains (textureDetail)) + ActiveTextures.Add (textureDetail); + } } } - } - - if (IncludeGuiElements) - { - Graphic[] graphics = FindObjects(); - - foreach(Graphic graphic in graphics) + + if (IncludeGuiElements) { - if (graphic.mainTexture) + Graphic[] graphics = FindObjects(); + + foreach(Graphic graphic in graphics) { - var tSpriteTextureDetail = GetTextureDetail(graphic.mainTexture, graphic); - if (!ActiveTextures.Contains(tSpriteTextureDetail)) + if (graphic.mainTexture) { - ActiveTextures.Add(tSpriteTextureDetail); + var tSpriteTextureDetail = GetTextureDetail(graphic.mainTexture, graphic); + if (!ActiveTextures.Contains(tSpriteTextureDetail)) + { + ActiveTextures.Add(tSpriteTextureDetail); + } } - } - if (graphic.materialForRendering) - { - MaterialDetails tMaterialDetails = FindMaterialDetails(graphic.materialForRendering); - if (tMaterialDetails == null) + if (graphic.materialForRendering) { - tMaterialDetails = new MaterialDetails(); - tMaterialDetails.material = graphic.materialForRendering; - tMaterialDetails.isgui = true; - ActiveMaterials.Add(tMaterialDetails); + MaterialDetails tMaterialDetails = FindMaterialDetails(graphic.materialForRendering); + if (tMaterialDetails == null) + { + tMaterialDetails = new MaterialDetails(); + tMaterialDetails.material = graphic.materialForRendering; + tMaterialDetails.isgui = true; + ActiveMaterials.Add(tMaterialDetails); + } + tMaterialDetails.FoundInGraphics.Add(graphic); } - tMaterialDetails.FoundInGraphics.Add(graphic); } - } - Button[] buttons = FindObjects