Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEditor;
  4. using UnityEngine;
  5.  
  6. [CustomPropertyDrawer(typeof(Unlockable))]
  7. public class UnlockableDrawer : PropertyDrawer
  8. {
  9. public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
  10. {
  11. EditorGUI.BeginProperty(position, label, property);
  12.  
  13. var indent = EditorGUI.indentLevel;
  14. EditorGUI.indentLevel = 1;
  15.  
  16. SerializedProperty successCountProperty = property.FindPropertyRelative("successCount");
  17. SerializedProperty needDataProperty = property.FindPropertyRelative("needData");
  18.  
  19. float xPosition = position.x;
  20. var labelPosition = new Rect(xPosition, position.y, 80, EditorGUI.GetPropertyHeight(successCountProperty));
  21. xPosition += 90;
  22. var successCountRect = new Rect(xPosition, position.y, 140, EditorGUI.GetPropertyHeight(successCountProperty));
  23. xPosition += 150;
  24. var needDataRect = new Rect(xPosition, position.y, 230, EditorGUI.GetPropertyHeight(needDataProperty));
  25.  
  26. var labelWidth = EditorGUIUtility.labelWidth;
  27. EditorGUIUtility.labelWidth = 110;
  28. EditorGUI.LabelField(labelPosition, new GUIContent("Unlockable"));
  29. EditorGUI.PropertyField(successCountRect, successCountProperty, new GUIContent("Success Count:"));
  30. EditorGUIUtility.labelWidth = 90;
  31. EditorGUI.PropertyField(needDataRect, needDataProperty, new GUIContent("Need Data:"));
  32. EditorGUIUtility.labelWidth = labelWidth;
  33.  
  34. EditorGUI.indentLevel = indent;
  35.  
  36. EditorGUI.EndProperty();
  37. }
  38.  
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement