common extensions and some utilities

This commit is contained in:
2025-03-19 00:18:40 +01:00
parent f80fd22a00
commit e62bd2aa6d
35 changed files with 323 additions and 58 deletions

View File

@@ -0,0 +1,34 @@
using System.Text;
using RebootKit.Engine.Foundation;
using UnityEditor;
using UnityEngine;
namespace RebootKitEditor.PropertyDrawers {
[CustomPropertyDrawer(typeof(SerializableGuid))]
public class SerializableGuidDrawer : PropertyDrawer {
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) {
EditorGUI.BeginProperty(position, label, property);
EditorGUILayout.TextField(label, BuildGuidString(FindGuidParts(property)));
EditorGUI.EndProperty();
}
public SerializedProperty[] FindGuidParts(SerializedProperty property) {
SerializedProperty[] res = {
property.FindPropertyRelative("A"),
property.FindPropertyRelative("B"),
property.FindPropertyRelative("C"),
property.FindPropertyRelative("D")
};
return res;
}
public string BuildGuidString(SerializedProperty[] parts) {
StringBuilder sb = new();
sb.AppendFormat("{0:X8}", parts[0].uintValue);
sb.AppendFormat("{0:X8}", parts[1].uintValue);
sb.AppendFormat("{0:X8}", parts[2].uintValue);
sb.AppendFormat("{0:X8}", parts[3].uintValue);
return sb.ToString();
}
}
}