예제 #1
0
        public static string GetPrefabBuilderGUIName(IPrefabBuilder builder)
        {
            CustomPrefabBuilder attr =
                builder.GetType().GetCustomAttributes(typeof(CustomPrefabBuilder), false).FirstOrDefault() as CustomPrefabBuilder;

            return(attr.Name);
        }
예제 #2
0
        public static bool HasValidCustomPrefabBuilderAttribute(Type t)
        {
            CustomPrefabBuilder attr =
                t.GetCustomAttributes(typeof(CustomPrefabBuilder), false).FirstOrDefault() as CustomPrefabBuilder;

            return(attr != null && !string.IsNullOrEmpty(attr.Name));
        }
예제 #3
0
        public static int GetPrefabBuilderAssetThreshold(string className)
        {
            var type = Type.GetType(className);

            if (type != null)
            {
                CustomPrefabBuilder attr =
                    type.GetCustomAttributes(typeof(CustomPrefabBuilder), false).FirstOrDefault() as CustomPrefabBuilder;
                if (attr != null)
                {
                    return(attr.AssetThreshold);
                }
            }
            return(0);
        }
예제 #4
0
        public static string GetPrefabBuilderVersion(string className)
        {
            var type = Type.GetType(className);

            if (type != null)
            {
                CustomPrefabBuilder attr =
                    type.GetCustomAttributes(typeof(CustomPrefabBuilder), false).FirstOrDefault() as CustomPrefabBuilder;
                if (attr != null)
                {
                    return(attr.Version);
                }
            }
            return(string.Empty);
        }
예제 #5
0
        public static Dictionary <string, string> GetAttributeAssemblyQualifiedNameMap()
        {
            if (s_attributeAssemblyQualifiedNameMap == null)
            {
                // attribute name or class name : class name
                s_attributeAssemblyQualifiedNameMap = new Dictionary <string, string>();

                var allBuilders = new List <Type>();

                foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
                {
                    var builders = assembly.GetTypes()
                                   .Where(t => !t.IsInterface)
                                   .Where(t => typeof(IPrefabBuilder).IsAssignableFrom(t));
                    allBuilders.AddRange(builders);
                }

                foreach (var type in allBuilders)
                {
                    // set attribute-name as key of dict if atribute is exist.
                    CustomPrefabBuilder attr =
                        type.GetCustomAttributes(typeof(CustomPrefabBuilder), true).FirstOrDefault() as CustomPrefabBuilder;

                    var typename = type.AssemblyQualifiedName;


                    if (attr != null)
                    {
                        if (!s_attributeAssemblyQualifiedNameMap.ContainsKey(attr.Name))
                        {
                            s_attributeAssemblyQualifiedNameMap[attr.Name] = typename;
                        }
                    }
                    else
                    {
                        s_attributeAssemblyQualifiedNameMap[typename] = typename;
                    }
                }
            }
            return(s_attributeAssemblyQualifiedNameMap);
        }