From a39f20861cbbd7309ab9ba1324a01333fcf9279f Mon Sep 17 00:00:00 2001 From: mob-sakai Date: Fri, 22 Jun 2018 18:09:43 +0900 Subject: [PATCH] Add editor script --- .../UIExtentions/UIParticle/Editor.meta | 8 +++ .../UIParticle/Editor/UIParticleEditor.cs | 70 +++++++++++++++++++ .../Editor/UIParticleEditor.cs.meta | 11 +++ 3 files changed, 89 insertions(+) create mode 100644 Assets/Coffee/UIExtentions/UIParticle/Editor.meta create mode 100644 Assets/Coffee/UIExtentions/UIParticle/Editor/UIParticleEditor.cs create mode 100644 Assets/Coffee/UIExtentions/UIParticle/Editor/UIParticleEditor.cs.meta diff --git a/Assets/Coffee/UIExtentions/UIParticle/Editor.meta b/Assets/Coffee/UIExtentions/UIParticle/Editor.meta new file mode 100644 index 0000000..e0a9c3d --- /dev/null +++ b/Assets/Coffee/UIExtentions/UIParticle/Editor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f479867169fb04929b98c38e646b83c5 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Coffee/UIExtentions/UIParticle/Editor/UIParticleEditor.cs b/Assets/Coffee/UIExtentions/UIParticle/Editor/UIParticleEditor.cs new file mode 100644 index 0000000..8d67de2 --- /dev/null +++ b/Assets/Coffee/UIExtentions/UIParticle/Editor/UIParticleEditor.cs @@ -0,0 +1,70 @@ +using UnityEditor; +using UnityEditor.UI; +using UnityEngine; + +namespace Coffee.UIExtensions +{ + [CustomEditor(typeof(UIParticle))] + [CanEditMultipleObjects] + public class UIParticleEditor : GraphicEditor + { + //################################ + // Constant or Static Members. + //################################ + static readonly GUIContent contentParticleMaterial = new GUIContent("Particle Material", "The material for rendering particles"); + static readonly GUIContent contentTrailMaterial = new GUIContent("Trail Material", "The material for rendering particle trails"); + + + //################################ + // Public/Protected Members. + //################################ + /// + /// This function is called when the object becomes enabled and active. + /// + protected override void OnEnable() + { + base.OnEnable(); + _spParticleSystem = serializedObject.FindProperty("m_ParticleSystem"); + _spTrailParticle = serializedObject.FindProperty("m_TrailParticle"); + } + + /// + /// Implement this function to make a custom inspector. + /// + public override void OnInspectorGUI() + { + serializedObject.Update(); + + EditorGUILayout.PropertyField(_spParticleSystem); + EditorGUI.indentLevel++; + var ps = _spParticleSystem.objectReferenceValue as ParticleSystem; + if (ps) + { + var pr = ps.GetComponent(); + var sp = new SerializedObject(pr).FindProperty("m_Materials"); + + EditorGUILayout.PropertyField(sp.GetArrayElementAtIndex(0), contentParticleMaterial); + EditorGUILayout.PropertyField(sp.GetArrayElementAtIndex(1), contentTrailMaterial); + sp.serializedObject.ApplyModifiedProperties(); + + if(!Application.isPlaying && pr.enabled) + { + EditorGUILayout.HelpBox("ParticleSystemRenderer will be disable on playing.", MessageType.Info); + } + } + EditorGUI.indentLevel--; + + EditorGUI.BeginDisabledGroup(true); + EditorGUILayout.PropertyField(_spTrailParticle); + EditorGUI.EndDisabledGroup(); + + serializedObject.ApplyModifiedProperties(); + } + + //################################ + // Private Members. + //################################ + SerializedProperty _spParticleSystem; + SerializedProperty _spTrailParticle; + } +} \ No newline at end of file diff --git a/Assets/Coffee/UIExtentions/UIParticle/Editor/UIParticleEditor.cs.meta b/Assets/Coffee/UIExtentions/UIParticle/Editor/UIParticleEditor.cs.meta new file mode 100644 index 0000000..2407ef9 --- /dev/null +++ b/Assets/Coffee/UIExtentions/UIParticle/Editor/UIParticleEditor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 37cdd12f98487483aba53394d2174e31 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: