internal static void FetchTypes()
        {
            Dictionary <string, TypeData> dictionary = new Dictionary <string, TypeData>();

            dictionary.Add("None", new TypeData(typeof(object)));
            types = dictionary;
            IEnumerable <Assembly> enumerable = from assembly in AppDomain.CurrentDomain.GetAssemblies()
                                                where assembly.FullName.Contains("Assembly")
                                                select assembly;

            foreach (Assembly item in enumerable)
            {
                foreach (Type item2 in from T in item.GetTypes()
                         where T.IsClass && !T.IsAbstract && Enumerable.Contains(T.GetInterfaces(), typeof(IConnectionTypeDeclaration))
                         select T)
                {
                    IConnectionTypeDeclaration connectionTypeDeclaration = item.CreateInstance(item2.FullName) as IConnectionTypeDeclaration;
                    if (connectionTypeDeclaration == null)
                    {
                        throw new UnityException("Error with Type Declaration " + item2.FullName);
                    }
                    types.Add(connectionTypeDeclaration.Identifier, new TypeData(connectionTypeDeclaration));
                }
            }
        }
示例#2
0
        internal TypeData()
        {
            declaration = null;
            Type        = typeof(object);
            Color       = Color.white;
            InKnobTex   = ResourceManager.LoadTexture("Textures/In_Knob.png");
            OutKnobTex  = ResourceManager.LoadTexture("Textures/Out_Knob.png");

            if (InKnobTex == null || InKnobTex == null)
            {
                throw new UnityException("Invalid textures for default typeData!");
            }
        }
        public TypeData(Type type)
        {
            Identifier  = type.Name;
            declaration = null;
            Type        = type;
            Color       = Color.white;
            int hashCode = type.GetHashCode();

            byte[] bytes = BitConverter.GetBytes(hashCode);
            Color      = new Color(Mathf.Pow((float)(int)bytes[0] / 255f, 0.5f), Mathf.Pow((float)(int)bytes[1] / 255f, 0.5f), Mathf.Pow((float)(int)bytes[2] / 255f, 0.5f));
            InKnobTex  = ResourceManager.GetTintedTexture("Textures/In_Knob.png", Color);
            OutKnobTex = ResourceManager.GetTintedTexture("Textures/Out_Knob.png", Color);
        }
 internal TypeData(IConnectionTypeDeclaration typeDecl)
 {
     Identifier  = typeDecl.Identifier;
     declaration = typeDecl;
     Type        = declaration.Type;
     Color       = declaration.Color;
     InKnobTex   = ResourceManager.GetTintedTexture(declaration.InKnobTex, Color);
     OutKnobTex  = ResourceManager.GetTintedTexture(declaration.OutKnobTex, Color);
     if (!isValid())
     {
         throw new DataMisalignedException("Type Declaration " + typeDecl.Identifier + " contains invalid data!");
     }
 }
示例#5
0
        internal TypeData(Type type)
        {
            declaration = null;
            Type        = type;
            Color       = Color.white;      //(float)type.GetHashCode() / (int.MaxValue/3);

            InKnobTex  = ResourceManager.GetTintedTexture("Textures/In_Knob.png", Color);
            OutKnobTex = ResourceManager.GetTintedTexture("Textures/Out_Knob.png", Color);

            if (InKnobTex == null || InKnobTex == null)
            {
                throw new UnityException("Invalid textures for default typeData " + type.ToString() + "!");
            }
        }
示例#6
0
        internal TypeData(IConnectionTypeDeclaration typeDecl)
        {
            declaration = typeDecl;
            Type        = declaration.Type;
            Color       = declaration.Color;

            InKnobTex  = ResourceManager.GetTintedTexture(declaration.InKnobTex, Color);
            OutKnobTex = ResourceManager.GetTintedTexture(declaration.OutKnobTex, Color);

            if (InKnobTex == null || InKnobTex == null)
            {
                throw new UnityException("Invalid textures for default typeData " + declaration.Identifier + "!");
            }
        }
示例#7
0
        public TypeData(Type type)
        {
            Identifier  = type.Name;
            declaration = null;
            Type        = type;

            // Generate consistent color for a type - using string because it delivers greater variety of colors than type hashcode
            int srcInt = (int)(type.AssemblyQualifiedName.GetHashCode());

            UnityEngine.Random.InitState(srcInt);
            Color = UnityEngine.Random.ColorHSV(0, 1, 0.6f, 0.8f, 0.8f, 1.4f);

            InKnobTex  = ResourceManager.GetTintedTexture("Textures/In_Knob.png", Color);
            OutKnobTex = ResourceManager.GetTintedTexture("Textures/Out_Knob.png", Color);
        }
示例#8
0
        /// <summary>
        /// Fetches every Type Declaration in the script assemblies and the executing one, if the NodeEditor is packed into a .dll
        /// </summary>
        internal static void FetchTypes()
        {
            types = new Dictionary <string, TypeData> {
                { "None", new TypeData(typeof(System.Object)) }
            };

            IEnumerable <Assembly> scriptAssemblies = AppDomain.CurrentDomain.GetAssemblies().Where((Assembly assembly) => assembly.FullName.Contains("Assembly"));

            foreach (Assembly assembly in scriptAssemblies)
            {
                foreach (Type type in assembly.GetTypes().Where(T => T.IsClass && !T.IsAbstract && T.GetInterfaces().Contains(typeof(IConnectionTypeDeclaration))))
                {
                    IConnectionTypeDeclaration typeDecl = assembly.CreateInstance(type.FullName) as IConnectionTypeDeclaration;
                    if (typeDecl == null)
                    {
                        throw new UnityException("Error with Type Declaration " + type.FullName);
                    }
                    types.Add(typeDecl.Identifier, new TypeData(typeDecl));
                }
            }
        }
示例#9
0
        public TypeData(Type type)
        {
            Identifier  = type.Name;
            declaration = null;
            Type        = type;
            Color       = Color.white;      //(float)type.GetHashCode() / (int.MaxValue/3);

            // TODO: Experimental: Create colors randomly from hashcode of type
            // right now everything is roughly the same color unfortunately

            // int -> 3x float
            int srcInt = type.GetHashCode();

            byte[] bytes = BitConverter.GetBytes(srcInt);
            //Debug.Log ("hash " + srcInt + " from type " + type.FullName + " has byte count of " + bytes.Length);
            Color = new Color(Mathf.Pow(((float)bytes[0]) / 255, 0.5f), Mathf.Pow(((float)bytes[1]) / 255, 0.5f), Mathf.Pow(((float)bytes[2]) / 255, 0.5f));
            //Debug.Log ("Color " + col.ToString ());

            InKnobTex  = ResourceManager.GetTintedTexture("Textures/In_Knob.png", Color);
            OutKnobTex = ResourceManager.GetTintedTexture("Textures/Out_Knob.png", Color);
        }
示例#10
0
        /// <summary>
        /// Fetches every Type Declaration in the script assemblies and the executing one, if the NodeEditor is packed into a .dll
        /// </summary>
        internal static void FetchTypes()
        {
            types = new Dictionary <string, TypeData> {
                { "None", new TypeData() }
            };

            IEnumerable <Assembly> scriptAssemblies = AppDomain.CurrentDomain.GetAssemblies().Where((Assembly assembly) => assembly.FullName.Contains("Assembly"));

            foreach (Assembly assembly in scriptAssemblies)
            {             // Iterate through each script assembly
                IEnumerable <Type> typeDeclarations = assembly.GetTypes().Where(T => T.IsClass && !T.IsAbstract && T.GetInterface(typeof(IConnectionTypeDeclaration).FullName) != null);
                foreach (Type type in typeDeclarations)
                {                 // get all type declarations and create a typeData for them
                    IConnectionTypeDeclaration typeDecl = assembly.CreateInstance(type.FullName) as IConnectionTypeDeclaration;
                    if (typeDecl == null)
                    {
                        throw new UnityException("Error with Type Declaration " + type.FullName);
                    }
                    types.Add(typeDecl.Identifier, new TypeData(typeDecl));
                }
            }
        }
示例#11
0
        internal TypeData()
        {
            declaration = null;
            Type = typeof(object);
            Color = Color.white;
            InKnobTex = ResourceManager.LoadTexture ("Textures/In_Knob.png");
            OutKnobTex = ResourceManager.LoadTexture ("Textures/Out_Knob.png");

            if (InKnobTex == null || InKnobTex == null)
                throw new UnityException ("Invalid textures for default typeData!");
        }
示例#12
0
        internal TypeData(Type type)
        {
            declaration = null;
            Type = type;
            Color = Color.white;//(float)type.GetHashCode() / (int.MaxValue/3);

            InKnobTex = ResourceManager.GetTintedTexture ("Textures/In_Knob.png", Color);
            OutKnobTex = ResourceManager.GetTintedTexture ("Textures/Out_Knob.png", Color);

            if (InKnobTex == null || InKnobTex == null)
                throw new UnityException ("Invalid textures for default typeData " + type.ToString () + "!");
        }
示例#13
0
        internal TypeData(IConnectionTypeDeclaration typeDecl)
        {
            declaration = typeDecl;
            Type = declaration.Type;
            Color = declaration.Color;

            InKnobTex = ResourceManager.GetTintedTexture (declaration.InKnobTex, Color);
            OutKnobTex = ResourceManager.GetTintedTexture (declaration.OutKnobTex, Color);

            if (InKnobTex == null || InKnobTex == null)
                throw new UnityException ("Invalid textures for default typeData " + declaration.Identifier + "!");
        }