Пример #1
0
        private Dictionary <MonoScript, List <FieldInfo> > Calculate()
        {
            var dict         = new Dictionary <MonoScript, List <FieldInfo> >();
            var monoType     = typeof(MonoBehaviour);
            var listType     = typeof(List <>);
            var delegateType = typeof(Delegate);
            var eventType    =
                Assembly.LoadFile(EditorAssetHelper.GetLibraryDll(AssetHelper.AssemblyCSharpfirstpass))
                .GetType("EventDelegate");

            foreach (var findAsset in EditorAssetHelper.FindAssetsPaths(EditorAssetHelper.SearchFilter.Script))
            {
                var script     = AssetDatabase.LoadAssetAtPath <MonoScript>(findAsset);
                var scriptType = script.GetClass();
                if (scriptType != null && scriptType.IsSubclassOf(monoType) && !scriptType.IsNestedAssembly &&
                    scriptType.Assembly.FullName.Contains(AssetHelper.AssemblyCSharpfirstpass))
                {
                    foreach (var fieldInfo in scriptType.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly))
                    {
                        var filedType = fieldInfo.FieldType;
                        if (filedType.IsGenericType && filedType.GetGenericTypeDefinition() == listType)
                        {
                            filedType = filedType.GetGenericArguments()[0];
                        }

                        if (filedType.IsSubclassOf(delegateType) ||
                            (eventType != null && filedType.IsSubclassOf(eventType)))
                        {
                            if (!dict.ContainsKey(script))
                            {
                                dict[script] = new List <FieldInfo>();
                            }

                            dict[script].Add(fieldInfo);
                        }
                    }
                }
            }

            return(dict);
        }
Пример #2
0
 public override List <string> GetAssetPaths(string path = null)
 {
     return(EditorAssetHelper.FindAssetsPaths(EditorAssetHelper.SearchFilter.Texture, path));
 }
Пример #3
0
 protected override List <Material> GetProjectObjects()
 {
     return(EditorAssetHelper.FindAssetsPaths(EditorAssetHelper.SearchFilter.Material)
            .ConvertAll(input => AssetDatabase.LoadAssetAtPath <Material>(input)));
 }
Пример #4
0
 protected override List <GameObject> GetProjectObjects()
 {
     return(EditorAssetHelper.FindAssetsPaths(EditorAssetHelper.SearchFilter.Prefab)
            .ConvertAll(input => AssetDatabase.LoadAssetAtPath <GameObject>(input)));
 }