public static void ShowWindow(SunGeneratorEditor targ) { SaveToTextureSunWindow win = GetWindow <SaveToTextureSunWindow>(false, "Save animated", true); win.target = targ; win.target.TimeStep = 5.0f; }
public override void OnInspectorGUI() { current = this; SunGenerator tTarget = (SunGenerator)target; EditorGUI.BeginChangeCheck(); DrawDefaultInspector(); if (EditorGUI.EndChangeCheck()) { tTarget.Build(); } GUILayout.Space(6); GUILayout.BeginHorizontal(); if (GUILayout.Button(new GUIContent("Save animated", "Save animation to texture and create material"))) { SaveToTextureSunWindow.ShowWindow(this); AssetDatabase.Refresh(); } GUI.enabled = tTarget.ShaderMode != SunGenerator.EModeSM.CPU_2SM3 && tTarget.ShaderMode != SunGenerator.EModeSM.CPU_SM3 && tTarget.ShaderMode != SunGenerator.EModeSM.CPU_SM4 && tTarget.ShaderMode != SunGenerator.EModeSM.LIGHT_CPU; if (GUILayout.Button(new GUIContent("Save material", "Save current material"))) { string path = EditorUtility.SaveFilePanel("", Application.dataPath, target.name, "mat"); MeshRenderer mr = tTarget.GetComponent <MeshRenderer>(); if (path.Length != 0 && mr != null) { Material mat = mr.sharedMaterial; path = path.Replace(Application.dataPath, "Assets"); AssetDatabase.CreateAsset(mat, path); AssetDatabase.Refresh(); } } GUI.enabled = true; GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (GUILayout.Button(new GUIContent("Load Themplate", "Load parameters to xml"))) { string path = EditorUtility.OpenFilePanel( "Load template from XML", "/Assets/SunShader/Temlpates", "xml"); if (path.Length != 0) { LoadXml(path, ref tTarget); } } if (GUILayout.Button(new GUIContent("Save Themplate", "Save parameters to xml"))) { string path = EditorUtility.SaveFilePanel( "Save template as XML", "/Assets/SunShader/Temlpates", target.name + ".xml", "xml"); if (path.Length != 0) { SaveXml(path, ref tTarget); } } GUILayout.EndHorizontal(); }