public static Type FindFilterTypeFromGUIName(string guiName) { if (guiName == Model.Settings.DEFAULT_FILTER_KEYTYPE) { return(null); // or UnityEngine.Object ? } // since PrefabImporter is internal class and can't access if (guiName == kPREFAB_KEY_NAME) { if (s_prefabImporterClass == null) { s_prefabImporterClass = Assembly.Load("UnityEditor").GetType(kPREFAB_IMPORTER_CLASS); } return(s_prefabImporterClass); } var typemap = ImporterConfiguratorUtility.GetImporterConfiguratorGuiNameTypeMap(); if (typemap.ContainsKey(guiName)) { return(typemap [guiName]); } if (s_defaultAssetFilterGUITypeMap.ContainsKey(guiName)) { return(s_defaultAssetFilterGUITypeMap [guiName]); } return(null); }
public static string FindGUINameFromType(Type t) { UnityEngine.Assertions.Assert.IsNotNull(t); // since PrefabImporter is internal class and can't access if (t.FullName == kPREFAB_IMPORTER_CLASS) { return(kPREFAB_KEY_NAME); } var typemap = ImporterConfiguratorUtility.GetImporterConfiguratorGuiNameTypeMap(); var elements = typemap.Where(v => v.Value == t); if (elements.Any()) { return(elements.First().Key); } var elements2 = s_defaultAssetFilterGUITypeMap.Where(v => v.Value == t); if (elements2.Any()) { return(elements2.First().Key); } return(Model.Settings.DEFAULT_FILTER_KEYTYPE); }
public static List <string> GetFilterGUINames() { if (s_filterKeyTypeList == null) { var typemap = ImporterConfiguratorUtility.GetImporterConfiguratorGuiNameTypeMap(); var keyList = new List <string> (); keyList.Add(Model.Settings.DEFAULT_FILTER_KEYTYPE); keyList.AddRange(typemap.Keys); keyList.AddRange(s_defaultAssetFilterGUITypeMap.Keys); s_filterKeyTypeList = keyList; } return(s_filterKeyTypeList); }
public static Type FindFilterTypeFromGUIName(string guiName) { if (guiName == Model.Settings.DEFAULT_FILTER_KEYTYPE) { return(null); // or UnityEngine.Object ? } var typemap = ImporterConfiguratorUtility.GetImporterConfiguratorGuiNameTypeMap(); if (typemap.ContainsKey(guiName)) { return(typemap [guiName]); } if (s_defaultAssetFilterGUITypeMap.ContainsKey(guiName)) { return(s_defaultAssetFilterGUITypeMap [guiName]); } return(null); }
public static string FindGUINameFromType(Type t) { Assertions.Assert.IsNotNull(t); var typemap = ImporterConfiguratorUtility.GetImporterConfiguratorGuiNameTypeMap(); var elements = typemap.Where(v => v.Value == t); if (elements.Any()) { return(elements.First().Key); } var elements2 = s_defaultAssetFilterGUITypeMap.Where(v => v.Value == t); if (elements2.Any()) { return(elements2.First().Key); } return(Model.Settings.DEFAULT_FILTER_KEYTYPE); }
public override void OnInspectorGUI(NodeGUI node, AssetReferenceStreamManager streamManager, NodeGUIEditor editor, Action onValueChanged) { EditorGUILayout.HelpBox("Overwrite Import Setting: Overwrite import settings of incoming assets.", MessageType.Info); editor.UpdateNodeName(node); // prevent inspector flicking by new Editor changing active selction node.SetActive(true); using (new EditorGUILayout.VerticalScope()) { Type importerType = null; Type assetType = null; var referenceImporter = GetReferenceAssetImporter(node.Data, false); if (referenceImporter != null) { importerType = referenceImporter.GetType(); assetType = TypeUtility.GetMainAssetTypeAtPath(AssetDatabase.GUIDToAssetPath(m_referenceAssetGuid)); } else { GUILayout.Space(10f); using (new EditorGUILayout.VerticalScope(GUI.skin.box)) { EditorGUILayout.HelpBox("Import setting type can be set by incoming asset, or you can specify by selecting.", MessageType.Info); using (new EditorGUILayout.HorizontalScope()) { EditorGUILayout.LabelField("Importer Type"); if (GUILayout.Button("", "Popup", GUILayout.MinWidth(150f))) { var menu = new GenericMenu(); var guiMap = ImporterConfiguratorUtility.GetImporterConfiguratorGuiNameTypeMap(); var guiNames = guiMap.Keys.ToArray(); for (var i = 0; i < guiNames.Length; i++) { var index = i; menu.AddItem( new GUIContent(guiNames [i]), false, () => { ResetConfig(node.Data); m_configureImporterFor = guiMap [guiNames [index]]; // call Validate NodeGUIUtility.NodeEventHandler(new NodeEvent(NodeEvent.EventType.EVENT_NODE_UPDATED, node)); } ); } menu.ShowAsContext(); } } } return; } if (importerType != null && assetType != null) { GUILayout.Space(10f); DoCustomAssetGUI(assetType, importerType, node, editor, onValueChanged); } // get reference importer again (enabling custom asset this time) referenceImporter = GetReferenceAssetImporter(node.Data, true); if (referenceImporter != null) { var configurator = m_configuratorInstance.Get <IAssetImporterConfigurator> (editor.CurrentEditingGroup); if (configurator != null) { GUILayout.Space(10f); Action onChangedAction = () => { using (new RecordUndoScope(string.Format("Change {0} Setting", node.Name), node)) { m_configuratorInstance.Set(editor.CurrentEditingGroup, configurator); onValueChanged(); } }; configurator.OnInspectorGUI(referenceImporter, editor.CurrentEditingGroup, onChangedAction); } if (m_importerEditor == null) { m_importerEditor = Editor.CreateEditor(referenceImporter); } } if (m_importerEditor != null) { GUILayout.Space(10f); GUILayout.Label(string.Format("Import Setting ({0})", importerType.Name)); m_importerEditor.OnInspectorGUI(); } GUILayout.Space(40f); using (new EditorGUILayout.HorizontalScope(GUI.skin.box)) { GUILayout.Space(4f); EditorGUILayout.LabelField("Clear Saved Import Setting"); if (GUILayout.Button("Clear")) { if (EditorUtility.DisplayDialog("Clear Saved Import Setting", string.Format("Do you want to reset saved import setting for \"{0}\"? This operation is not undoable.", node.Name), "OK", "Cancel")) { ResetConfig(node.Data); } } } } }