Advertisement
ElectricJesus

TestPropertyDrawer

Dec 20th, 2016
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.77 KB | None | 0 0
  1. using UnityEngine;
  2. using UnityEditor;
  3. using System.Collections;
  4.  
  5. [CustomPropertyDrawer(typeof(Test))]
  6. public class TestPropertyDrawer : PropertyDrawer {
  7.  
  8.     float lineHeight = 16;
  9.     float lineMargin = 2;
  10.  
  11.     public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
  12.     {
  13.         EditorGUI.BeginProperty(position, label, property);
  14.         SerializedProperty PropTestInt = property.FindPropertyRelative("testInt");
  15.         PropTestInt.intValue = EditorGUI.IntField(new Rect(position.x, position.y + lineHeight, position.width, lineHeight), PropTestInt.intValue);
  16.         EditorGUI.EndProperty();
  17.     }
  18.  
  19.     public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
  20.     {
  21.         return lineHeight;
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement