UI update 02

This commit is contained in:
FloatGaming
2026-06-30 21:21:30 +08:00
parent b2a1e307a4
commit f62f643cfc
1666 changed files with 211081 additions and 22799 deletions
@@ -0,0 +1,80 @@
#if UNITY_EDITOR
using UnityEditor;
using UnityEngine;
using System;
using System.Linq;
namespace KD.Destro2D.Editor {
[CustomPropertyDrawer(typeof(Destruction), true)]
public class Destro2DMenu : PropertyDrawer
{
const float PAD = 2f;
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
EditorGUI.BeginProperty(position, label, property);
Rect header = new Rect(
position.x,
position.y,
position.width,
EditorGUIUtility.singleLineHeight
);
string title =
property.managedReferenceValue == null
? "Select Destruction Type"
: property.managedReferenceValue.GetType().Name;
if (GUI.Button(header, title, EditorStyles.popup))
{
var menu = new GenericMenu();
var types = TypeCache.GetTypesDerivedFrom<Destruction>()
.Where(t => !t.IsAbstract && !t.IsGenericType);
foreach (var type in types)
{
menu.AddItem(
new GUIContent(type.Name),
false,
() =>
{
property.managedReferenceValue = Activator.CreateInstance(type);
property.serializedObject.ApplyModifiedProperties();
}
);
}
menu.ShowAsContext();
}
if (property.managedReferenceValue != null)
{
Rect body = new Rect(
position.x,
position.y + EditorGUIUtility.singleLineHeight + PAD,
position.width,
EditorGUI.GetPropertyHeight(property, true)
);
EditorGUI.indentLevel++;
EditorGUI.PropertyField(body, property, GUIContent.none, true);
EditorGUI.indentLevel--;
}
EditorGUI.EndProperty();
}
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
if (property.managedReferenceValue == null)
return EditorGUIUtility.singleLineHeight;
return EditorGUIUtility.singleLineHeight +
PAD +
EditorGUI.GetPropertyHeight(property, true);
}
}
}
#endif
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 76818ebe2697ff646b7149645aede1f1
AssetOrigin:
serializedVersion: 1
productId: 358408
packageName: Destro 2D - Dynamic Sprite Destruction
packageVersion: 1.0.3
assetPath: Assets/Destro2DMain/Editor/Destro2DMenu.cs
uploadId: 925032