Esempio n. 1
0
        public static void InvokeAutoRegister()
        {
            var factoryTypes = typeof(AutoResisterRendererResourceFactories).GetNestedTypes(BindingFlags.Public);

            foreach (var factoryType in factoryTypes)
            {
#if !UNITY_EDITOR && (ENABLE_DOTNET || (UNITY_WINRT && !ENABLE_IL2CPP))
                if (!factoryType.GetTypeInfo().IsSubclassOf(typeof(RendererResourceFactory)))
                {
#else
                if (!factoryType.IsSubclassOf(typeof(RendererResourceFactory)))
                {
#endif
                    UnityEngine.Debug.LogError("[CRIWARE] internal logic error. " + factoryType.Name + " is required to be a subclass of RendererResourceFactory.");
                    continue;
                }
#if !UNITY_EDITOR && (ENABLE_DOTNET || (UNITY_WINRT && !ENABLE_IL2CPP))
                var priorityAttribute = (RendererResourceFactoryPriorityAttribute)CustomAttributeExtensions.GetCustomAttribute(
                    factoryType.GetTypeInfo(),
                    typeof(RendererResourceFactoryPriorityAttribute)
                    );
#else
                var priorityAttribute = (RendererResourceFactoryPriorityAttribute)System.Attribute.GetCustomAttribute(
                    factoryType,
                    typeof(RendererResourceFactoryPriorityAttribute)
                    );
#endif
                if (priorityAttribute == null)
                {
                    UnityEngine.Debug.LogError("[CRIWARE] internal logic error. need priority attribute. (" + factoryType.Name + ")");
                    continue;
                }
                RendererResourceFactory.RegisterFactory(
                    (RendererResourceFactory)System.Activator.CreateInstance(factoryType),
                    priorityAttribute.priority
                    );
            }
        }
    }
Esempio n. 2
0
 static public void RegisterFactory(RendererResourceFactory factory, int priority)
 {
     factoryList.Add(priority, factory);
 }