added some stuff

This commit is contained in:
Wong Sui Bin 2023-01-24 21:51:46 +08:00
parent 9b69003715
commit 3dbf2f9010
520 changed files with 176780 additions and 2 deletions

View file

@ -0,0 +1,39 @@
using UnityEditor;
using UnityEngine;
using Lemon.GenericLib.Generics;
namespace Lemon.GenericLib.Editor {
[CustomPropertyDrawer(typeof(Optional<>))]
public class OptionalPropertyDrawer : PropertyDrawer
{
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
var valueProperty = property.FindPropertyRelative("value");
return EditorGUI.GetPropertyHeight(valueProperty);
}
public override void OnGUI(
Rect position,
SerializedProperty property,
GUIContent label
)
{
var valueProperty = property.FindPropertyRelative("value");
var enabledProperty = property.FindPropertyRelative("enabled");
EditorGUI.BeginProperty(position, label, property);
position.width -= 24;
EditorGUI.BeginDisabledGroup(!enabledProperty.boolValue);
EditorGUI.PropertyField(position, valueProperty, label, true);
EditorGUI.EndDisabledGroup();
position.x += position.width + 24;
position.width = position.height = EditorGUI.GetPropertyHeight(enabledProperty);
position.x -= position.width;
EditorGUI.PropertyField(position, enabledProperty, GUIContent.none);
EditorGUI.EndProperty();
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f883a30b9c6fd0a40a1a9be2ea575b86
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: