diff --git a/Assets/Asset Usage Finder.meta b/Assets/Asset Usage Finder.meta new file mode 100644 index 00000000..c743c83c --- /dev/null +++ b/Assets/Asset Usage Finder.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 780c836a7014ad24ea989f9567d59296 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Asset Usage Finder/AssetUsageFinder.asmdef b/Assets/Asset Usage Finder/AssetUsageFinder.asmdef new file mode 100644 index 00000000..9f3d4fe1 --- /dev/null +++ b/Assets/Asset Usage Finder/AssetUsageFinder.asmdef @@ -0,0 +1,15 @@ +{ + "name": "AssetUsageFinder", + "references": [], + "includePlatforms": [ + "Editor" + ], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": false, + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/Assets/Asset Usage Finder/AssetUsageFinder.asmdef.meta b/Assets/Asset Usage Finder/AssetUsageFinder.asmdef.meta new file mode 100644 index 00000000..b07a838f --- /dev/null +++ b/Assets/Asset Usage Finder/AssetUsageFinder.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 78166de3938470b4da415a0209d69308 +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Asset Usage Finder/Editor.meta b/Assets/Asset Usage Finder/Editor.meta new file mode 100644 index 00000000..f06a2ce1 --- /dev/null +++ b/Assets/Asset Usage Finder/Editor.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: a6cb38742b49c2543b9129cc5bc1959f +folderAsset: yes +timeCreated: 1464798283 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Asset Usage Finder/Editor/AUFUtils.cs b/Assets/Asset Usage Finder/Editor/AUFUtils.cs new file mode 100644 index 00000000..695eead5 --- /dev/null +++ b/Assets/Asset Usage Finder/Editor/AUFUtils.cs @@ -0,0 +1,42 @@ +using System.Linq; +using UnityEditor; +using UnityEngine; + +namespace AssetUsageFinder { + public static class AufUtils { + public static Object[] LoadAllAssetsAtPath (string assetPath) { + // prevents error "Do not use readobjectthreaded on scene objects!" + return typeof (SceneAsset) == AssetDatabase.GetMainAssetTypeAtPath (assetPath) + ? new[] { AssetDatabase.LoadMainAssetAtPath (assetPath) } + : AssetDatabase.LoadAllAssetsAtPath (assetPath); + } + + public static T FirstOfType () where T : Object { + var typeName = typeof (T).Name; + + var guids = AssetDatabase.FindAssets (string.Format ("t:{0}", typeName)); + if (!guids.Any ()) { + AssetDatabase.Refresh (ImportAssetOptions.ForceUpdate); + } + + if (guids.Length == 0) { + Asr.Fail (); + Report (typeName); + return null; + } + + foreach (var guid in guids) { + var path = AssetDatabase.GUIDToAssetPath (guid); + var asset = (T)AssetDatabase.LoadAssetAtPath (path, typeof (T)); + return asset; + } + + Report (typeName); + return null; + } + + static void Report (string typeName) { + Debug.LogError (string.Format ("Cannot find '{0}' (AUF style resource). Please try to remove AUF and import again, or restart Unity", typeName)); + } + } +} \ No newline at end of file diff --git a/Assets/Asset Usage Finder/Editor/AUFUtils.cs.meta b/Assets/Asset Usage Finder/Editor/AUFUtils.cs.meta new file mode 100644 index 00000000..58ec69ee --- /dev/null +++ b/Assets/Asset Usage Finder/Editor/AUFUtils.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 67f83d816cd4ba344a82ea0cf924e446 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Asset Usage Finder/Editor/Asr.cs b/Assets/Asset Usage Finder/Editor/Asr.cs new file mode 100644 index 00000000..1e501a1c --- /dev/null +++ b/Assets/Asset Usage Finder/Editor/Asr.cs @@ -0,0 +1,38 @@ +using System.Diagnostics; +using UnityEngine; +using UnityEngine.Assertions; + +namespace AssetUsageFinder { + static class FLAGS { + public const string DEBUG = "DEBUG1"; //todo rename in release + } + + static class Asr { +#line hidden + [Conditional(FLAGS.DEBUG)] + public static void AreEqual(int a, int b) { + Assert.AreEqual(a, b); + } + + [Conditional(FLAGS.DEBUG)] + public static void IsTrue(bool b, string format = null) { + Assert.IsTrue(b, format); + } + + [Conditional(FLAGS.DEBUG)] + public static void IsFalse(bool b, string format = null) { + Assert.IsFalse(b, format); + } + + [Conditional(FLAGS.DEBUG)] + public static void Fail(string format = null) { + throw new AssertionException("Failed", format); + } + + [Conditional(FLAGS.DEBUG)] + public static void IsNotNull(Object target, string str) { + Assert.IsNotNull(target, str); + } +#line default + } +} \ No newline at end of file diff --git a/Assets/Asset Usage Finder/Editor/Asr.cs.meta b/Assets/Asset Usage Finder/Editor/Asr.cs.meta new file mode 100644 index 00000000..09d645ce --- /dev/null +++ b/Assets/Asset Usage Finder/Editor/Asr.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 28cd7f324901405696fa9c87c25a1d2b +timeCreated: 1587623743 \ No newline at end of file diff --git a/Assets/Asset Usage Finder/Editor/Content.meta b/Assets/Asset Usage Finder/Editor/Content.meta new file mode 100644 index 00000000..0ce42f4a --- /dev/null +++ b/Assets/Asset Usage Finder/Editor/Content.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 2181b913e8042f54db8354b4302d01f2 +folderAsset: yes +timeCreated: 1467572757 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Asset Usage Finder/Editor/Content/Style.asset b/Assets/Asset Usage Finder/Editor/Content/Style.asset new file mode 100644 index 00000000..8a674812 --- /dev/null +++ b/Assets/Asset Usage Finder/Editor/Content/Style.asset @@ -0,0 +1,740 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 2a8038d7a393d814b887bec61ad77979, type: 3} + m_Name: Style + m_EditorClassIdentifier: + Pro: + LookupBtn: + Content: + m_Text: + m_Image: {fileID: 2800000, guid: 93880ab424857034481dd201068f1f3c, type: 3} + m_Tooltip: Look for dependencies in Project + Style: + m_Name: button + m_Normal: + m_Background: {fileID: 7619082074131061878, guid: 0000000000000000d000000000000000, + type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0.7058824, g: 0.7058824, b: 0.7058824, a: 1} + m_Hover: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 1, g: 1, b: 1, a: 1} + m_Active: + m_Background: {fileID: 5631187574603569090, guid: 0000000000000000d000000000000000, + type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0.7058824, g: 0.7058824, b: 0.7058824, a: 1} + m_Focused: + m_Background: {fileID: 5631187574603569090, guid: 0000000000000000d000000000000000, + type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0.7058824, g: 0.7058824, b: 0.7058824, a: 1} + m_OnNormal: + m_Background: {fileID: -4685157240802103863, guid: 0000000000000000d000000000000000, + type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0.9411765, g: 0.9411765, b: 0.9411765, a: 1} + m_OnHover: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 1, g: 1, b: 1, a: 1} + m_OnActive: + m_Background: {fileID: 4047951448802137905, guid: 0000000000000000d000000000000000, + type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 1, g: 1, b: 1, a: 1} + m_OnFocused: + m_Background: {fileID: 8556163245987529883, guid: 0000000000000000d000000000000000, + type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Border: + m_Left: 6 + m_Right: 6 + m_Top: 4 + m_Bottom: 4 + m_Margin: + m_Left: 4 + m_Right: 4 + m_Top: 3 + m_Bottom: 3 + m_Padding: + m_Left: 1 + m_Right: 1 + m_Top: 1 + m_Bottom: 3 + m_Overflow: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 1 + m_Font: {fileID: 0} + m_FontSize: 0 + m_FontStyle: 0 + m_Alignment: 4 + m_WordWrap: 0 + m_RichText: 0 + m_TextClipping: 1 + m_ImagePosition: 2 + m_ContentOffset: {x: 0, y: 0} + m_FixedWidth: 20 + m_FixedHeight: 20 + m_StretchWidth: 0 + m_StretchHeight: 0 + TabBreadcrumb0: + m_Name: GUIEditor.BreadcrumbLeft + m_Normal: + m_Background: {fileID: 8645626873510801130, guid: 0000000000000000d000000000000000, + type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0.705, g: 0.705, b: 0.705, a: 1} + m_Hover: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0.705, g: 0.705, b: 0.705, a: 1} + m_Active: + m_Background: {fileID: -4071144489119945478, guid: 0000000000000000d000000000000000, + type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0.705, g: 0.705, b: 0.705, a: 1} + m_Focused: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0.705, g: 0.705, b: 0.705, a: 1} + m_OnNormal: + m_Background: {fileID: -3855161947729212693, guid: 0000000000000000d000000000000000, + type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0.705, g: 0.705, b: 0.705, a: 1} + m_OnHover: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0.705, g: 0.705, b: 0.705, a: 1} + m_OnActive: + m_Background: {fileID: 4626433863934729146, guid: 0000000000000000d000000000000000, + type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0.705, g: 0.705, b: 0.705, a: 1} + m_OnFocused: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0.705, g: 0.705, b: 0.705, a: 1} + m_Border: + m_Left: 3 + m_Right: 10 + m_Top: 0 + m_Bottom: 0 + m_Margin: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_Padding: + m_Left: 5 + m_Right: 11 + m_Top: 2 + m_Bottom: 0 + m_Overflow: + m_Left: 6 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_Font: {fileID: 0} + m_FontSize: 0 + m_FontStyle: 0 + m_Alignment: 3 + m_WordWrap: 0 + m_RichText: 1 + m_TextClipping: 1 + m_ImagePosition: 0 + m_ContentOffset: {x: 0, y: -1} + m_FixedWidth: 0 + m_FixedHeight: 18 + m_StretchWidth: 0 + m_StretchHeight: 0 + TabBreadcrumb1: + m_Name: GUIEditor.BreadcrumbMid + m_Normal: + m_Background: {fileID: -5572395043393670061, guid: 0000000000000000d000000000000000, + type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0.705, g: 0.705, b: 0.705, a: 1} + m_Hover: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0.705, g: 0.705, b: 0.705, a: 1} + m_Active: + m_Background: {fileID: 7619446805891711926, guid: 0000000000000000d000000000000000, + type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0.705, g: 0.705, b: 0.705, a: 1} + m_Focused: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0.705, g: 0.705, b: 0.705, a: 1} + m_OnNormal: + m_Background: {fileID: -465409310786048726, guid: 0000000000000000d000000000000000, + type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0.705, g: 0.705, b: 0.705, a: 1} + m_OnHover: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0.705, g: 0.705, b: 0.705, a: 1} + m_OnActive: + m_Background: {fileID: 5201657687025341418, guid: 0000000000000000d000000000000000, + type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0.705, g: 0.705, b: 0.705, a: 1} + m_OnFocused: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0.705, g: 0.705, b: 0.705, a: 1} + m_Border: + m_Left: 10 + m_Right: 10 + m_Top: 0 + m_Bottom: 0 + m_Margin: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_Padding: + m_Left: 10 + m_Right: 10 + m_Top: 2 + m_Bottom: 0 + m_Overflow: + m_Left: 10 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_Font: {fileID: 0} + m_FontSize: 0 + m_FontStyle: 0 + m_Alignment: 3 + m_WordWrap: 0 + m_RichText: 1 + m_TextClipping: 1 + m_ImagePosition: 0 + m_ContentOffset: {x: 0, y: -1} + m_FixedWidth: 0 + m_FixedHeight: 18 + m_StretchWidth: 0 + m_StretchHeight: 0 + RowMainAssetBtn: + m_Name: button + m_Normal: + m_Background: {fileID: 7619082074131061878, guid: 0000000000000000d000000000000000, + type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0.7058824, g: 0.7058824, b: 0.7058824, a: 1} + m_Hover: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 1, g: 1, b: 1, a: 1} + m_Active: + m_Background: {fileID: -660027063019260353, guid: 0000000000000000d000000000000000, + type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0.7058824, g: 0.7058824, b: 0.7058824, a: 1} + m_Focused: + m_Background: {fileID: 6868133616650823125, guid: 0000000000000000d000000000000000, + type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0.7058824, g: 0.7058824, b: 0.7058824, a: 1} + m_OnNormal: + m_Background: {fileID: -4685157240802103863, guid: 0000000000000000d000000000000000, + type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0.9411765, g: 0.9411765, b: 0.9411765, a: 1} + m_OnHover: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 1, g: 1, b: 1, a: 1} + m_OnActive: + m_Background: {fileID: 568729325262407274, guid: 0000000000000000d000000000000000, + type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0.7058824, g: 0.7058824, b: 0.7058824, a: 1} + m_OnFocused: + m_Background: {fileID: 5631187574603569090, guid: 0000000000000000d000000000000000, + type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0.7058824, g: 0.7058824, b: 0.7058824, a: 1} + m_Border: + m_Left: 6 + m_Right: 6 + m_Top: 4 + m_Bottom: 4 + m_Margin: + m_Left: 4 + m_Right: 4 + m_Top: 3 + m_Bottom: 3 + m_Padding: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_Overflow: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 1 + m_Font: {fileID: 0} + m_FontSize: 0 + m_FontStyle: 0 + m_Alignment: 3 + m_WordWrap: 0 + m_RichText: 0 + m_TextClipping: 1 + m_ImagePosition: 0 + m_ContentOffset: {x: 0, y: 0} + m_FixedWidth: 0 + m_FixedHeight: 20 + m_StretchWidth: 1 + m_StretchHeight: 0 + Size: {x: 400, y: 800} + RowLabel: + m_Name: label + m_Normal: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0.7058824, g: 0.7058824, b: 0.7058824, a: 1} + m_Hover: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Active: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Focused: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnNormal: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnHover: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnActive: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnFocused: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Border: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_Margin: + m_Left: 4 + m_Right: 4 + m_Top: 2 + m_Bottom: 2 + m_Padding: + m_Left: 2 + m_Right: 2 + m_Top: 1 + m_Bottom: 2 + m_Overflow: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_Font: {fileID: 3459068928204737762, guid: 0000000000000000d000000000000000, + type: 0} + m_FontSize: 0 + m_FontStyle: 0 + m_Alignment: 0 + m_WordWrap: 0 + m_RichText: 0 + m_TextClipping: 1 + m_ImagePosition: 0 + m_ContentOffset: {x: 0, y: 0} + m_FixedWidth: 0 + m_FixedHeight: 0 + m_StretchWidth: 1 + m_StretchHeight: 0 + Personal: + LookupBtn: + Content: + m_Text: + m_Image: {fileID: 2800000, guid: 48b12aa9f8e67a5419b212fcae22754b, type: 3} + m_Tooltip: Look for dependencies in Project + Style: + m_Name: button + m_Normal: + m_Background: {fileID: -573041650897247223, guid: 0000000000000000d000000000000000, + type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Hover: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Active: + m_Background: {fileID: -7527060558648309217, guid: 0000000000000000d000000000000000, + type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Focused: + m_Background: {fileID: 7832598784815925287, guid: 0000000000000000d000000000000000, + type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 1, g: 1, b: 1, a: 1} + m_OnNormal: + m_Background: {fileID: -4454209017672384243, guid: 0000000000000000d000000000000000, + type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 1, g: 1, b: 1, a: 1} + m_OnHover: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 1, g: 1, b: 1, a: 1} + m_OnActive: + m_Background: {fileID: 4047951448802137905, guid: 0000000000000000d000000000000000, + type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 1, g: 1, b: 1, a: 1} + m_OnFocused: + m_Background: {fileID: 8556163245987529883, guid: 0000000000000000d000000000000000, + type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Border: + m_Left: 6 + m_Right: 6 + m_Top: 4 + m_Bottom: 4 + m_Margin: + m_Left: 4 + m_Right: 4 + m_Top: 3 + m_Bottom: 3 + m_Padding: + m_Left: 1 + m_Right: 1 + m_Top: 1 + m_Bottom: 3 + m_Overflow: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 1 + m_Font: {fileID: 0} + m_FontSize: 0 + m_FontStyle: 0 + m_Alignment: 4 + m_WordWrap: 0 + m_RichText: 0 + m_TextClipping: 1 + m_ImagePosition: 2 + m_ContentOffset: {x: 0, y: 0} + m_FixedWidth: 20 + m_FixedHeight: 20 + m_StretchWidth: 0 + m_StretchHeight: 0 + TabBreadcrumb0: + m_Name: GUIEditor.BreadcrumbLeft + m_Normal: + m_Background: {fileID: -8730859949539617441, guid: 0000000000000000d000000000000000, + type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Hover: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Active: + m_Background: {fileID: 3607839988326647129, guid: 0000000000000000d000000000000000, + type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Focused: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnNormal: + m_Background: {fileID: -2909435724611740479, guid: 0000000000000000d000000000000000, + type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnHover: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnActive: + m_Background: {fileID: 658594365626841568, guid: 0000000000000000d000000000000000, + type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnFocused: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Border: + m_Left: 3 + m_Right: 10 + m_Top: 0 + m_Bottom: 0 + m_Margin: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_Padding: + m_Left: 5 + m_Right: 11 + m_Top: 2 + m_Bottom: 0 + m_Overflow: + m_Left: 6 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_Font: {fileID: 0} + m_FontSize: 0 + m_FontStyle: 0 + m_Alignment: 3 + m_WordWrap: 0 + m_RichText: 1 + m_TextClipping: 1 + m_ImagePosition: 0 + m_ContentOffset: {x: 0, y: -1} + m_FixedWidth: 0 + m_FixedHeight: 18 + m_StretchWidth: 0 + m_StretchHeight: 0 + TabBreadcrumb1: + m_Name: GUIEditor.BreadcrumbMid + m_Normal: + m_Background: {fileID: 298390163510713244, guid: 0000000000000000d000000000000000, + type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Hover: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Active: + m_Background: {fileID: -5694940394960273964, guid: 0000000000000000d000000000000000, + type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Focused: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnNormal: + m_Background: {fileID: 4917697211602105510, guid: 0000000000000000d000000000000000, + type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnHover: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnActive: + m_Background: {fileID: 2726902712204841013, guid: 0000000000000000d000000000000000, + type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnFocused: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Border: + m_Left: 10 + m_Right: 10 + m_Top: 0 + m_Bottom: 0 + m_Margin: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_Padding: + m_Left: 10 + m_Right: 10 + m_Top: 2 + m_Bottom: 0 + m_Overflow: + m_Left: 10 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_Font: {fileID: 0} + m_FontSize: 0 + m_FontStyle: 0 + m_Alignment: 3 + m_WordWrap: 0 + m_RichText: 1 + m_TextClipping: 1 + m_ImagePosition: 0 + m_ContentOffset: {x: 0, y: -1} + m_FixedWidth: 0 + m_FixedHeight: 18 + m_StretchWidth: 0 + m_StretchHeight: 0 + RowMainAssetBtn: + m_Name: button + m_Normal: + m_Background: {fileID: -573041650897247223, guid: 0000000000000000d000000000000000, + type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Hover: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Active: + m_Background: {fileID: -7527060558648309217, guid: 0000000000000000d000000000000000, + type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Focused: + m_Background: {fileID: 7832598784815925287, guid: 0000000000000000d000000000000000, + type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 1, g: 1, b: 1, a: 1} + m_OnNormal: + m_Background: {fileID: -4454209017672384243, guid: 0000000000000000d000000000000000, + type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 1, g: 1, b: 1, a: 1} + m_OnHover: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 1, g: 1, b: 1, a: 1} + m_OnActive: + m_Background: {fileID: 4047951448802137905, guid: 0000000000000000d000000000000000, + type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 1, g: 1, b: 1, a: 1} + m_OnFocused: + m_Background: {fileID: 8556163245987529883, guid: 0000000000000000d000000000000000, + type: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Border: + m_Left: 6 + m_Right: 6 + m_Top: 4 + m_Bottom: 4 + m_Margin: + m_Left: 4 + m_Right: 4 + m_Top: 3 + m_Bottom: 3 + m_Padding: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_Overflow: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 1 + m_Font: {fileID: 0} + m_FontSize: 0 + m_FontStyle: 0 + m_Alignment: 3 + m_WordWrap: 0 + m_RichText: 0 + m_TextClipping: 1 + m_ImagePosition: 0 + m_ContentOffset: {x: 0, y: 0} + m_FixedWidth: 0 + m_FixedHeight: 20 + m_StretchWidth: 1 + m_StretchHeight: 0 + Size: {x: 400, y: 800} + RowLabel: + m_Name: label + m_Normal: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Hover: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Active: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_Focused: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 0.01960784} + m_OnNormal: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnHover: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 1} + m_OnActive: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 0.01960784} + m_OnFocused: + m_Background: {fileID: 0} + m_ScaledBackgrounds: [] + m_TextColor: {r: 0, g: 0, b: 0, a: 0.01960784} + m_Border: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_Margin: + m_Left: 4 + m_Right: 4 + m_Top: 2 + m_Bottom: 2 + m_Padding: + m_Left: 2 + m_Right: 2 + m_Top: 1 + m_Bottom: 2 + m_Overflow: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_Font: {fileID: 3459068928204737762, guid: 0000000000000000d000000000000000, + type: 0} + m_FontSize: 0 + m_FontStyle: 0 + m_Alignment: 3 + m_WordWrap: 0 + m_RichText: 0 + m_TextClipping: 1 + m_ImagePosition: 0 + m_ContentOffset: {x: 0, y: 0} + m_FixedWidth: 0 + m_FixedHeight: 0 + m_StretchWidth: 1 + m_StretchHeight: 0 diff --git a/Assets/Asset Usage Finder/Editor/Content/Style.asset.meta b/Assets/Asset Usage Finder/Editor/Content/Style.asset.meta new file mode 100644 index 00000000..1f40b99f --- /dev/null +++ b/Assets/Asset Usage Finder/Editor/Content/Style.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 939dee46ae9eef044b454d9a2f64719d +timeCreated: 1467571796 +licenseType: Store +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Asset Usage Finder/Editor/Content/lookup.png b/Assets/Asset Usage Finder/Editor/Content/lookup.png new file mode 100644 index 00000000..acbb90d5 --- /dev/null +++ b/Assets/Asset Usage Finder/Editor/Content/lookup.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:18b9b7ca6e7aa4a5e7d4567c1ae7a567dd44f9888be9b3c0f3b919b7eb9c830b +size 16712 diff --git a/Assets/Asset Usage Finder/Editor/Content/lookup.png.meta b/Assets/Asset Usage Finder/Editor/Content/lookup.png.meta new file mode 100644 index 00000000..9e4d5be7 --- /dev/null +++ b/Assets/Asset Usage Finder/Editor/Content/lookup.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: 48b12aa9f8e67a5419b212fcae22754b +timeCreated: 1487778797 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 1 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: 1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 2 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Asset Usage Finder/Editor/Content/lookup_pro.png b/Assets/Asset Usage Finder/Editor/Content/lookup_pro.png new file mode 100644 index 00000000..b92bceb9 --- /dev/null +++ b/Assets/Asset Usage Finder/Editor/Content/lookup_pro.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:98f76a797ba192b503ce7f558893e9840b9345fe86bb64afce8e0dc3f57c9ef5 +size 2812 diff --git a/Assets/Asset Usage Finder/Editor/Content/lookup_pro.png.meta b/Assets/Asset Usage Finder/Editor/Content/lookup_pro.png.meta new file mode 100644 index 00000000..40989838 --- /dev/null +++ b/Assets/Asset Usage Finder/Editor/Content/lookup_pro.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: 93880ab424857034481dd201068f1f3c +timeCreated: 1467572760 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 1 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: 1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 2 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Asset Usage Finder/Editor/Data.meta b/Assets/Asset Usage Finder/Editor/Data.meta new file mode 100644 index 00000000..3a87dfcd --- /dev/null +++ b/Assets/Asset Usage Finder/Editor/Data.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: acc929cd151e60c4eaec2a88e8c36274 +folderAsset: yes +timeCreated: 1488097356 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Asset Usage Finder/Editor/Data/AssetDependencies.cs b/Assets/Asset Usage Finder/Editor/Data/AssetDependencies.cs new file mode 100644 index 00000000..3019fbe3 --- /dev/null +++ b/Assets/Asset Usage Finder/Editor/Data/AssetDependencies.cs @@ -0,0 +1,25 @@ +using System; +using System.Linq; +using UnityEngine; + +namespace AssetUsageFinder { + [Serializable] + public class AssetDependencies { + public string[] DependencyGuids; + public string HashString; + + [NonSerialized] Hash128 _hashCache; + + public Hash128 DependencyHash { + get { return _hashCache.Equals(default(Hash128)) ? Hash128.Parse(HashString) : _hashCache; } + set { + _hashCache = value; + HashString = value.ToString(); + } + } + + public bool Contains(string guid) { + return DependencyGuids.Any(d => StringComparer.InvariantCultureIgnoreCase.Equals(guid, d)); + } + } +} \ No newline at end of file diff --git a/Assets/Asset Usage Finder/Editor/Data/AssetDependencies.cs.meta b/Assets/Asset Usage Finder/Editor/Data/AssetDependencies.cs.meta new file mode 100644 index 00000000..631a952f --- /dev/null +++ b/Assets/Asset Usage Finder/Editor/Data/AssetDependencies.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b4b690bbffa63544f9cc84b6b0bcbf18 +timeCreated: 1486474181 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Asset Usage Finder/Editor/Data/CacheManager.cs b/Assets/Asset Usage Finder/Editor/Data/CacheManager.cs new file mode 100644 index 00000000..92dbb267 --- /dev/null +++ b/Assets/Asset Usage Finder/Editor/Data/CacheManager.cs @@ -0,0 +1,131 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using UnityEditor; +using UnityEngine; + +namespace AssetUsageFinder { + public class CacheManager { + Dictionary _dict; + HashSet _used; + + // [MenuItem("Tools/LogPath")] + static void Log() { + Debug.Log(Application.temporaryCachePath); + } + + public CacheManager() { + _dict = new Dictionary(StringComparer.InvariantCultureIgnoreCase); + _used = new HashSet(StringComparer.InvariantCultureIgnoreCase); + } + + public void Init() { + var serializable = Deserialize(); + _dict = serializable.OnDeserialize(); + } + + static SerializableData Deserialize() { + SerializableData data; + string json; + + if (!File.Exists(Path)) { + // not exists - write new + data = SerializableData.Empty(); + json = JsonUtility.ToJson(data); + File.WriteAllText(Path, json); + } + else { + // exists + json = File.ReadAllText(Path); + + if (string.IsNullOrEmpty(json)) { + // but corrupted - overwrite with new + data = SerializableData.Empty(); + json = JsonUtility.ToJson(data); + File.WriteAllText(Path, json); + } + + data = JsonUtility.FromJson(json); + if (!SerializableData.Valid(data)) { + // but corrupted - overwrite with new + data = SerializableData.Empty(); + json = JsonUtility.ToJson(data); + File.WriteAllText(Path, json); + } + // todo assert valid + } + + return data; + } + + static string Path => $"{Application.temporaryCachePath}/AssetUsageFinder4.json"; + + public void Serialize() { + var data = SerializableData.OnSerialize(_dict); + var json = JsonUtility.ToJson(data); + File.WriteAllText(Path, json); + } + + internal AssetDependencies Get(string path, string guid) { + _used.Add(guid); + if (_dict.TryGetValue(guid, out var res)) { + var assetDependencyHash = AssetDatabase.GetAssetDependencyHash(path); + + if (assetDependencyHash.isValid && res.DependencyHash == assetDependencyHash) { + return res; + } + + res = HashByPath(); + _dict[guid] = res; + return res; + } + + res = HashByPath(); + _dict.Add(guid, res); + return res; + + AssetDependencies HashByPath() { + var dependencyPaths = AssetDatabase.GetDependencies(path, recursive: false); + var guids = dependencyPaths.Select(AssetDatabase.AssetPathToGUID).ToArray(); + return new AssetDependencies { + DependencyGuids = guids, + DependencyHash = AssetDatabase.GetAssetDependencyHash(path), + }; + } + } + + [Serializable] + public class SerializableData { + public const int CurrentVersion = 7; // for cache invalidation + + public int Version; + public string[] Keys; + public AssetDependencies[] Values; + + public static SerializableData Empty() => new SerializableData() { + Keys = new string[0], + Values = new AssetDependencies[0], + Version = CurrentVersion, + }; + + public static SerializableData OnSerialize(Dictionary dict) { + return new SerializableData() { + Keys = dict.Keys.ToArray(), + Values = dict.Values.ToArray(), + Version = CurrentVersion, + }; + } + + public Dictionary OnDeserialize() { + var res = new Dictionary(StringComparer.InvariantCultureIgnoreCase); + var keysLength = Keys.Length; + for (var i = 0; i < keysLength; i++) res.Add(Keys[i], Values[i]); + return res; + } + + public static bool Valid(SerializableData that) => + that != null && CurrentVersion == that.Version && that.Keys != null && that.Values != null && that.Keys.Length == that.Values.Length; + } + } +} \ No newline at end of file diff --git a/Assets/Asset Usage Finder/Editor/Data/CacheManager.cs.meta b/Assets/Asset Usage Finder/Editor/Data/CacheManager.cs.meta new file mode 100644 index 00000000..c3ffa238 --- /dev/null +++ b/Assets/Asset Usage Finder/Editor/Data/CacheManager.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e70f0d094b7379b45a36f7fc76809b0a +timeCreated: 1486465336 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Asset Usage Finder/Editor/Data/DependencyAbstractFinder.cs b/Assets/Asset Usage Finder/Editor/Data/DependencyAbstractFinder.cs new file mode 100644 index 00000000..d9ac783b --- /dev/null +++ b/Assets/Asset Usage Finder/Editor/Data/DependencyAbstractFinder.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; +using Object = UnityEngine.Object; + +namespace AssetUsageFinder { + [Serializable] + abstract class DependencyAbstractFinder { + public SearchTarget Target; + public ResultRow[] Dependencies; + public GUIContent TabContent; + public DependencyAbstractFinder Parent; + public string Title = ""; + + public List Parents() { + var res = new List(); + for (var cur = this; cur != null; cur = cur.Parent) + res.Add(cur); + return res; + } + + public IEnumerable Group(IEnumerable inScenePro) { + ResultRow cur = null; + var res = new List(); + var list = inScenePro.OrderBy(t => t.Main.GetInstanceID()); + var modificationsString = "Object.Modification.Modifications"; + var correpsondingString = "CorrespondingSourceObject"; + var gameObjectString = "GameObject"; + foreach (var source in list.ToList()) { + if (cur == null || cur.Main != source.Main) { + cur = source; + var buf = source.Properties.Where(p => + !p.Content.text.Contains(gameObjectString) && + !p.Content.text.Contains(modificationsString) && + !p.Content.text.Contains(correpsondingString)).ToList(); + cur.Properties = buf; + res.Add(cur); + } + else { + foreach (var item in source.Properties) { + if ( + !item.Content.text.Contains(gameObjectString) && + !item.Content.text.Contains(modificationsString) && + !item.Content.text.Contains(correpsondingString) && + !cur.Properties.Any(p => + p.Content.text == item.Content.text && + p.Content.tooltip == p.Content.tooltip)) { + cur.Properties.Add(item); + } + } + } + } + + return res; + } + + public abstract void FindDependencies(); + public abstract DependencyAbstractFinder Nest(Object o); + } +} \ No newline at end of file diff --git a/Assets/Asset Usage Finder/Editor/Data/DependencyAbstractFinder.cs.meta b/Assets/Asset Usage Finder/Editor/Data/DependencyAbstractFinder.cs.meta new file mode 100644 index 00000000..eaf1e5fc --- /dev/null +++ b/Assets/Asset Usage Finder/Editor/Data/DependencyAbstractFinder.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 25951e74c3fd1cd40863089a51c157ce +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Asset Usage Finder/Editor/Data/DependencyFinderEngine.cs b/Assets/Asset Usage Finder/Editor/Data/DependencyFinderEngine.cs new file mode 100644 index 00000000..b4880ff4 --- /dev/null +++ b/Assets/Asset Usage Finder/Editor/Data/DependencyFinderEngine.cs @@ -0,0 +1,381 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using UnityEditor; +using UnityEditor.Animations; + +using UnityEngine; +using UnityEngine.SceneManagement; +using Object = UnityEngine.Object; + +namespace AssetUsageFinder { + static class DependencyFinderEngine { + #region Private + + const string AssetsRootPath = "Assets/"; + static double _cachedTime; + + static bool NeedsUpdate { + get { + var t = _cachedTime; + _cachedTime = EditorApplication.timeSinceStartup; + var result = _cachedTime - t > 0.03; + return result; + } + } + + static Option GenerateResultRowByObject(SearchTarget target, Object c, bool isScene = true) { + var so = new SerializedObject(c); + var sp = so.GetIterator(); + ResultRow row = null; + while (sp.Next(enterChildren: true)) { + string transformPath = string.Empty; + if (sp.propertyType != SerializedPropertyType.ObjectReference) continue; + if (!target.Check(sp.objectReferenceValue)) continue; + if (row == null) { + row = new ResultRow { + Root = c, + Target = c, + SerializedObject = so + }; + + if (isScene) { + var component = c as Component; + if (component) { + row.Main = component.gameObject; + } + else { + var o = c as GameObject; + if (o != null) { + row.Main = o; + } + } + + var go = row.Main as GameObject; + // Assert.NotNull(go); + row.LabelContent.text = AnimationUtility.CalculateTransformPath(go.transform, null); + row.LabelContent.image = AssetPreview.GetMiniThumbnail(go); + } + else { + var path = AssetDatabase.GetAssetPath(c); + row.Main = AssetDatabase.LoadMainAssetAtPath(path); + + var mainType = PrefabUtility.GetPrefabAssetType(row.Main); + + if (mainType != PrefabAssetType.NotAPrefab) { + var comp = row.Target as Component; + if (comp) { + try { + transformPath = string.Format("{0}/", AnimationUtility.CalculateTransformPath(comp.transform, null)).Replace("/", "/\n"); + } + catch { + // ignored + } + } + } + + row.LabelContent.text = path.Replace(AssetsRootPath, string.Empty); + row.LabelContent.image = AssetDatabase.GetCachedIcon(path); + } + } + + Texture2D miniTypeThumbnail = row.Main == c ? null : AssetPreview.GetMiniThumbnail(c); + + row.Properties.Add(new ResultRow.PropertyData { + Property = sp.Copy(), + Content = new GUIContent { + image = miniTypeThumbnail, + text = Nicify(sp, sp.serializedObject.targetObject, row.Main, target), + tooltip = string.Format("{2}{0}.{1}", sp.serializedObject.targetObject.GetType().Name, sp.propertyPath, transformPath) + } + }); + } + + if (row == null) + so.Dispose(); + return row; + } + + + public static IEnumerable<(int state, string crumbs)> Traverse(AnimatorController controller) { + for (var index = 0; index < controller.layers.Length; index++) { + var controllerLayer = controller.layers[index]; + foreach (var i in Inner(controllerLayer.stateMachine, $"{controllerLayer.name}({index})")) + yield return i; + } + } + + static IEnumerable<(int state, string crumbs)> Inner(AnimatorStateMachine f, string crumbs) { + foreach (var state in f.states) + yield return (state.state.GetInstanceID(), crumbs); + + foreach (var child in f.stateMachines) { + foreach (var tuple in Inner(child.stateMachine, $"{crumbs}/{child.stateMachine.name}")) + yield return tuple; + } + } + + // todo use GetInstanceID instead of unityobj refs + static Dictionary> _animCache = new Dictionary>(); + + static string GetBread(AnimatorController c, AnimatorState state) { + if (!_animCache.TryGetValue(c.GetInstanceID(), out var res)) { + res = new Dictionary(); + _animCache.Add(c.GetInstanceID(), res); + foreach (var (stateId, crumbs) in Traverse(c)) + res.Add(stateId, crumbs); + } + + if (res.TryGetValue(state.GetInstanceID(), out var crumb)) + return $"{crumb}/"; + return string.Empty; + } + + static string Nicify(SerializedProperty sp, Object o, Object main, SearchTarget target) { + // return sp.propertyPath; + + string nice = string.Empty; + switch (o) { + case AnimatorController _: { + return Nice(sp.propertyPath); + } + + case BlendTree blendTree: { + return $"{blendTree.name}({o.GetType().Name})"; + } + + case AnimatorState animatorState: { + if (main is AnimatorController animatorController) { + var bread = GetBread(animatorController, animatorState); + return $"{bread}{animatorState.name}"; + } + + break; + } + case StateMachineBehaviour smb: { + var ctx = AnimatorController.FindStateMachineBehaviourContext(smb); + if (ctx.Length == 0) + break; + + var first = ctx[0]; + var bread = string.Empty; + switch (first.animatorObject) { + case AnimatorStateMachine _: + // nothing + break; + case AnimatorState ast: { + bread = GetBread(first.animatorController, ast); + break; + } + } + + return $"{bread}{first.animatorObject.name}"; + } + case Material _: + nice = sp.displayName; + break; + default: { + nice = Nice(sp.propertyPath); + break; + } + } + + nice = string.Format("{0}.{1}", o.GetType().Name, nice); + return nice; + } + + static string Nice(string path) { + var nice = path.Replace(".Array.data", string.Empty); + if (nice.IndexOf(".m_PersistentCalls.m_Calls", StringComparison.Ordinal) > 0) { + nice = nice.Replace(".m_PersistentCalls.m_Calls", string.Empty) + .Replace(".m_Target", string.Empty); + } + + + if (nice.StartsWith("m_", StringComparison.Ordinal)) + nice = nice.Replace("m_", string.Empty); + + nice = nice.Split('.').Select(t => ObjectNames.NicifyVariableName(t).Replace(" ", string.Empty)).Aggregate((a, b) => a + "." + b); + return nice; + } + + public static IEnumerable AsEnumerable(T o) { + yield return o; + } + + #endregion + + #region Project + + static HashSet GetDependencies(Object activeObject) { + var targetPath = AssetDatabase.GetAssetPath(activeObject); + var targetGuid = AssetDatabase.AssetPathToGUID(targetPath); + var objectGuids = AssetDatabase.FindAssets("t:Object"); + var results = new HashSet(StringComparer.Ordinal); + var total = objectGuids.LongLength; + var cache = Globals.Get(); + try { + for (int i = 0; i < total; i++) { + var path = AssetDatabase.GUIDToAssetPath(objectGuids[i]); + var res = cache.Get(path, objectGuids[i]); + + if (path.Contains(".unity")) + continue; + + if (res.Contains(targetGuid)) + results.Add(path); + + if (!NeedsUpdate) continue; + + if (EditorUtility.DisplayCancelableProgressBar("Generating cache", "Searching for file usages", (float) i / total)) + break; + } + } + finally { + cache.Serialize(); + EditorUtility.ClearProgressBar(); + } + + results.Remove(targetPath); + return results; + } + + public static IEnumerable GetFilesThatReference(SearchTarget target) { + return GetDependencies(target.Target) + .SelectMany(p => AssetDatabase.LoadAllAssetsAtPath(p)) + .Where(t => t && !(t is DefaultAsset) && !(t is Transform)) + .Select(asset => GenerateResultRowByObject(target, asset, false)) + .Where(row => row.HasValue) + .Select(r => r.GetOrFail()); + } + + public static HashSet GetScenesThatContain(Object activeObject) { + var targetPath = AssetDatabase.GetAssetPath(activeObject); + var targetGuid = AssetDatabase.AssetPathToGUID(targetPath); + + var results = new HashSet(StringComparer.Ordinal); + var sceneGuids = AssetDatabase.FindAssets("t:Scene"); + + var total = sceneGuids.LongLength; + + var cache = Globals.Get(); + try { + for (int i = 0; i < total; i++) { + var path = AssetDatabase.GUIDToAssetPath(sceneGuids[i]); + var res = cache.Get(path, sceneGuids[i]); + + if (res.Contains(targetGuid)) + results.Add(path); + + if (!NeedsUpdate) continue; + + if (EditorUtility.DisplayCancelableProgressBar("Searching for file usages in scenes..", path, (float) i / total)) + break; + } + } + finally { + cache.Serialize(); + EditorUtility.ClearProgressBar(); + } + + EditorUtility.ClearProgressBar(); + results.Remove(targetPath); + return results; + } + + #endregion Project + + public static IEnumerable GetDependenciesInScene(SearchTarget target) { + var referencedBy = new List(); + + for (int ii = 0; ii < SceneManager.sceneCount; ii++) { + var currentScene = SceneManager.GetSceneAt(ii); + + if (!currentScene.IsValid() || !currentScene.isLoaded) + continue; + + var allObjects = currentScene + .GetRootGameObjects() + .SelectMany(g => { + if (g != target.Target) + return g.GetComponentsInChildren(true) + .Where(FilterComponents).Union(AsEnumerable(g as Object)); + return g.GetComponentsInChildren(true).Where(FilterComponents); + }) + .Where(t => t) + .ToArray(); + var total = allObjects.Length; + + var step = total / 5; + + try { + if (target.Nested.TryGet(out var nested)) + foreach (var n in nested) { + var searchTarget = SearchTarget.CreateSceneNested(n); + for (var i = 0; i < total; i++) { + var comp = allObjects[i]; + if (!GenerateResultRowByObject(target, comp).TryGet(out var res)) + continue; + + if (res != null && target.Target != res.Main) + referencedBy.Add(res); + + if (!GenerateResultRowByObject(searchTarget, comp).TryGet(out var resultNested)) + continue; + + if (resultNested != null && searchTarget.Target != resultNested.Main) + referencedBy.Add(resultNested); + + if (step == 0) continue; + if (i % step != 0) continue; + if (EditorUtility.DisplayCancelableProgressBar("Searching for file usages in current scene..", target.Target.name, (float) i / total)) + break; + } + } + } + finally { + EditorUtility.ClearProgressBar(); + } + } + + return referencedBy.Distinct().ToList(); + } + + static bool FilterComponents(Component c) { + switch (c) { + case Transform _: + return false; + default: + return true; + } + } + + public static IEnumerable GetDependenciesInStage(SearchTarget target, UnityEditor.SceneManagement.PrefabStage stage) { + var referencedBy = new List(); + + var allObjects = stage.scene + .GetRootGameObjects() + .SelectMany(g => { + if (g != target.Target) + return g.GetComponentsInChildren(true).Where(FilterComponents).Union(AsEnumerable(g as Object)); + return g.GetComponentsInChildren(true).Where(FilterComponents); + }).ToArray(); + var total = allObjects.Length; + for (int i = 0; i < total; i++) { + var comp = allObjects[i]; + if (!GenerateResultRowByObject(target, comp).TryGet(out var res)) + continue; + + referencedBy.Add(res); + + if (EditorUtility.DisplayCancelableProgressBar("Searching for file usages in current scene..", target.Target.name, (float) i / total)) + break; + } + + EditorUtility.ClearProgressBar(); + + + return referencedBy; + } + } +} \ No newline at end of file diff --git a/Assets/Asset Usage Finder/Editor/Data/DependencyFinderEngine.cs.meta b/Assets/Asset Usage Finder/Editor/Data/DependencyFinderEngine.cs.meta new file mode 100644 index 00000000..7bc619f9 --- /dev/null +++ b/Assets/Asset Usage Finder/Editor/Data/DependencyFinderEngine.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8a6622c947e860548bd95915e407658e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Asset Usage Finder/Editor/Data/FileDependencyFinder.cs b/Assets/Asset Usage Finder/Editor/Data/FileDependencyFinder.cs new file mode 100644 index 00000000..0b87d1ad --- /dev/null +++ b/Assets/Asset Usage Finder/Editor/Data/FileDependencyFinder.cs @@ -0,0 +1,43 @@ +using System; +using System.Diagnostics; +using System.Linq; +using UnityEditor; +using UnityEngine; +using Object = UnityEngine.Object; +using UnityEngine.Assertions; + +namespace AssetUsageFinder { + [Serializable] + sealed class FileDependencyFinder : DependencyAbstractFinder { + public class Pair { + public string NicifiedPath; + public string Path; + } + + public Pair[] ScenePaths; + + public FileDependencyFinder(Object target) { + Asr.IsTrue(target, "Asset you're trying to search is corrupted"); + Target = SearchTarget.CreateFile(target); + FindDependencies(); + var path = AssetDatabase.GetAssetPath(Target.Target); + Title = path; + TabContent = new GUIContent { + text = target.name, + image = AssetDatabase.GetCachedIcon(path) + }; + } + + + public override void FindDependencies() { + var files = DependencyFinderEngine.GetFilesThatReference(Target); + Dependencies = Group(files.Where(f => !(f.Target is SceneAsset))) + .OrderBy(t => t.LabelContent.text, StringComparer.Ordinal) + .ToArray(); + } + + public override DependencyAbstractFinder Nest(Object o) { + return new FileDependencyFinder(o) {Parent = this}; + } + } +} \ No newline at end of file diff --git a/Assets/Asset Usage Finder/Editor/Data/FileDependencyFinder.cs.meta b/Assets/Asset Usage Finder/Editor/Data/FileDependencyFinder.cs.meta new file mode 100644 index 00000000..f41b3a12 --- /dev/null +++ b/Assets/Asset Usage Finder/Editor/Data/FileDependencyFinder.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2c4b883461f4461438dae02eba435811 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Asset Usage Finder/Editor/Data/Globals.cs b/Assets/Asset Usage Finder/Editor/Data/Globals.cs new file mode 100644 index 00000000..c084abed --- /dev/null +++ b/Assets/Asset Usage Finder/Editor/Data/Globals.cs @@ -0,0 +1,21 @@ +using System; + +namespace AssetUsageFinder { + static class Globals where T : class { + static T _instance; + + public static void TryInit(Func ctor) { + if (_instance != null) return; + _instance = ctor.Invoke(); + } + + public static T Get() => _instance; + + public static T GetOrCreate(Func ctor) { + TryInit(ctor); + return _instance; + } + + public static void Set(T value) => _instance = value; + } +} \ No newline at end of file diff --git a/Assets/Asset Usage Finder/Editor/Data/Globals.cs.meta b/Assets/Asset Usage Finder/Editor/Data/Globals.cs.meta new file mode 100644 index 00000000..532b40c8 --- /dev/null +++ b/Assets/Asset Usage Finder/Editor/Data/Globals.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 2dee75149ff4451a979163c53566150c +timeCreated: 1587621466 \ No newline at end of file diff --git a/Assets/Asset Usage Finder/Editor/Data/InSceneDependencyFinder.cs b/Assets/Asset Usage Finder/Editor/Data/InSceneDependencyFinder.cs new file mode 100644 index 00000000..d787933f --- /dev/null +++ b/Assets/Asset Usage Finder/Editor/Data/InSceneDependencyFinder.cs @@ -0,0 +1,37 @@ +using System; +using System.Linq; +using UnityEditor; +using UnityEngine; +using Object = UnityEngine.Object; + +namespace AssetUsageFinder { + [Serializable] + sealed class InSceneDependencyFinder : DependencyAbstractFinder { + [SerializeField] string _scenePath; + + public InSceneDependencyFinder(Object target, string scenePath) { + Target = SearchTarget.CreateScene(target, scenePath); + _scenePath = scenePath; + Title = scenePath; + + var name = target is Component ? target.GetType().Name : target.name; + + TabContent = new GUIContent { + text = name, + image = AssetPreview.GetMiniTypeThumbnail(Target.Target.GetType()) ?? AssetPreview.GetMiniThumbnail(Target.Target) + }; + + FindDependencies(); + } + + public override void FindDependencies() { + var dependenciesInScene = DependencyFinderEngine.GetDependenciesInScene(Target); + Dependencies = Group(dependenciesInScene).ToArray(); + } + + + public override DependencyAbstractFinder Nest(Object o) { + return new InSceneDependencyFinder(o, _scenePath) {Parent = this}; + } + } +} \ No newline at end of file diff --git a/Assets/Asset Usage Finder/Editor/Data/InSceneDependencyFinder.cs.meta b/Assets/Asset Usage Finder/Editor/Data/InSceneDependencyFinder.cs.meta new file mode 100644 index 00000000..e8014fdd --- /dev/null +++ b/Assets/Asset Usage Finder/Editor/Data/InSceneDependencyFinder.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 925da3bd0dee034418ecb5cf800a3526 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Asset Usage Finder/Editor/Data/InStageDependencyFinder.cs b/Assets/Asset Usage Finder/Editor/Data/InStageDependencyFinder.cs new file mode 100644 index 00000000..18f53499 --- /dev/null +++ b/Assets/Asset Usage Finder/Editor/Data/InStageDependencyFinder.cs @@ -0,0 +1,39 @@ +using System; +using System.Linq; +using UnityEditor; + +using UnityEngine; +using Object = UnityEngine.Object; + +namespace AssetUsageFinder { + [Serializable] + sealed class InStageDependencyFinder : DependencyAbstractFinder { + [SerializeField] string _stagePath; + [SerializeField] UnityEditor.SceneManagement.PrefabStage _stage; + + public InStageDependencyFinder(Object target, string stagePath) { + Target = SearchTarget.CreateStage(target, stagePath); + _stagePath = stagePath; + _stage = Target.Stage; + Title = stagePath; + + var name = target is Component ? target.GetType().Name : target.name; + + TabContent = new GUIContent { + text = name, + image = AssetPreview.GetMiniTypeThumbnail(Target.Target.GetType()) ?? AssetPreview.GetMiniThumbnail(Target.Target) + }; + + FindDependencies(); + } + + public override void FindDependencies() { + Dependencies = Group(DependencyFinderEngine.GetDependenciesInStage(Target, _stage)).ToArray(); + } + + + public override DependencyAbstractFinder Nest(Object o) { + return new InStageDependencyFinder(o, _stagePath) {Parent = this}; + } + } +} \ No newline at end of file diff --git a/Assets/Asset Usage Finder/Editor/Data/InStageDependencyFinder.cs.meta b/Assets/Asset Usage Finder/Editor/Data/InStageDependencyFinder.cs.meta new file mode 100644 index 00000000..76d09cb1 --- /dev/null +++ b/Assets/Asset Usage Finder/Editor/Data/InStageDependencyFinder.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 584109c30c0a0d849bbc12ec89d8c597 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Asset Usage Finder/Editor/Data/ResultRow.cs b/Assets/Asset Usage Finder/Editor/Data/ResultRow.cs new file mode 100644 index 00000000..b8e62fe9 --- /dev/null +++ b/Assets/Asset Usage Finder/Editor/Data/ResultRow.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using UnityEditor; +using UnityEngine; +using Object = UnityEngine.Object; + +namespace AssetUsageFinder { + [Serializable] + class ResultRow { + [Serializable] + public class PropertyData { + public SerializedProperty Property; + public GUIContent Content; + } + + public Object Target; + public SerializedObject SerializedObject; + public List Properties = new List(); + public Object Root; + public GUIContent LabelContent = new GUIContent(); + public GUIContent PropertyFieldContent = new GUIContent(); + public Object Main; + } +} \ No newline at end of file diff --git a/Assets/Asset Usage Finder/Editor/Data/ResultRow.cs.meta b/Assets/Asset Usage Finder/Editor/Data/ResultRow.cs.meta new file mode 100644 index 00000000..6328f09d --- /dev/null +++ b/Assets/Asset Usage Finder/Editor/Data/ResultRow.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 40006b038ab829f4698bcebf3c1508f1 +timeCreated: 1467625979 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Asset Usage Finder/Editor/Data/SearchTarget.cs b/Assets/Asset Usage Finder/Editor/Data/SearchTarget.cs new file mode 100644 index 00000000..793a2f49 --- /dev/null +++ b/Assets/Asset Usage Finder/Editor/Data/SearchTarget.cs @@ -0,0 +1,119 @@ +using System; +using System.Linq; +using UnityEditor; + +using UnityEngine; +using UnityEngine.Assertions; +using UnityEngine.SceneManagement; +using static AssetUsageFinder.PrefabUtilities; +using Object = UnityEngine.Object; + +namespace AssetUsageFinder { + [Serializable] + class SearchTarget { + public static SearchTarget CreateStage(Object target, string sceneOrStagePath = null) { + return new SearchTarget(target, FindModeEnum.Stage, sceneOrStagePath); + } + + public static SearchTarget CreateFile(Object target, string sceneOrStagePath = null) { + return new SearchTarget(target, FindModeEnum.File, sceneOrStagePath); + } + + public static SearchTarget CreateScene(Object target, string sceneOrStagePath = null) { + return new SearchTarget(target, FindModeEnum.Scene, sceneOrStagePath); + } + + public static SearchTarget CreateSceneNested(Object target) { + return new SearchTarget(target, FindModeEnum.Scene) {IsNested = true}; + } + + public Object Target; + public Option Nested; + public Object Root; + public Scene Scene; + public UnityEditor.SceneManagement.PrefabStage Stage; + public bool IsNested; + + SearchTarget(Object target, FindModeEnum findMode, string sceneOrStagePath = null) { + Asr.IsNotNull(target, "Asset you're trying to search is corrupted"); + Target = target; + var path = sceneOrStagePath ?? AssetDatabase.GetAssetPath(Target); + switch (findMode) { + case FindModeEnum.File: { + Asr.IsTrue(string.IsNullOrEmpty(sceneOrStagePath)); + Root = AssetDatabase.LoadMainAssetAtPath(path); + if (!IsNested) + Nested = AufUtils.LoadAllAssetsAtPath(path); + if (AssetDatabase.GetMainAssetTypeAtPath(path).IsAssignableFrom(typeof(SceneAsset))) + Scene = SceneManager.GetSceneByPath(path); + } + break; + case FindModeEnum.Scene: + case FindModeEnum.Stage: { + Root = Target; + var asset = AssetDatabase.GetAssetPath(target); + if (Target is GameObject go) { + switch (PrefabUtility.GetPrefabAssetType(go)) { + case PrefabAssetType.Regular: + case PrefabAssetType.Variant: { + if (!IsNested) + Nested = string.IsNullOrEmpty(asset) ? go.GetComponents() : AssetDatabase.LoadAllAssetsAtPath(asset); + + break; + } + case PrefabAssetType.Model: { + if (!IsNested) + Nested = AssetDatabase.LoadAllAssetsAtPath(asset); + break; + } + case PrefabAssetType.MissingAsset: + case PrefabAssetType.NotAPrefab: + if (!IsNested) + Nested = go.GetComponents().Union(Enumerable.Repeat(Target, 1)).ToArray(); + break; + } + + Stage = UnityEditor.SceneManagement.PrefabStageUtility.GetCurrentPrefabStage(); + if (findMode == FindModeEnum.Scene) { + if (string.IsNullOrEmpty(sceneOrStagePath)) + sceneOrStagePath = go.scene.path; + Scene = SceneManager.GetSceneByPath(sceneOrStagePath); + } + } + else if (Target is Component c) { + // prefab instance + Nested = default; + if (findMode == FindModeEnum.Scene) { + if (string.IsNullOrEmpty(sceneOrStagePath)) + sceneOrStagePath = c.gameObject.scene.path; + Scene = SceneManager.GetSceneByPath(sceneOrStagePath); + } + } + else { + if (!IsNested) + Nested = AssetDatabase.LoadAllAssetsAtPath(asset); + + if (AssetDatabase.GetMainAssetTypeAtPath(path).IsAssignableFrom(typeof(SceneAsset))) + Scene = SceneManager.GetSceneByPath(path); + } + } + break; + } + + Asr.IsTrue(!IsNested || !Nested.HasValue); + } + + public bool Check(Object arg) { + if (arg == null || Target == null) return false; + if (arg == Target) return true; + if (!Nested.TryGet(out var n)) return false; + + var length = n.Length; + for (var i = 0; i < length; i++) + if (n[i] == arg) + return true; + + return false; + } + } +} \ No newline at end of file diff --git a/Assets/Asset Usage Finder/Editor/Data/SearchTarget.cs.meta b/Assets/Asset Usage Finder/Editor/Data/SearchTarget.cs.meta new file mode 100644 index 00000000..714a4609 --- /dev/null +++ b/Assets/Asset Usage Finder/Editor/Data/SearchTarget.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: f500aea056165bb4294b484f1c9623d3 +timeCreated: 1467656394 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Asset Usage Finder/Editor/DependencyWindow.cs b/Assets/Asset Usage Finder/Editor/DependencyWindow.cs new file mode 100644 index 00000000..b8d7b451 --- /dev/null +++ b/Assets/Asset Usage Finder/Editor/DependencyWindow.cs @@ -0,0 +1,266 @@ +using System; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; +using UnityEngine.SceneManagement; +using Object = UnityEngine.Object; +using System.Linq; +using AssetUsageFinder.Styles; +using UnityEditor.SceneManagement; + +namespace AssetUsageFinder { + class DependencyWindow : EditorWindow { + Vector2 _scrollPos; + [SerializeField] DependencyAbstractFinder _data; + [SerializeField] protected FindModeEnum _findMode; + bool _expandFiles = true; + bool _expandScenes = true; + static GUIContent _sceneIcon; + Rect _popupButtonRect; + PrevClick _click; + List _postponedActions; + + [Serializable] + public class Style { + public ContentStylePair LookupBtn = new ContentStylePair(); + public GUIStyle TabBreadcrumb0 = new GUIStyle(); + public GUIStyle TabBreadcrumb1 = new GUIStyle(); + public GUIStyle RowMainAssetBtn = new GUIStyle(); + public Vector2 Size = new Vector2(250f, 800f); + public GUIStyle RowLabel = new GUIStyle(); + + public static Style FindSelf() { + var res = AufUtils.FirstOfType(); + return EditorGUIUtility.isProSkin ? res.Pro : res.Personal; + } + } + + public static Style StyleInstance => Globals