miepzerino
2025-03-30 d2ab30e7a69bfe7efda63ae75812207377917bd3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
using UnityEditor;
 
namespace Flexalon.Editor
{
    [CustomEditor(typeof(FlexalonFlexibleLayout)), CanEditMultipleObjects]
    public class FlexalonFlexibleLayoutEditor : FlexalonComponentEditor
    {
        private SerializedProperty _direction;
        private SerializedProperty _wrap;
        private SerializedProperty _wrapDirection;
        private SerializedProperty _horizontalAlign;
        private SerializedProperty _verticalAlign;
        private SerializedProperty _depthAlign;
        private SerializedProperty _horizontalInnerAlign;
        private SerializedProperty _verticalInnerAlign;
        private SerializedProperty _depthInnerAlign;
        private SerializedProperty _gapType;
        private SerializedProperty _gap;
        private SerializedProperty _wrapGapType;
        private SerializedProperty _wrapGap;
 
        [MenuItem("GameObject/Flexalon/Flexible Layout")]
        public static void Create(MenuCommand command)
        {
            FlexalonComponentEditor.Create<FlexalonFlexibleLayout>("Flexible Layout", command.context);
        }
 
        void OnEnable()
        {
            _direction = serializedObject.FindProperty("_direction");
            _wrap = serializedObject.FindProperty("_wrap");
            _wrapDirection = serializedObject.FindProperty("_wrapDirection");
            _horizontalAlign = serializedObject.FindProperty("_horizontalAlign");
            _verticalAlign = serializedObject.FindProperty("_verticalAlign");
            _depthAlign = serializedObject.FindProperty("_depthAlign");
            _horizontalInnerAlign = serializedObject.FindProperty("_horizontalInnerAlign");
            _verticalInnerAlign = serializedObject.FindProperty("_verticalInnerAlign");
            _depthInnerAlign = serializedObject.FindProperty("_depthInnerAlign");
            _gapType = serializedObject.FindProperty("_gapType");
            _gap = serializedObject.FindProperty("_gap");
            _wrapGapType = serializedObject.FindProperty("_wrapGapType");
            _wrapGap = serializedObject.FindProperty("_wrapGap");
        }
 
        public override void OnInspectorGUI()
        {
            serializedObject.Update();
            ForceUpdateButton();
            SerializedObject so = serializedObject;
            EditorGUILayout.PropertyField(_direction);
            EditorGUILayout.PropertyField(_wrap);
 
            if ((target as FlexalonFlexibleLayout).Wrap)
            {
                EditorGUILayout.PropertyField(_wrapDirection);
            }
 
            EditorGUILayout.PropertyField(_horizontalAlign);
            EditorGUILayout.PropertyField(_verticalAlign);
            EditorGUILayout.PropertyField(_depthAlign);
            EditorGUILayout.PropertyField(_horizontalInnerAlign);
            EditorGUILayout.PropertyField(_verticalInnerAlign);
            EditorGUILayout.PropertyField(_depthInnerAlign);
            EditorGUILayout.PropertyField(_gapType);
 
            if (_gapType.intValue == (int)FlexalonFlexibleLayout.GapOptions.Fixed)
            {
                EditorGUILayout.PropertyField(_gap);
            }
 
            if ((target as FlexalonFlexibleLayout).Wrap)
            {
                EditorGUILayout.PropertyField(_wrapGapType);
                if (_wrapGapType.intValue == (int)FlexalonFlexibleLayout.GapOptions.Fixed)
                {
                    EditorGUILayout.PropertyField(_wrapGap);
                }
            }
 
            ApplyModifiedProperties();
        }
    }
}