private void DoInspectorImportSettingGUI(Node node) { EditorGUILayout.HelpBox("ImportSetting: Force apply import settings to given assets.", MessageType.Info); UpdateNodeName(node); GUILayout.Space(10f); if (packageEditMode) { EditorGUI.BeginDisabledGroup(true); } /* * importer node has no platform key. * platform key is contained by Unity's importer inspector itself. */ using (new EditorGUILayout.VerticalScope(GUI.skin.box)) { var nodeId = node.nodeId; var samplingPath = FileController.PathCombine(AssetBundleGraphSettings.IMPORTER_SETTINGS_PLACE, nodeId); IntegratedGUIImportSetting.ValidateImportSample(samplingPath, (string noFolderFound) => { EditorGUILayout.LabelField("Sampling Asset", "No sample asset found. please Reload first."); }, (string noFilesFound) => { EditorGUILayout.LabelField("Sampling Asset", "No sample asset found. please Reload first."); }, (string samplingAssetPath) => { EditorGUILayout.LabelField("Sampling Asset Path", samplingAssetPath); if (GUILayout.Button("Setup Import Setting")) { var obj = AssetDatabase.LoadAssetAtPath <UnityEngine.Object>(samplingAssetPath); Selection.activeObject = obj; } if (GUILayout.Button("Reset Import Setting")) { // delete all import setting files. FileController.RemakeDirectory(samplingPath); node.Save(); } }, (string tooManyFilesFoundMessage) => { if (GUILayout.Button("Reset Import Setting")) { // delete all import setting files. FileController.RemakeDirectory(samplingPath); node.Save(); } } ); } if (packageEditMode) { EditorGUI.EndDisabledGroup(); } UpdateDeleteSetting(node); }
private void DoInspectorModifierGUI(Node node) { EditorGUILayout.HelpBox("Modifier: Force apply asset settings to given assets.", MessageType.Info); UpdateNodeName(node); GUILayout.Space(10f); var currentModifierTargetType = IntegratedGUIModifier.ModifierOperationTargetTypeName(node.nodeId); using (new EditorGUILayout.VerticalScope(GUI.skin.box)) { var isOperationDataExist = false; IntegratedGUIModifier.ValidateModifiyOperationData( node.nodeId, node.currentPlatform, () => { GUILayout.Label("No modifier data found, please Reload first."); }, () => { isOperationDataExist = true; } ); if (!isOperationDataExist) { return; } using (new EditorGUILayout.HorizontalScope()) { GUILayout.Label("Target Type:"); GUILayout.Label(currentModifierTargetType); } /* * reset whole platform's data for this modifier. */ if (GUILayout.Button("Reset Modifier")) { var modifierFolderPath = FileController.PathCombine(AssetBundleGraphSettings.MODIFIER_OPERATOR_DATAS_PLACE, node.nodeId); FileController.RemakeDirectory(modifierFolderPath); node.Save(); modifierOperatorInstance = null; return; } } var currentPlatform = node.currentPlatform; node.currentPlatform = UpdateCurrentPlatform(node.currentPlatform); /* * if platform tab is changed, renew modifierOperatorInstance for that tab. */ if (currentPlatform != node.currentPlatform) { modifierOperatorInstance = null; } /* * reload modifierOperator instance from saved modifierOperator data. */ if (modifierOperatorInstance == null) { var modifierOperatorDataPath = IntegratedGUIModifier.ModifierDataPathForeachPlatform(node.nodeId, node.currentPlatform); // choose default modifierOperatorData if platform specified file is not exist. if (!File.Exists(modifierOperatorDataPath)) { modifierOperatorDataPath = IntegratedGUIModifier.ModifierDataPathForDefaultPlatform(node.nodeId); } var loadedModifierOperatorDataStr = string.Empty; using (var sr = new StreamReader(modifierOperatorDataPath)) { loadedModifierOperatorDataStr = sr.ReadToEnd(); } var modifierOperatorType = TypeBinder.SupportedModifierOperatorDefinition[currentModifierTargetType]; /* * create instance from saved modifierOperator data. */ modifierOperatorInstance = typeof(NodeEditor) .GetMethod("FromJson") .MakeGenericMethod(modifierOperatorType)// set desired generic type here. .Invoke(this, new object[] { loadedModifierOperatorDataStr }) as ModifierOperators.OperatorBase; } /* * Show ModifierOperator Inspector. */ if (modifierOperatorInstance != null) { Action changed = () => { var data = JsonUtility.ToJson(modifierOperatorInstance); var prettified = AssetBundleGraph.PrettifyJson(data); var modifierOperatorDataPath = IntegratedGUIModifier.ModifierDataPathForeachPlatform(node.nodeId, node.currentPlatform); using (var sw = new StreamWriter(modifierOperatorDataPath)) { sw.Write(prettified); } // reflect change of data. AssetDatabase.Refresh(); modifierOperatorInstance = null; }; GUILayout.Space(10f); modifierOperatorInstance.DrawInspector(changed); } var deleted = UpdateDeleteSetting(node); if (deleted) { // source platform depended data is deleted. reload instance for reloading instance from data. modifierOperatorInstance = null; } }