Пример #1
0
        private void CollectTypes()
        {
            AppendUsing(typeof(MonoDllFactory));
            IEnumerable <Assembly> assembles = AppDomain.CurrentDomain.GetAssemblies();

            assembles = assembles.Where(a => a.FullName.Contains("Assembly"));
            foreach (var a in assembles)
            {
                Type[]             ts    = a.GetTypes();
                IEnumerable <Type> types =
                    ts.Where(t => t.IsClass && !t.IsAbstract && t.IsSubclassOf(typeof(MonoBehaviour)));
                foreach (var t in types)
                {
                    MonoDllAttribute act = GetAttribute <MonoDllAttribute>(t);
                    if (act != null)
                    {
                        _treeTypes.Add(act.name, t);
                        AppendUsing(t);
                    }
                }
            }
        }
Пример #2
0
        public static void Register()
        {
            IEnumerable <Assembly> assembles = UnityEditorReflectionTool.GetCustomAssembles().ToArray();

            foreach (var a in assembles)
            {
                Type[]             ts    = a.GetTypes();
                IEnumerable <Type> types =
                    ts.Where(t => t.IsClass && !t.IsAbstract && t.IsSubclassOf(typeof(MonoBehaviour)));
                foreach (var t in types)
                {
                    object[] attributes = t.GetCustomAttributes(typeof(MonoDllAttribute), false);
                    if (attributes.Length == 0)
                    {
                        continue;
                    }
                    MonoDllAttribute att = attributes[0] as MonoDllAttribute;
                    if (att != null)
                    {
                        MonoDllFactory.Register(att.name, t);
                    }
                }
            }
        }