Exemple #1
0
        /// <summary>
        /// Fetches every Type Declaration in the assembly
        /// </summary>
        public static void FetchTypes()
        {         // Search the current and (if the NodeEditor is packed into a .dll) the calling one
            types = new Dictionary <string, TypeData> ();

            List <Assembly> scriptAssemblies = AppDomain.CurrentDomain.GetAssemblies()
                                               .Where((Assembly a) => a.FullName.StartsWith("Assembly-"))
                                               .ToList(); // This filters out all script assemblies

            if (!scriptAssemblies.Contains(Assembly.GetExecutingAssembly()))
            {
                scriptAssemblies.Add(Assembly.GetExecutingAssembly());
            }
            foreach (Assembly assembly in scriptAssemblies)
            {
                foreach (Type type in assembly.GetTypes().Where(T => T.IsClass && !T.IsAbstract && T.GetInterfaces().Contains(typeof(ITypeDeclaration))))
                {
                    ITypeDeclaration typeDecl = assembly.CreateInstance(type.FullName) as ITypeDeclaration;
                    if (typeDecl == null)
                    {
                        UnityEngine.Debug.LogError("Error with Type Declaration " + type.FullName);
                        return;
                    }
                    Texture2D InputKnob  = NodeEditor.LoadTexture(typeDecl.InputKnob_TexPath);
                    Texture2D OutputKnob = NodeEditor.LoadTexture(typeDecl.OutputKnob_TexPath);
                    types.Add(typeDecl.name, new TypeData(typeDecl.col, InputKnob, OutputKnob, typeDecl.Type));
                }
            }
        }