/// <summary> /// ヘッダ描画 /// </summary> private void DrawHeader() { using (new EditorGUILayout.HorizontalScope(EditorStyles.toolbar)) { if (GUILayout.Button("Open Generator", EditorStyles.toolbarButton)) { MaterialPresetGeneratorWindow.Open(); } GUILayout.FlexibleSpace(); if (GUILayout.Button("Select Preset", EditorStyles.toolbarButton)) { var shader = particleSystemRenderer?.sharedMaterial?.shader; if (shader != null) { var preset = ShaderPresetDatabase.Get()?.FindPreset(shader); if (preset != null) { Selection.activeObject = preset; } // EditorGUIUtility.PingObject(preset); } } } }
private void OnGUI() { DrawHeader(); using (new EditorGUILayout.VerticalScope(GUI.skin.box)) { EditorGUILayout.LabelField("■ ParticleSystem"); EditorGUI.BeginChangeCheck(); particleSystem = EditorGUILayout.ObjectField(particleSystem, typeof(ParticleSystem)) as ParticleSystem; if (EditorGUI.EndChangeCheck()) { if (particleSystem != null) { particleSystemRenderer = particleSystem.GetComponent <ParticleSystemRenderer>(); } else { particleSystemRenderer = null; } } EditorGUI.BeginDisabledGroup(true); EditorGUILayout.LabelField("■ Shader"); EditorGUI.indentLevel++; EditorGUILayout.ObjectField("Shader", particleSystemRenderer?.sharedMaterial?.shader, typeof(Shader), false); EditorGUI.indentLevel--; EditorGUI.EndDisabledGroup(); } using (new EditorGUILayout.VerticalScope(GUI.skin.box)) { EditorGUI.BeginDisabledGroup(particleSystemRenderer == null); if (GUILayout.Button("Apply")) { var shader = particleSystemRenderer.sharedMaterial.shader; if (shader != null) { var preset = ShaderPresetDatabase.Get().FindPreset(shader); PresetUtility.ApplyPreset(particleSystem, preset); } } EditorGUI.EndDisabledGroup(); } }