Major refactor.

Core now formed and contains all useful utility to create custom ui with restrictions.
Many methods was extracted from different classes and moved to core.

Undo is now supported(because unity's undo bug seems to be fixed).

Example now moved into same level separate folder.
This commit is contained in:
TextusGames
2020-05-16 20:15:24 +03:00
parent f47dd5d350
commit eeaadfc569
65 changed files with 138 additions and 86 deletions

View File

@ -0,0 +1,8 @@
using System;
using UnityEngine;
[AttributeUsage(AttributeTargets.Field)]
public class SerializeReferenceButtonAttribute : PropertyAttribute
{
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: c64e0f68b41b48939c9b98cc29a19b20
timeCreated: 1579584059

View File

@ -0,0 +1,31 @@
#if UNITY_EDITOR
using UnityEditor;
using UnityEngine;
[CustomPropertyDrawer(typeof(SerializeReferenceButtonAttribute))]
public class SerializeReferenceButtonAttributeDrawer : PropertyDrawer
{
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
return EditorGUI.GetPropertyHeight(property, true);
}
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
EditorGUI.BeginProperty(position, label, property);
var labelPosition = new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight);
EditorGUI.LabelField(labelPosition, label);
var typeRestrictions = SerializedReferenceUIDefaultTypeRestrictions.GetAllBuiltInTypeRestrictions(fieldInfo);
property.DrawSelectionButtonForManagedReference(position, typeRestrictions);
EditorGUI.PropertyField(position, property, GUIContent.none, true);
EditorGUI.EndProperty();
}
}
#endif

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 5a07638044724309b6088c28a11a15af
timeCreated: 1579584059