void OnGUI() { DrawHeader(); if (m_ButtonStyle == null) { m_ButtonStyle = new GUIStyle(GUI.skin.button); m_ButtonStyle.wordWrap = true; } if (m_GeneratorSettings == null) { EditorGUILayout.LabelField("GeneratorSettings.asset not found"); m_GeneratorSettings = EditorGUILayout.ObjectField(m_GeneratorSettings, typeof(GeneratorSettings), false) as GeneratorSettings; } EditorGUI.BeginDisabledGroup(m_GeneratorSettings == null); { // // generate folder // if (GUILayout.Button(GenerateFolderButtonContent, m_ButtonStyle)) // { // EditorApplication.ExecuteMenuItem("Assets/Create/Folder"); // } // generate data if (GUILayout.Button(GenerateButtonContent, m_ButtonStyle)) { string directoryPath = ""; foreach (var obj in Selection.objects) { if (obj == null) { continue; } if (!AssetDatabase.IsMainAsset(obj)) { continue; } var path = AssetDatabase.GetAssetPath(obj); bool isDirectory = Directory.Exists(path); directoryPath = (isDirectory) ? path : Directory.GetParent(path).FullName; break; } var savePath = EditorUtility.SaveFilePanel( "Generate ShaderGraph Data", directoryPath, "New Data", "" ); Debug.Log($"savePath: {savePath}"); if (!string.IsNullOrEmpty(savePath)) { GenerateData(savePath); } } } EditorGUI.EndDisabledGroup(); }
void OnEnable() { m_GeneratorSettings = m_GeneratorSettings ?? AssetDatabase.LoadAssetAtPath(GeneratorSettings.FilePath, typeof(GeneratorSettings)) as GeneratorSettings; }