public static int AddClassToRegister(Type type)
        {
            var count = 0;

            foreach (var p in type.GetProperties())
            {
                if (!IsSupportedType(p.PropertyType))
                {
                    continue;
                }
                if (p.DeclaringType != type)
                {
                    continue;
                }
                if (p.DeclaringType.GetCustomAttributes(typeof(ObsoleteAttribute), true).Length > 0)
                {
                    continue;
                }
                if (p.GetCustomAttributes(typeof(ObsoleteAttribute), true).Length > 0)
                {
                    continue;
                }
                SurrogateCompiler.CreateProperty(p);
                // count++;
            }

            foreach (var m in type.GetMethods())
            {
                if (IsSupportedMethod(type, m))
                {
                    SurrogateCompiler.CreateAction(m);
                    count++;
                }
            }

            foreach (var f in type.GetFields())
            {
                if (!IsSupportedType(f.FieldType))
                {
                    continue;
                }
                if (f.DeclaringType != type)
                {
                    continue;
                }
                if (f.DeclaringType.GetCustomAttributes(typeof(ObsoleteAttribute), true).Length > 0)
                {
                    continue;
                }
                if (f.GetCustomAttributes(typeof(ObsoleteAttribute), true).Length > 0)
                {
                    continue;
                }
                SurrogateCompiler.CreateField(f);
                // count++;
            }
            return(count);
        }
        public static void BuildEverything()
        {
            var count = 0;

            foreach (var asm in System.AppDomain.CurrentDomain.GetAssemblies())
            {
                if (blackListesAssemblies.Contains(asm.FullName))
                {
                    continue;
                }

                foreach (var type in asm.GetTypes())
                {
                    if (type.IsSubclassOf(typeof(Component)))
                    {
                        count += AddClassToRegister(type);
                    }
                }
            }
            Debug.Log($"{count} classed generated.");
            SurrogateCompiler.Save();
            AssetDatabase.Refresh();
        }
示例#3
0
        void Build()
        {
            var sr = target as SurrogateRegister;

            foreach (var mi in sr.methodIndex.Keys.ToArray())
            {
                sr.methodIndex[mi] = SurrogateCompiler.CreateAction(mi).AssemblyQualifiedName;
            }
            foreach (var fi in sr.fieldIndex.Keys.ToArray())
            {
                sr.fieldIndex[fi] = SurrogateCompiler.CreateField(fi).AssemblyQualifiedName;
            }
            foreach (var pi in sr.propertyIndex.Keys.ToArray())
            {
                sr.propertyIndex[pi] = SurrogateCompiler.CreateProperty(pi).AssemblyQualifiedName;
            }

            sr.missingFields.Clear();
            sr.missingMethods.Clear();
            sr.missingProperties.Clear();
            EditorUtility.SetDirty(sr);
            SurrogateCompiler.Save();
            AssetDatabase.Refresh();
        }