Skip to content

Instantly share code, notes, and snippets.

@sdomenici009
Created December 2, 2015 07:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sdomenici009/7b25e5840003c23110a9 to your computer and use it in GitHub Desktop.
Save sdomenici009/7b25e5840003c23110a9 to your computer and use it in GitHub Desktop.
using UnityEngine;
using UnityEditor;
using System.Collections;
[CustomPropertyDrawer(typeof(TileData))]
public class CustomTileData : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
EditorGUI.PrefixLabel(position, label);
Rect newPosition = position;
newPosition.y += 18f;
SerializedProperty rows = property.FindPropertyRelative("rows");
for(int i=0; i < 10; i++)
{
SerializedProperty row = rows.GetArrayElementAtIndex(i).FindPropertyRelative("row");
newPosition.height = 20;
if (row.arraySize != 10)
row.arraySize = 10;
newPosition.width = 70;
for(int j=0; j < 10; j++)
{
EditorGUI.PropertyField(newPosition, row.GetArrayElementAtIndex(j), GUIContent.none);
newPosition.x += newPosition.width;
}
newPosition.x = position.x;
newPosition.y += 20;
}
}
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
return 20 * 12;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment