public static void GetPreviewableTypes(out Dictionary <Type, List <Type> > previewableTypes)
        {
            // We initialize this list once per InspectorWindow, instead of globally.
            // This means that if the user is debugging an IPreviewable structure,
            // the InspectorWindow can be closed and reopened to refresh this list.

            previewableTypes = new Dictionary <Type, List <Type> >();
            foreach (var type in EditorAssemblies.GetAllTypesWithInterface <IPreviewable>())
            {
                // we don't want Editor classes with preview here.
                if (type.IsSubclassOf(typeof(Editor)))
                {
                    continue;
                }

                // Record only the types with a CustomPreviewAttribute.
                var attrs = type.GetCustomAttributes(typeof(CustomPreviewAttribute), false) as CustomPreviewAttribute[];
                foreach (CustomPreviewAttribute previewAttr in attrs)
                {
                    if (previewAttr.m_Type == null)
                    {
                        continue;
                    }

                    List <Type> types;
                    if (!previewableTypes.TryGetValue(previewAttr.m_Type, out types))
                    {
                        types = new List <Type>();
                        previewableTypes.Add(previewAttr.m_Type, types);
                    }

                    types.Add(type);
                }
            }
        }
        private ILightingExplorerExtension GetLightExplorerExtension(System.Type currentSRPType)
        {
            if (currentSRPType == null)
            {
                return(GetDefaultLightingExplorerExtension());
            }

            var extensionTypes = EditorAssemblies.GetAllTypesWithInterface <ILightingExplorerExtension>();

            foreach (System.Type extensionType in extensionTypes)
            {
                LightingExplorerExtensionAttribute attribute = System.Attribute.GetCustomAttribute(extensionType, typeof(LightingExplorerExtensionAttribute)) as LightingExplorerExtensionAttribute;
                if (attribute != null && attribute.renderPipelineType == currentSRPType)
                {
                    ILightingExplorerExtension extension = (ILightingExplorerExtension)System.Activator.CreateInstance(extensionType);
                    return(extension);
                }
            }

            // no light explorer extension found for current srp, return the default one
            return(GetDefaultLightingExplorerExtension());
        }
示例#3
0
 internal static IEnumerable <Type> SubclassesOf(Type parent)
 {
     return((!parent.IsInterface) ? (from klass in EditorAssemblies.loadedTypes
                                     where klass.IsSubclassOf(parent)
                                     select klass) : EditorAssemblies.GetAllTypesWithInterface(parent));
 }
示例#4
0
 internal static IEnumerable <Type> GetAllTypesWithInterface <T>() where T : class
 {
     return(EditorAssemblies.GetAllTypesWithInterface(typeof(T)));
 }