-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCustPropertyDrawer.cs
41 lines (36 loc) · 1.1 KB
/
CustPropertyDrawer.cs
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
using UnityEngine;
using UnityEditor;
using System.Collections;
[CustomPropertyDrawer(typeof(ArrayLayout))]
public class CustPropertyDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
EditorGUI.PrefixLabel(position, label);
Rect newposition = position;
newposition.y += 144f;
SerializedProperty data = property.FindPropertyRelative("rows");
//data.rows[0][]
if (data.arraySize != 8)
data.arraySize = 8;
for (int j = 0; j < 8; j++)
{
SerializedProperty row = data.GetArrayElementAtIndex(j).FindPropertyRelative("row");
newposition.height = 18f;
if (row.arraySize != 6)
row.arraySize = 6;
newposition.width = position.width / 6;
for (int i = 0; i < 6; i++)
{
EditorGUI.PropertyField(newposition, row.GetArrayElementAtIndex(i), GUIContent.none);
newposition.x += newposition.width;
}
newposition.x = position.x;
newposition.y -= 18f;
}
}
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
return 18f * 10;
}
}