fix: always display materials in inspector

3.x
mob-sakai 2022-06-09 02:19:26 +09:00
parent dd2d185e4a
commit a10042d989
1 changed files with 2 additions and 11 deletions

View File

@ -30,8 +30,7 @@ namespace Coffee.UIExtensions
private SerializedProperty _spShrinkByMaterial; private SerializedProperty _spShrinkByMaterial;
private ReorderableList _ro; private ReorderableList _ro;
private bool _xyzMode; static private bool _xyzMode;
private bool _showMaterials;
private static readonly List<string> s_MaskablePropertyNames = new List<string> private static readonly List<string> s_MaskablePropertyNames = new List<string>
{ {
@ -58,14 +57,11 @@ namespace Coffee.UIExtensions
_spIgnoreCanvasScaler = serializedObject.FindProperty("m_IgnoreCanvasScaler"); _spIgnoreCanvasScaler = serializedObject.FindProperty("m_IgnoreCanvasScaler");
_spAnimatableProperties = serializedObject.FindProperty("m_AnimatableProperties"); _spAnimatableProperties = serializedObject.FindProperty("m_AnimatableProperties");
_spShrinkByMaterial = serializedObject.FindProperty("m_ShrinkByMaterial"); _spShrinkByMaterial = serializedObject.FindProperty("m_ShrinkByMaterial");
_showMaterials = EditorPrefs.GetBool("Coffee.UIExtensions.UIParticleEditor._showMaterials", true);
var sp = serializedObject.FindProperty("m_Particles"); var sp = serializedObject.FindProperty("m_Particles");
_ro = new ReorderableList(sp.serializedObject, sp, true, true, true, true); _ro = new ReorderableList(sp.serializedObject, sp, true, true, true, true);
_ro.elementHeight = EditorGUIUtility.singleLineHeight * 3 + 4; _ro.elementHeight = EditorGUIUtility.singleLineHeight * 3 + 4;
_ro.elementHeightCallback = _ => _showMaterials _ro.elementHeightCallback = _ => 3 * (EditorGUIUtility.singleLineHeight + 2);
? 3 * (EditorGUIUtility.singleLineHeight + 2)
: EditorGUIUtility.singleLineHeight + 2;
_ro.drawElementCallback = (rect, index, active, focused) => _ro.drawElementCallback = (rect, index, active, focused) =>
{ {
EditorGUI.BeginDisabledGroup(sp.hasMultipleDifferentValues); EditorGUI.BeginDisabledGroup(sp.hasMultipleDifferentValues);
@ -73,8 +69,6 @@ namespace Coffee.UIExtensions
rect.height = EditorGUIUtility.singleLineHeight; rect.height = EditorGUIUtility.singleLineHeight;
var p = sp.GetArrayElementAtIndex(index); var p = sp.GetArrayElementAtIndex(index);
EditorGUI.ObjectField(rect, p, GUIContent.none); EditorGUI.ObjectField(rect, p, GUIContent.none);
if (!_showMaterials) return;
rect.x += 15; rect.x += 15;
rect.width -= 15; rect.width -= 15;
var ps = p.objectReferenceValue as ParticleSystem; var ps = p.objectReferenceValue as ParticleSystem;
@ -98,9 +92,6 @@ namespace Coffee.UIExtensions
#endif #endif
EditorGUI.LabelField(new Rect(rect.x, rect.y, 150, rect.height), s_ContentRenderingOrder); EditorGUI.LabelField(new Rect(rect.x, rect.y, 150, rect.height), s_ContentRenderingOrder);
var content = EditorGUIUtility.IconContent(_showMaterials ? "VisibilityOn" : "VisibilityOff");
_showMaterials = GUI.Toggle(new Rect(rect.width - 55, rect.y, 24, 20), _showMaterials, content, EditorStyles.label);
if (GUI.Button(new Rect(rect.width - 35, rect.y, 60, rect.height), s_ContentRefresh, EditorStyles.miniButton)) if (GUI.Button(new Rect(rect.width - 35, rect.y, 60, rect.height), s_ContentRefresh, EditorStyles.miniButton))
{ {
foreach (UIParticle t in targets) foreach (UIParticle t in targets)