mirror of
https://github.com/maxartz15/UnitySerializedReferenceUI.git
synced 2025-07-04 09:56:10 +02:00
editor namespace
This commit is contained in:
@ -4,35 +4,38 @@ using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
public static class SerializeReferenceInspectorButton
|
||||
namespace Textus.SerializeReferenceUI.Editor
|
||||
{
|
||||
/// Must be drawn before DefaultProperty in order to receive input
|
||||
public static void DrawSelectionButtonForManagedReference(this SerializedProperty property, Rect position, IEnumerable<Func<Type, bool>> filters = null)
|
||||
public static class SerializeReferenceInspectorButton
|
||||
{
|
||||
Rect buttonPosition = position;
|
||||
buttonPosition.x += EditorGUIUtility.labelWidth + 1 * EditorGUIUtility.standardVerticalSpacing;
|
||||
buttonPosition.width = position.width - EditorGUIUtility.labelWidth - 1 * EditorGUIUtility.standardVerticalSpacing;
|
||||
buttonPosition.height = EditorGUIUtility.singleLineHeight;
|
||||
|
||||
Color storedColor = GUI.backgroundColor;
|
||||
int storedIndent = EditorGUI.indentLevel;
|
||||
EditorGUI.indentLevel = 0;
|
||||
|
||||
(string AssemblyName, string ClassName) = ManagedReferenceUtility.GetSplitNamesFromTypename(property.managedReferenceFullTypename);
|
||||
|
||||
bool isNull = string.IsNullOrEmpty(ClassName);
|
||||
GUI.backgroundColor = isNull ? Color.red : storedColor;
|
||||
|
||||
string className = isNull ? "Null (Assign)" : ClassName;
|
||||
string assemblyName = AssemblyName;
|
||||
|
||||
if (GUI.Button(buttonPosition, new GUIContent(className, className + " ( "+ assemblyName +" )")))
|
||||
/// Must be drawn before DefaultProperty in order to receive input
|
||||
public static void DrawSelectionButtonForManagedReference(this SerializedProperty property, Rect position, IEnumerable<Func<Type, bool>> filters = null)
|
||||
{
|
||||
property.ShowContextMenuForManagedReference(buttonPosition, filters);
|
||||
Rect buttonPosition = position;
|
||||
buttonPosition.x += EditorGUIUtility.labelWidth + 1 * EditorGUIUtility.standardVerticalSpacing;
|
||||
buttonPosition.width = position.width - EditorGUIUtility.labelWidth - 1 * EditorGUIUtility.standardVerticalSpacing;
|
||||
buttonPosition.height = EditorGUIUtility.singleLineHeight;
|
||||
|
||||
Color storedColor = GUI.backgroundColor;
|
||||
int storedIndent = EditorGUI.indentLevel;
|
||||
EditorGUI.indentLevel = 0;
|
||||
|
||||
(string AssemblyName, string ClassName) = ManagedReferenceUtility.GetSplitNamesFromTypename(property.managedReferenceFullTypename);
|
||||
|
||||
bool isNull = string.IsNullOrEmpty(ClassName);
|
||||
GUI.backgroundColor = isNull ? Color.red : storedColor;
|
||||
|
||||
string className = isNull ? "Null (Assign)" : ClassName;
|
||||
string assemblyName = AssemblyName;
|
||||
|
||||
if (GUI.Button(buttonPosition, new GUIContent(className, className + " ( " + assemblyName + " )")))
|
||||
{
|
||||
property.ShowContextMenuForManagedReference(buttonPosition, filters);
|
||||
}
|
||||
|
||||
GUI.backgroundColor = storedColor;
|
||||
EditorGUI.indentLevel = storedIndent;
|
||||
}
|
||||
|
||||
GUI.backgroundColor = storedColor;
|
||||
EditorGUI.indentLevel = storedIndent;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@ -4,17 +4,20 @@ using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
public static class SerializeReferenceInspectorMiddleMouseMenu
|
||||
namespace Textus.SerializeReferenceUI.Editor
|
||||
{
|
||||
public static void ShowContextMenuForManagedReferenceOnMouseMiddleButton(this SerializedProperty property, Rect position, IEnumerable<Func<Type, bool>> filters = null)
|
||||
public static class SerializeReferenceInspectorMiddleMouseMenu
|
||||
{
|
||||
Event e = Event.current;
|
||||
if (e.type != EventType.MouseDown || !position.Contains(e.mousePosition) || e.button != 2)
|
||||
public static void ShowContextMenuForManagedReferenceOnMouseMiddleButton(this SerializedProperty property, Rect position, IEnumerable<Func<Type, bool>> filters = null)
|
||||
{
|
||||
return;
|
||||
Event e = Event.current;
|
||||
if (e.type != EventType.MouseDown || !position.Contains(e.mousePosition) || e.button != 2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
property.ShowContextMenuForManagedReference(filters);
|
||||
}
|
||||
|
||||
property.ShowContextMenuForManagedReference(filters);
|
||||
}
|
||||
}
|
||||
#endif
|
Reference in New Issue
Block a user