This commit is contained in:
2025-05-13 03:10:33 +03:00
parent 5f03062f42
commit e5e3172b0f
80 changed files with 9655 additions and 0 deletions
@@ -0,0 +1,42 @@
#if UNITY_EDITOR
using UnityEngine;
using UnityEditor;
using System.Reflection;
//using System;
[CustomPropertyDrawer (typeof (InspectorButton))]
public class InspectorButtonDrawer : PropertyDrawer {
public override void OnGUI (Rect pos, SerializedProperty prop, GUIContent label) {
SerializedObject O = prop.GetType ().GetField ("m_SerializedObject", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(prop) as SerializedObject;
Object[] TargetObjects = O.targetObjects;
string MethodName = prop.name;
char[] charsToTrim = {'_'};
MethodName = MethodName.Trim(charsToTrim);
MethodInfo TargetMethod = TargetObjects[0].GetType ().GetMethod (MethodName);
if (TargetMethod == null) {
GUI.color = Color.red;
GUI.Label(pos,"Method "+MethodName+" not found.");
GUI.color = Color.white;
return;
}
if (GUI.Button (pos, MethodName)) {
foreach (Object o in TargetObjects)
TargetMethod.Invoke(o,new object[0]);
}
}
}
#endif
[System.Serializable]
public struct InspectorButton { }