添加缺失插件

This commit is contained in:
YXY
2026-03-03 18:24:17 +08:00
parent d43882c5cf
commit c979cd2a92
90 changed files with 5269 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
{
"name": "AssetUsageFinder",
"references": [],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": false,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 78166de3938470b4da415a0209d69308
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: a6cb38742b49c2543b9129cc5bc1959f
folderAsset: yes
timeCreated: 1464798283
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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<T> () 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));
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 67f83d816cd4ba344a82ea0cf924e446
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 28cd7f324901405696fa9c87c25a1d2b
timeCreated: 1587623743

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 2181b913e8042f54db8354b4302d01f2
folderAsset: yes
timeCreated: 1467572757
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 939dee46ae9eef044b454d9a2f64719d
timeCreated: 1467571796
licenseType: Store
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/Asset Usage Finder/Editor/Content/lookup.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@@ -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:

BIN
Assets/Asset Usage Finder/Editor/Content/lookup_pro.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@@ -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:

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: acc929cd151e60c4eaec2a88e8c36274
folderAsset: yes
timeCreated: 1488097356
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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));
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: b4b690bbffa63544f9cc84b6b0bcbf18
timeCreated: 1486474181
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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<string, AssetDependencies> _dict;
HashSet<string> _used;
// [MenuItem("Tools/LogPath")]
static void Log() {
Debug.Log(Application.temporaryCachePath);
}
public CacheManager() {
_dict = new Dictionary<string, AssetDependencies>(StringComparer.InvariantCultureIgnoreCase);
_used = new HashSet<string>(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<SerializableData>(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<string, AssetDependencies> dict) {
return new SerializableData() {
Keys = dict.Keys.ToArray(),
Values = dict.Values.ToArray(),
Version = CurrentVersion,
};
}
public Dictionary<string, AssetDependencies> OnDeserialize() {
var res = new Dictionary<string, AssetDependencies>(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;
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: e70f0d094b7379b45a36f7fc76809b0a
timeCreated: 1486465336
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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<DependencyAbstractFinder> Parents() {
var res = new List<DependencyAbstractFinder>();
for (var cur = this; cur != null; cur = cur.Parent)
res.Add(cur);
return res;
}
public IEnumerable<ResultRow> Group(IEnumerable<ResultRow> inScenePro) {
ResultRow cur = null;
var res = new List<ResultRow>();
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);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 25951e74c3fd1cd40863089a51c157ce
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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<ResultRow> 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<int, Dictionary<int, string>> _animCache = new Dictionary<int, Dictionary<int, string>>();
static string GetBread(AnimatorController c, AnimatorState state) {
if (!_animCache.TryGetValue(c.GetInstanceID(), out var res)) {
res = new Dictionary<int, string>();
_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<T> AsEnumerable<T>(T o) {
yield return o;
}
#endregion
#region Project
static HashSet<string> GetDependencies(Object activeObject) {
var targetPath = AssetDatabase.GetAssetPath(activeObject);
var targetGuid = AssetDatabase.AssetPathToGUID(targetPath);
var objectGuids = AssetDatabase.FindAssets("t:Object");
var results = new HashSet<string>(StringComparer.Ordinal);
var total = objectGuids.LongLength;
var cache = Globals<CacheManager>.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<ResultRow> 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<string> GetScenesThatContain(Object activeObject) {
var targetPath = AssetDatabase.GetAssetPath(activeObject);
var targetGuid = AssetDatabase.AssetPathToGUID(targetPath);
var results = new HashSet<string>(StringComparer.Ordinal);
var sceneGuids = AssetDatabase.FindAssets("t:Scene");
var total = sceneGuids.LongLength;
var cache = Globals<CacheManager>.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<ResultRow> GetDependenciesInScene(SearchTarget target) {
var referencedBy = new List<ResultRow>();
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<Component>(true)
.Where(FilterComponents).Union(AsEnumerable(g as Object));
return g.GetComponentsInChildren<Component>(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<ResultRow> GetDependenciesInStage(SearchTarget target, UnityEditor.SceneManagement.PrefabStage stage) {
var referencedBy = new List<ResultRow>();
var allObjects = stage.scene
.GetRootGameObjects()
.SelectMany(g => {
if (g != target.Target)
return g.GetComponentsInChildren<Component>(true).Where(FilterComponents).Union(AsEnumerable(g as Object));
return g.GetComponentsInChildren<Component>(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;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8a6622c947e860548bd95915e407658e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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};
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2c4b883461f4461438dae02eba435811
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,21 @@
using System;
namespace AssetUsageFinder {
static class Globals<T> where T : class {
static T _instance;
public static void TryInit(Func<T> ctor) {
if (_instance != null) return;
_instance = ctor.Invoke();
}
public static T Get() => _instance;
public static T GetOrCreate(Func<T> ctor) {
TryInit(ctor);
return _instance;
}
public static void Set(T value) => _instance = value;
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 2dee75149ff4451a979163c53566150c
timeCreated: 1587621466

View File

@@ -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};
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 925da3bd0dee034418ecb5cf800a3526
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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};
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 584109c30c0a0d849bbc12ec89d8c597
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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<PropertyData> Properties = new List<PropertyData>();
public Object Root;
public GUIContent LabelContent = new GUIContent();
public GUIContent PropertyFieldContent = new GUIContent();
public Object Main;
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 40006b038ab829f4698bcebf3c1508f1
timeCreated: 1467625979
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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<Object[]> 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<Component>() : 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<Component>().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;
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: f500aea056165bb4294b484f1c9623d3
timeCreated: 1467656394
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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<Action> _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<WindowStyleAsset>();
return EditorGUIUtility.isProSkin ? res.Pro : res.Personal;
}
}
public static Style StyleInstance => Globals<Style>.GetOrCreate(Style.FindSelf);
void OnEnable() {
_postponedActions = new List<Action>();
}
void BreadCrumbs() {
var parents = _data.Parents();
parents.Reverse();
var w = 0f;
{
using (new EditorGUILayout.VerticalScope()) {
EditorGUILayout.BeginHorizontal();
for (var i = 0; i < parents.Count; i++) {
var parent = parents[i];
var style = i == 0 ? StyleInstance.TabBreadcrumb0 : StyleInstance.TabBreadcrumb1;
var styleWidth = style.CalcSize(parent.TabContent).x;
if (w > EditorGUIUtility.currentViewWidth - styleWidth) {
w = 0f;
EditorGUILayout.EndHorizontal();
EditorGUILayout.BeginHorizontal();
}
w += styleWidth;
if (i == parents.Count - 1) {
var res = GUILayout.Toggle(true, parent.TabContent, style);
if (!res)
EditorGUIUtility.PingObject(parent.Target.Target);
}
else if (GUILayout.Button(parent.TabContent, style)) {
EditorGUIUtility.PingObject(parent.Target.Target);
_postponedActions.Add(() => { Init(parent); });
}
}
EditorGUILayout.EndHorizontal();
}
}
}
void Update() {
if (!_postponedActions.Any()) return;
foreach (var a in _postponedActions)
a();
_postponedActions.Clear();
}
void OnGUI() {
if (_postponedActions == null || _data == null || (Event.current != null && Event.current.keyCode == KeyCode.Escape)) {
_postponedActions = new List<Action>();
_postponedActions.Add(() => Close());
return;
}
EditorGUILayout.BeginVertical();
{
BreadCrumbs();
_scrollPos = EditorGUILayout.BeginScrollView(_scrollPos);
{
EditorGUILayout.Space();
ShowDependencies(_data.Dependencies);
}
EditorGUILayout.EndScrollView();
}
EditorGUILayout.EndVertical();
EditorGUILayout.Space();
Footer();
}
void Footer() {
if (Event.current.type != EventType.Repaint) return;
_popupButtonRect = GUILayoutUtility.GetLastRect();
_popupButtonRect.position += position.position;
}
public void Init(DependencyAbstractFinder d) {
_data = d;
// _labelMaxWidth = CalculateContentMaxWidth(EditorStyles.label, _data.Dependencies.SelectMany(dd => dd.Properties.Select(p => p.Content)));
// var t = new[] {_data.Target.Root};
// if (_data.Target.Nested.TryGet(out var nested))
titleContent = new GUIContent($"{FindMode.GetWindowTitleByFindMode(_findMode)}");
titleContent.tooltip = _data.Title;
}
void ShowDependencies(ResultRow[] dependencies) {
var nDeps = dependencies.Count();
_expandFiles = EditorGUILayout.Foldout(_expandFiles, $"{FindMode.GetContentByFindMode(_findMode)}: [{nDeps}]");
if (_findMode == FindModeEnum.File) {
if (_data.Target.Scene.IsValid() && !_data.Target.Scene.isLoaded)
return;
}
if (_expandFiles) {
if (nDeps > 0) {
foreach (var dependency in dependencies)
if (dependency != null && dependency.SerializedObject != null && dependency.SerializedObject.targetObject != null)
DrawRow(dependency);
else
this.Close();
}
else {
EditorGUILayout.LabelField("No file dependencies found.");
}
}
EditorGUILayout.Space();
var fileDep = _data as FileDependencyFinder;
if (fileDep == null)
return;
if (fileDep.ScenePaths == null) {
fileDep.ScenePaths = DependencyFinderEngine.GetScenesThatContain(_data.Target.Target)
.Select(p => new FileDependencyFinder.Pair {Path = p, NicifiedPath = p.Replace("Assets/", string.Empty)}).ToArray();
}
var nScenes = fileDep.ScenePaths.Count();
_expandScenes = EditorGUILayout.Foldout(_expandScenes, $"In Scenes: [{nScenes}]");
if (!_expandScenes) return;
if (nScenes > 0) {
foreach (var p in fileDep.ScenePaths) {
using (new EditorGUILayout.HorizontalScope()) {
SceneIcon.text = p.NicifiedPath;
if (GUILayout.Button(SceneIcon, EditorStyles.label, GUILayout.Height(16f), GUILayout.MaxWidth(20f + p.NicifiedPath.Length * 7f)))
EditorGUIUtility.PingObject(AssetDatabase.LoadAssetAtPath<SceneAsset>(p.Path));
if (!GUILayout.Button("Open scene & search"))
continue;
var sceneToOpen = SceneManager.GetSceneByPath(p.Path);
if (sceneToOpen.isLoaded) {
GuiManager.OpenSceneWindow(_data.Target.Target, p.Path);
}
else {
var currentScene = EditorSceneManager.GetActiveScene();
if (currentScene.isDirty && EditorUtility.DisplayDialog(
$"Unsaved changes",
$"You are going to open and search in scene [{p.Path}]\n" +
$"but you have unsaved changes at the scene [{currentScene.name}]",
$"Stay at current scene and cancel search", $"Discard changes and search"))
return;
EditorSceneManager.OpenScene(p.Path);
GuiManager.OpenSceneWindow(_data.Target.Target, p.Path);
}
}
}
}
else {
EditorGUILayout.LabelField("No scene dependencies found.");
}
}
struct PrevClick {
Object _target;
float _timeClicked;
public PrevClick(Object target) {
_target = target;
_timeClicked = Time.realtimeSinceStartup;
}
const float DoubleClickTime = 0.5f;
public bool IsDoubleClick(Object o) {
return _target == o && Time.realtimeSinceStartup - _timeClicked < DoubleClickTime;
}
}
void DrawRow(ResultRow dependency) {
var id = dependency.Main.GetInstanceID();
using (new EditorGUILayout.VerticalScope(EditorStyles.helpBox)) {
using (new EditorGUILayout.HorizontalScope()) {
if (GUILayout.Button(dependency.LabelContent, StyleInstance.RowMainAssetBtn)) {
if (_click.IsDoubleClick(dependency.Main))
Selection.activeObject = dependency.Main;
else {
EditorGUIUtility.PingObject(dependency.Main);
}
_click = new PrevClick(dependency.Main);
}
if (GUILayout.Button(StyleInstance.LookupBtn.Content, StyleInstance.LookupBtn.Style)) {
_postponedActions.Add(() =>
Init(_data.Nest(dependency.Main)));
}
}
dependency.SerializedObject.Update();
EditorGUI.BeginChangeCheck();
if (dependency.Target) {
foreach (var prop in dependency.Properties) {
using (new EditorGUILayout.HorizontalScope()) {
var locked = prop.Property.objectReferenceValue is MonoScript;
var f = GUI.enabled;
if (locked) GUI.enabled = false;
EditorGUILayout.LabelField(prop.Content, StyleInstance.RowLabel, GUILayout.MaxWidth(this.position.width *.8f));
EditorGUILayout.PropertyField(prop.Property, GUIContent.none, true, GUILayout.MinWidth(this.position.width *.2f));
if (locked) GUI.enabled = f;
}
}
}
if (EditorGUI.EndChangeCheck())
dependency.SerializedObject.ApplyModifiedProperties();
}
}
static GUIContent SceneIcon {
get { return _sceneIcon ?? (_sceneIcon = new GUIContent(AssetPreview.GetMiniTypeThumbnail(typeof(SceneAsset)))); }
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: bcd1862681e4b684abaa15975a54cecf
timeCreated: 1464887183
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,7 @@
namespace AssetUsageFinder {
class FileDependencyWindow : DependencyWindow {
public FileDependencyWindow() {
_findMode = FindModeEnum.File;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 227b60af61a13ef46ae80267f1a7626e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AssetUsageFinder {
public enum FindModeEnum {
Unknown = 0,
File = 1,
Scene = 2,
Stage = 3
}
public static class FindMode {
public static string GetWindowTitleByFindMode(FindModeEnum findMode) {
switch (findMode) {
case FindModeEnum.File:
return "Usages in Project";
case FindModeEnum.Scene:
return "Usages in Scene";
case FindModeEnum.Stage:
return "Usages in Stage";
default:
return "Unknown Title!";
}
}
public static string GetContentByFindMode(FindModeEnum findMode) {
switch (findMode) {
case FindModeEnum.File:
return "In Project Files";
case FindModeEnum.Scene:
return "In Current Scene";
case FindModeEnum.Stage:
return "In Current Stage";
default:
return "Unknown Content!";
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: fef0947ab998ac34f8ab0f1e2eae5d37
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,169 @@
using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine;
using UnityEngine.SceneManagement;
namespace AssetUsageFinder {
[InitializeOnLoad]
public class GuiManager : UnityEditor.AssetModificationProcessor {
static string _version = "v4.0";
static GuiManager() {
EditorSceneManager.sceneSaved += OnSceneSaved;
}
static void OnSceneSaved(Scene scene) { }
public static string[] OnWillSaveAssets(string[] paths) {
return paths;
}
static void InitCache() {
Globals<CacheManager>.GetOrCreate(() => {
var res = new CacheManager();
res.Init();
return res;
});
}
#region Menu
[MenuItem("Assets/ Find Usages in Project", false, 30)]
static void FileMenu(MenuCommand command) {
InitCache();
var continueFinding = DoYouWantToSaveScene();
if (!continueFinding) return;
var pickupMessage = $"Please pick up a file from the project!";
var selected = Selection.activeObject;
if (selected == null) return;
var type = selected.GetType();
if (selected == null ||
type == typeof(DefaultAsset) ||
type == typeof(SceneAsset)) {
EditorUtility.DisplayDialog($"{_version}", $"{pickupMessage}", "Ok");
return;
}
if (type == typeof(GameObject)) {
var prefabProperties = PrefabUtilities.GetPrefabProperties(Selection.activeObject as GameObject);
if (prefabProperties.IsPartOfStage || prefabProperties.IsSceneObject) {
EditorUtility.DisplayDialog($"{_version}", $"{pickupMessage}", "Ok");
return;
}
}
EditorApplication.ExecuteMenuItem("File/Save Project");
OpenFileWindow(selected);
return;
}
[MenuItem("GameObject/ Find Usages in Scene && Stage", false, -1)]
public static void SceneOrStageMenu(MenuCommand data) {
InitCache();
var message = $"Please pick up an object from the scene && stage!";
var selected = Selection.activeObject;
if (selected == null) return;
if (selected == null || !(selected is GameObject)) {
EditorUtility.DisplayDialog($"{_version}", $"{message}", "Ok");
return;
}
var continueFinding = DoYouWantToSaveScene();
if (!continueFinding) return;
var prefabProperties = PrefabUtilities.GetPrefabProperties(Selection.activeObject as GameObject);
if (prefabProperties.IsPartOfStage) {
OpenStageWindow(selected, prefabProperties.Path);
}
else if (prefabProperties.IsSceneObject) {
OpenSceneWindow(selected, SceneManager.GetActiveScene().path);
}
else {
EditorUtility.DisplayDialog($"{_version}", $"{message}", "Ok");
return;
}
}
[MenuItem("CONTEXT/Component/ Find Usages of Component", false, 159)]
public static void FindReferencesToComponent(MenuCommand data) {
InitCache();
Object selected = data.context;
if (!selected) return;
var continueFinding = DoYouWantToSaveScene();
if (!continueFinding) return;
var scenePath = SceneManager.GetActiveScene().path;
OpenSceneWindow(selected, scenePath);
}
static bool DoYouWantToSaveScene() {
var scene = SceneManager.GetActiveScene();
if (scene.isDirty || string.IsNullOrEmpty(scene.path)) {
var response = EditorUtility.DisplayDialogComplex(
title: "Asset Usage Finder v4.0",
message: "Current scene is not saved yet!",
ok: "Save scene and find usages",
cancel: "Cancel usage finding",
alt: "Find without saving");
switch (response) {
case 0: // ok
EditorApplication.ExecuteMenuItem("File/Save");
return true;
case 1: // cancel
return false;
case 2: // find without saving
return true;
default:
return true;
}
}
return true;
}
#endregion Menu
#region InitWindow
static void OpenFileWindow(Object selected) {
var finder = new FileDependencyFinder(selected);
var window = ScriptableObject.CreateInstance<FileDependencyWindow>();
window.Init(finder);
var p = window.position;
p.size = DependencyWindow.StyleInstance.Size;
window.position = p;
window.Show();
}
public static void OpenSceneWindow(Object target, string scenePath) {
var finder = new InSceneDependencyFinder(target, scenePath);
var window = ScriptableObject.CreateInstance<SceneDependencyWindow>();
window.Init(finder);
window.Show();
}
static void OpenStageWindow(Object target, string stagePath) {
var finder = new InStageDependencyFinder(target, stagePath);
var window = ScriptableObject.CreateInstance<StageDependencyWindow>();
window.Init(finder);
window.Show();
}
#endregion InitWindow
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 65b7b313ed4025e4bbdf4f16a5d423de
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,133 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
namespace AssetUsageFinder {
public static class Option {
public static Option<T> Some<T>(T value) => new Option<T>(value, true);
public static Option<T> None<T>() => new Option<T>(default, false);
public static bool IsNotNull<T>(T t) {
return Option<T>.IsValueType || t != null;
}
}
public struct Option<T> : IEquatable<Option<T>>, IComparable<Option<T>> {
// ReSharper disable once StaticMemberInGenericType
internal static readonly bool IsValueType;
public bool HasValue { get; }
T Value { get; }
public static implicit operator Option<T>(T arg) {
if (!IsValueType) return ReferenceEquals(arg, null) ? new Option<T>() : Option.Some(arg);
#if M_WARN
if (arg.Equals(default(T)))
Warn.Warning($"{arg} has default value");
#endif
return Option.Some(arg);
}
static Option() {
IsValueType = typeof(T).IsValueType;
}
public void GetOrFail(out T value) {
if (!TryGet(out value))
Fail($"Option<{typeof(T).Name}> has no value");
}
public T GetOrFail() {
if (!TryGet(out var value))
Fail($"Option<{typeof(T).Name}> has no value");
return value;
}
[Conditional("DEBUG1")]
static void Fail(string format = null) {
throw new Exception(format);
}
public bool TryGet(out T value) {
if (!HasValue) {
value = default(T);
return false;
}
value = Value;
return true;
}
internal Option(T value, bool hasValue) {
Value = value;
HasValue = hasValue;
}
public T ValueOr(T alternative) {
return HasValue ? Value : alternative;
}
// for debug purposes
public override string ToString() {
if (!HasValue) return "None";
return Value == null ? "Some(null)" : $"Some({Value})";
}
#region eq comparers boilerplate
public bool Equals(Option<T> other) {
if (!HasValue && !other.HasValue)
return true;
if (HasValue && other.HasValue)
return EqualityComparer<T>.Default.Equals(Value, other.Value);
return false;
}
public override bool Equals(object obj) {
return obj is Option<T> && Equals((Option<T>) obj);
}
public static bool operator ==(Option<T> left, Option<T> right) {
return left.Equals(right);
}
public static bool operator !=(Option<T> left, Option<T> right) {
return !left.Equals(right);
}
public override int GetHashCode() {
if (!HasValue) return 0;
return Option.IsNotNull(Value) ? Value.GetHashCode() : 1;
}
public int CompareTo(Option<T> other) {
if (HasValue && !other.HasValue) return 1;
if (!HasValue && other.HasValue) return -1;
return Comparer<T>.Default.Compare(Value, other.Value);
}
public static bool operator <(Option<T> left, Option<T> right) {
return left.CompareTo(right) < 0;
}
public static bool operator <=(Option<T> left, Option<T> right) {
return left.CompareTo(right) <= 0;
}
public static bool operator >(Option<T> left, Option<T> right) {
return left.CompareTo(right) > 0;
}
public static bool operator >=(Option<T> left, Option<T> right) {
return left.CompareTo(right) >= 0;
}
#endregion
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: ae4b8392ac17499b9840c83d49357e45
timeCreated: 1591797332

View File

@@ -0,0 +1,85 @@
#if UNITY_2018_3_OR_NEWER
using UnityEditor;
using UnityEngine;
namespace AssetUsageFinder {
public static class PrefabUtilities {
public class PrefabProperties {
public bool IsPartOfStage;
public bool IsStageRoot;
public bool IsPartOfInstance;
public bool IsInstanceRoot;
public GameObject NearestInstanceRoot;
public bool IsAssetRoot;
public bool IsPartOfPrefabAsset;
public string Path;
public GameObject PrefabAssetRoot;
public bool IsSceneObject => (!IsPartOfPrefabAsset && !IsPartOfStage);
public bool IsPartOfAnyPrefab => Path != null;
public bool IsRootOfAnyPrefab => IsAssetRoot || IsInstanceRoot || IsStageRoot;
}
public static PrefabProperties GetPrefabProperties (GameObject gameObject) {
var p = new PrefabProperties ();
p.IsPartOfPrefabAsset = PrefabUtility.IsPartOfPrefabAsset (gameObject);
if (!p.IsPartOfPrefabAsset)
p.IsPartOfPrefabAsset = !string.IsNullOrEmpty (AssetDatabase.GetAssetPath (gameObject));
GameObject nerestInstanceRoot = p.NearestInstanceRoot = PrefabUtility.GetNearestPrefabInstanceRoot (gameObject);
p.IsPartOfInstance = (nerestInstanceRoot != null);
p.IsInstanceRoot = (gameObject == nerestInstanceRoot);
if (p.IsPartOfPrefabAsset) {
p.PrefabAssetRoot = gameObject.transform.root.gameObject;
p.IsAssetRoot = (gameObject == p.PrefabAssetRoot);
}
var editorPrefabStage = UnityEditor.SceneManagement.PrefabStageUtility.GetCurrentPrefabStage ();
if (editorPrefabStage != null) {
if (p.IsPartOfPrefabAsset == false)
p.IsPartOfStage = true;
if (p.IsPartOfStage && gameObject.transform.parent == null)
p.IsStageRoot = true;
}
if (p.IsRootOfAnyPrefab) {
if (p.IsStageRoot) {
p.Path = GetPath ();
}
else if (p.IsInstanceRoot) {
p.Path = PrefabUtility.GetPrefabAssetPathOfNearestInstanceRoot (gameObject);
}
else if (p.IsAssetRoot) {
p.Path = AssetDatabase.GetAssetPath (gameObject);
}
}
else {
if (p.IsPartOfStage) {
p.Path = GetPath ();
}
else if (p.IsPartOfInstance) {
p.Path = PrefabUtility.GetPrefabAssetPathOfNearestInstanceRoot (p.NearestInstanceRoot);
}
else if (p.IsPartOfPrefabAsset) {
p.Path = AssetDatabase.GetAssetPath (gameObject.transform.root.gameObject);
}
}
return p;
string GetPath () {
#if UNITY_2020_1_OR_NEWER
return editorPrefabStage.assetPath;
#else
return editorPrefabStage.prefabAssetPath;
#endif
}
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 40e15ba4381bc524f9aa96a02e671466
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,7 @@
namespace AssetUsageFinder {
class SceneDependencyWindow : DependencyWindow {
public SceneDependencyWindow() {
_findMode = FindModeEnum.Scene;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a6fa5c0e12d3f2d4eaeda43544061720
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,7 @@
namespace AssetUsageFinder {
class StageDependencyWindow : DependencyWindow {
public StageDependencyWindow() {
_findMode = FindModeEnum.Stage;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e4dcf69ebb96d694883ee0b402596bb2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 479a256622980e149b2c447e4d2939fb
folderAsset: yes
timeCreated: 1470315057
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,10 @@
using System;
using UnityEngine;
namespace AssetUsageFinder.Styles {
[Serializable]
class ContentStylePair {
public GUIContent Content = new GUIContent();
public GUIStyle Style = new GUIStyle();
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: d89a773ebe3631a45968846ae15ffe67
timeCreated: 1467636613
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,26 @@
using UnityEditor;
using UnityEditorInternal;
using UnityEngine;
namespace AssetUsageFinder.Styles {
class WindowStyleAsset : ScriptableObject {
#pragma warning disable 0649
public DependencyWindow.Style Pro;
public DependencyWindow.Style Personal;
#pragma warning restore
#if !false
[CustomEditor(typeof (WindowStyleAsset))]
class Editor : UnityEditor.Editor
{
public override void OnInspectorGUI()
{
EditorGUI.BeginChangeCheck();
base.OnInspectorGUI();
if (EditorGUI.EndChangeCheck())
InternalEditorUtility.RepaintAllViews();
}
}
#endif
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 2a8038d7a393d814b887bec61ad77979
timeCreated: 1467571260
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,17 @@
Asset Usage Finder v4.16
Importing new version of an asset:
1) Delete an old version of the product - Assets/DependencyPro folder
2) Import from Asset Store to Assets folder
IMPORTANT NOTICE:
In order to initialize cache for a project, you need to:
1) Run any usage search - File, Scene, Component
2) Wait for it to finish. It will take 4x less time any search took in v2.0
Benefits:
- Every other search will take less than 2 seconds. On huge projects, it should take less than 5 seconds
- Cache will be stored permanently and will be available after you close the project and turn off computer
- In case of changes that were made after cache initialization, only those changes will be cached. So you don't need to wait for cacheing of whole project every time
FAQ:
- https://docs.google.com/document/d/1RZA8Rf3QHdzTq6HFa7moA0G9W1uZjXOrSMJ25QwaNgk/edit?usp=sharing

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 63922495ab93f4e42ad5b30ddff568fc
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: