private void Init() { m_map = Resources.Load <EditorsMapStorage>(EditorsMapStorage.EditorsMapPrefabName); if (m_map == null) { m_map = Resources.Load <EditorsMapStorage>(EditorsMapStorage.EditorsMapTemplateName); } GameObject editorsMapGo = new GameObject(); EditorsMap editorsMap = editorsMapGo.AddComponent <EditorsMap>(); editorsMap.LoadMap(); Assembly[] allAssemblies; Type[] types; GetUOAssembliesAndTypes(out allAssemblies, out types); Assembly[] unityAssemblies = allAssemblies.Where(a => a != null && a.FullName != null && a.FullName.Contains("UnityEngine")).ToArray(); Assembly[] otherAssemblies = allAssemblies.Where(a => a != null && a.FullName != null && !a.FullName.Contains("UnityEngine")).ToArray(); m_objectEditorDescriptors = new[] { typeof(GameObject) } .Where(t => t.IsPublic && !t.IsGenericType) .Select(t => new EditorDescriptor(t, m_map != null && editorsMap.IsObjectEditorEnabled(t), m_map != null ? editorsMap.GetObjectEditor(t, true) : null, false)).ToArray(); m_propertyEditorDescriptors = new[] { typeof(object), typeof(UnityEngine.Object), typeof(bool), typeof(Enum), typeof(List <>), typeof(Array), typeof(string), typeof(int), typeof(float), typeof(Range), typeof(Vector2), typeof(Vector3), typeof(Vector4), typeof(Quaternion), typeof(Color), typeof(Bounds), typeof(RangeInt), typeof(RangeOptions), typeof(HeaderText), typeof(MethodInfo) } .Where(t => t.IsPublic) .Select(t => new EditorDescriptor(t, m_map != null && editorsMap.IsPropertyEditorEnabled(t), m_map != null ? editorsMap.GetPropertyEditor(t, true) : null, true)).ToArray(); m_stdComponentEditorDescriptors = unityAssemblies.SelectMany(a => a.GetTypes()) .Where(t => typeof(Component).IsAssignableFrom(t) && t.IsPublic && !t.IsGenericType) .OrderBy(t => (t == typeof(Component)) ? string.Empty : t.Name) .Select(t => new EditorDescriptor(t, m_map != null && editorsMap.IsObjectEditorEnabled(t), m_map != null ? editorsMap.GetObjectEditor(t, true) : null, false)).ToArray(); m_scriptEditorDescriptors = otherAssemblies.SelectMany(a => a.GetTypes()) .Where(t => typeof(MonoBehaviour).IsAssignableFrom(t) && t.IsPublic && !t.IsGenericType) .OrderBy(t => t.FullName) .Select(t => GetScriptEditorDescriptor(t, editorsMap)).ToArray(); List <Material> materials = new List <Material>(); string[] assets = AssetDatabase.GetAllAssetPaths(); foreach (string asset in assets) { if (!asset.EndsWith(".mat")) { continue; } Material material = AssetDatabase.LoadAssetAtPath <Material>(asset); if (material == null || (material.hideFlags & HideFlags.DontSaveInBuild) != 0 || material.shader == null || (material.shader.hideFlags & HideFlags.DontSaveInBuild) != 0) { continue; } materials.Add(material); } MaterialEditorDescriptor[] defaultDescriptors = new[] { new MaterialEditorDescriptor(null, m_map != null && m_map.IsDefaultMaterialEditorEnabled, m_map != null ? m_map.DefaultMaterialEditor : null) }; MaterialEditorDescriptor[] materialDescriptors = materials.Where(m => m.shader != null && !m.shader.name.StartsWith("Hidden/")) .Select(m => m.shader).Distinct() .OrderBy(s => s.name.StartsWith("Standard") ? string.Empty : s.name) .Select(s => new MaterialEditorDescriptor(s, m_map != null && editorsMap.IsMaterialEditorEnabled(s), m_map != null ? editorsMap.GetMaterialEditor(s, true) : null)).ToArray(); m_materialDescriptors = defaultDescriptors.Union(materialDescriptors).ToArray(); DestroyImmediate(editorsMapGo); }
private void Init() { m_map = Resources.Load <EditorsMapStorage>(EditorsMapStorage.EditorsMapPrefabName); EditorsMap.LoadMap(); Assembly unityAssembly = typeof(GameObject).Assembly; Assembly unityEditorAssembly = typeof(Editor).Assembly; Assembly unityUI = typeof(UnityEngine.UI.Button).Assembly; Assembly unityNet = typeof(UnityEngine.Networking.NetworkBehaviour).Assembly; Assembly yetAnotherAssembly = typeof(NetworkScenePostProcess).Assembly; Assembly[] otherAssemblies = AppDomain.CurrentDomain.GetAssemblies().Except(new[] { unityAssembly, unityEditorAssembly, unityUI, unityNet, yetAnotherAssembly }).ToArray(); m_objectEditorDescriptors = new[] { typeof(GameObject) } .Where(t => t.IsPublic && !t.IsGenericType) .Select(t => new EditorDescriptor(t, m_map != null && EditorsMap.IsObjectEditorEnabled(t), m_map != null ? EditorsMap.GetObjectEditor(t, true) : null, false)).ToArray(); m_propertyEditorDescriptors = new[] { typeof(object), typeof(UnityEngine.Object), typeof(bool), typeof(Enum), typeof(List <>), typeof(Array), typeof(string), typeof(int), typeof(float), typeof(Range), typeof(Vector2), typeof(Vector3), typeof(Vector4), typeof(Quaternion), typeof(Color), typeof(Bounds) } .Where(t => t.IsPublic) .Select(t => new EditorDescriptor(t, m_map != null && EditorsMap.IsPropertyEditorEnabled(t), m_map != null ? EditorsMap.GetPropertyEditor(t, true) : null, true)).ToArray(); m_stdComponentEditorDescriptors = unityAssembly.GetTypes() .Where(t => typeof(Component).IsAssignableFrom(t) && t.IsPublic && !t.IsGenericType) .OrderBy(t => (t == typeof(Component)) ? string.Empty : t.Name) .Select(t => new EditorDescriptor(t, m_map != null && EditorsMap.IsObjectEditorEnabled(t), m_map != null ? EditorsMap.GetObjectEditor(t, true) : null, false)).ToArray(); m_scriptEditorDescriptors = otherAssemblies.SelectMany(a => a.GetTypes()) .Where(t => typeof(MonoBehaviour).IsAssignableFrom(t) && t.IsPublic && !t.IsGenericType) .OrderBy(t => t.FullName) .Select(t => new EditorDescriptor(t, m_map != null && EditorsMap.IsObjectEditorEnabled(t), m_map != null ? EditorsMap.GetObjectEditor(t, true) : null, false)).ToArray(); List <Material> materials = new List <Material>(); string[] assets = AssetDatabase.GetAllAssetPaths(); foreach (string asset in assets) { if (!asset.EndsWith(".mat")) { continue; } Material material = AssetDatabase.LoadAssetAtPath <Material>(asset); if (material == null || (material.hideFlags & HideFlags.DontSaveInBuild) != 0 || material.shader == null || (material.shader.hideFlags & HideFlags.DontSaveInBuild) != 0) { continue; } materials.Add(material); } MaterialEditorDescriptor[] defaultDescriptors = new[] { new MaterialEditorDescriptor(null, m_map != null && m_map.IsDefaultMaterialEditorEnabled, m_map != null ? m_map.DefaultMaterialEditor : null) }; MaterialEditorDescriptor[] materialDescriptors = materials.Where(m => m.shader != null && !m.shader.name.StartsWith("Hidden/")) .Select(m => m.shader).Distinct() .OrderBy(s => s.name.StartsWith("Standard") ? string.Empty : s.name) .Select(s => new MaterialEditorDescriptor(s, m_map != null && EditorsMap.IsMaterialEditorEnabled(s), m_map != null ? EditorsMap.GetMaterialEditor(s, true) : null)).ToArray(); m_materialDescriptors = defaultDescriptors.Union(materialDescriptors).ToArray(); }