From f012b238d97aad3fdc3107b1f9a197de869c43e6 Mon Sep 17 00:00:00 2001 From: mob-sakai Date: Wed, 12 Aug 2020 00:15:34 +0900 Subject: [PATCH] fix: read-only properties in the inspector --- .../Scripts/Editor/UIParticleEditor.cs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Packages/UIParticle/Scripts/Editor/UIParticleEditor.cs b/Packages/UIParticle/Scripts/Editor/UIParticleEditor.cs index d659c4a..f343b3b 100644 --- a/Packages/UIParticle/Scripts/Editor/UIParticleEditor.cs +++ b/Packages/UIParticle/Scripts/Editor/UIParticleEditor.cs @@ -162,7 +162,10 @@ public override void OnInspectorGUI() { serializedObject.Update(); + EditorGUI.BeginDisabledGroup(true); EditorGUILayout.PropertyField(_spParticleSystem); + EditorGUI.EndDisabledGroup(); + EditorGUI.indentLevel++; var ps = _spParticleSystem.objectReferenceValue as ParticleSystem; if (ps) @@ -170,12 +173,18 @@ public override void OnInspectorGUI() var pr = ps.GetComponent(); var sp = new SerializedObject(pr).FindProperty("m_Materials"); - EditorGUILayout.PropertyField(sp.GetArrayElementAtIndex(0), s_ContentParticleMaterial); - if (2 <= sp.arraySize) + EditorGUI.BeginChangeCheck(); + { + EditorGUILayout.PropertyField(sp.GetArrayElementAtIndex(0), s_ContentParticleMaterial); + if (2 <= sp.arraySize) + { + EditorGUILayout.PropertyField(sp.GetArrayElementAtIndex(1), s_ContentTrailMaterial); + } + } + if (EditorGUI.EndChangeCheck()) { - EditorGUILayout.PropertyField(sp.GetArrayElementAtIndex(1), s_ContentTrailMaterial); + sp.serializedObject.ApplyModifiedProperties(); } - sp.serializedObject.ApplyModifiedProperties(); if (!Application.isPlaying && pr.enabled) { @@ -282,4 +291,4 @@ void OnSceneGUI() } } } -#endif // [ASMDEFEX] DO NOT REMOVE THIS LINE MANUALLY. \ No newline at end of file +#endif // [ASMDEFEX] DO NOT REMOVE THIS LINE MANUALLY.