Skip to content

Commit

Permalink
fix: read-only properties in the inspector
Browse files Browse the repository at this point in the history
  • Loading branch information
mob-sakai committed Aug 11, 2020
1 parent d3dc612 commit f012b23
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions Packages/UIParticle/Scripts/Editor/UIParticleEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,20 +162,29 @@ public override void OnInspectorGUI()
{
serializedObject.Update();

EditorGUI.BeginDisabledGroup(true);
EditorGUILayout.PropertyField(_spParticleSystem);
EditorGUI.EndDisabledGroup();

EditorGUI.indentLevel++;
var ps = _spParticleSystem.objectReferenceValue as ParticleSystem;
if (ps)
{
var pr = ps.GetComponent<ParticleSystemRenderer>();
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)
{
Expand Down Expand Up @@ -282,4 +291,4 @@ void OnSceneGUI()
}
}
}
#endif // [ASMDEFEX] DO NOT REMOVE THIS LINE MANUALLY.
#endif // [ASMDEFEX] DO NOT REMOVE THIS LINE MANUALLY.

0 comments on commit f012b23

Please sign in to comment.