added more utilty packges

This commit is contained in:
Sebastian Bularca
2026-03-29 18:59:24 +02:00
parent ee97b2fec3
commit 71b432e253
131 changed files with 7674 additions and 54 deletions

View File

@@ -0,0 +1,47 @@
using UnityEditor;
using UnityEngine;
namespace InspectorToolkit
{
public class BitmaskAttribute : PropertyAttribute {
public string[] groupNames;
public BitmaskAttribute(params string[] groupNames) {
this.groupNames = groupNames;
}
}
}
#if UNITY_EDITOR
namespace InspectorToolkit.Internal
{
[CustomPropertyDrawer(typeof(BitmaskAttribute))]
public class BitmaskAttributeDrawer : PropertyDrawer {
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
if(property.propertyType != SerializedPropertyType.Integer) {
GUI.Label(position, "Error, SerializedProperty must be 'Integer' type");
return;
}
if(attribute is not BitmaskAttribute bitmaskAttribute) {
return;
}
string[] groups = bitmaskAttribute.groupNames;
if(groups.Length == 0 || groups.Length > 8) {
GUI.Label(position, "Error, bitmask group count not valid");
return;
}
EditorGUI.BeginProperty(position, label, property);
property.intValue = EditorGUI.MaskField(position, label, property.intValue, groups);
int indent = EditorGUI.indentLevel;
EditorGUI.indentLevel = 0;
EditorGUI.indentLevel = indent;
EditorGUI.EndProperty();
}
}
}
#endif