UnityGame/Library/PackageCache/com.unity.ugui/Editor/UGUI/UI/GridLayoutGroupEditor.cs

57 lines
2.2 KiB
C#
Raw Normal View History

2024-10-27 10:53:47 +03:00
using UnityEngine;
using UnityEngine.UI;
using UnityEditorInternal;
using UnityEditor.AnimatedValues;
namespace UnityEditor.UI
{
[CustomEditor(typeof(GridLayoutGroup), true)]
[CanEditMultipleObjects]
/// <summary>
/// Custom Editor for the GridLayout Component.
/// Extend this class to write a custom editor for a component derived from GridLayout.
/// </summary>
public class GridLayoutGroupEditor : Editor
{
SerializedProperty m_Padding;
SerializedProperty m_CellSize;
SerializedProperty m_Spacing;
SerializedProperty m_StartCorner;
SerializedProperty m_StartAxis;
SerializedProperty m_ChildAlignment;
SerializedProperty m_Constraint;
SerializedProperty m_ConstraintCount;
protected virtual void OnEnable()
{
m_Padding = serializedObject.FindProperty("m_Padding");
m_CellSize = serializedObject.FindProperty("m_CellSize");
m_Spacing = serializedObject.FindProperty("m_Spacing");
m_StartCorner = serializedObject.FindProperty("m_StartCorner");
m_StartAxis = serializedObject.FindProperty("m_StartAxis");
m_ChildAlignment = serializedObject.FindProperty("m_ChildAlignment");
m_Constraint = serializedObject.FindProperty("m_Constraint");
m_ConstraintCount = serializedObject.FindProperty("m_ConstraintCount");
}
public override void OnInspectorGUI()
{
serializedObject.Update();
EditorGUILayout.PropertyField(m_Padding, true);
EditorGUILayout.PropertyField(m_CellSize, true);
EditorGUILayout.PropertyField(m_Spacing, true);
EditorGUILayout.PropertyField(m_StartCorner, true);
EditorGUILayout.PropertyField(m_StartAxis, true);
EditorGUILayout.PropertyField(m_ChildAlignment, true);
EditorGUILayout.PropertyField(m_Constraint, true);
if (m_Constraint.enumValueIndex > 0)
{
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(m_ConstraintCount, true);
EditorGUI.indentLevel--;
}
serializedObject.ApplyModifiedProperties();
}
}
}