Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEditor;
- using UnityEngine;
- [CustomPropertyDrawer(typeof(Unlockable))]
- public class UnlockableDrawer : PropertyDrawer
- {
- public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
- {
- EditorGUI.BeginProperty(position, label, property);
- var indent = EditorGUI.indentLevel;
- EditorGUI.indentLevel = 1;
- SerializedProperty successCountProperty = property.FindPropertyRelative("successCount");
- SerializedProperty needDataProperty = property.FindPropertyRelative("needData");
- float xPosition = position.x;
- var labelPosition = new Rect(xPosition, position.y, 80, EditorGUI.GetPropertyHeight(successCountProperty));
- xPosition += 90;
- var successCountRect = new Rect(xPosition, position.y, 140, EditorGUI.GetPropertyHeight(successCountProperty));
- xPosition += 150;
- var needDataRect = new Rect(xPosition, position.y, 230, EditorGUI.GetPropertyHeight(needDataProperty));
- var labelWidth = EditorGUIUtility.labelWidth;
- EditorGUIUtility.labelWidth = 110;
- EditorGUI.LabelField(labelPosition, new GUIContent("Unlockable"));
- EditorGUI.PropertyField(successCountRect, successCountProperty, new GUIContent("Success Count:"));
- EditorGUIUtility.labelWidth = 90;
- EditorGUI.PropertyField(needDataRect, needDataProperty, new GUIContent("Need Data:"));
- EditorGUIUtility.labelWidth = labelWidth;
- EditorGUI.indentLevel = indent;
- EditorGUI.EndProperty();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement