mirror of
https://github.com/maxartz15/UnitySerializedReferenceUI.git
synced 2025-06-18 10:46:08 +02:00
organize into upm directory structure
This commit is contained in:
45
DefaultUI/SerializeReferenceInspectorButton.cs
Normal file
45
DefaultUI/SerializeReferenceInspectorButton.cs
Normal file
@ -0,0 +1,45 @@
|
||||
#if UNITY_EDITOR
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
public static class SerializeReferenceInspectorButton
|
||||
{
|
||||
public static readonly Color SerializedReferenceMenuBackgroundColor = new Color(0.1f, 0.55f, 0.9f, 1f);
|
||||
|
||||
/// 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.DrawSelectionButtonForManagedReference(position, SerializedReferenceMenuBackgroundColor, filters);
|
||||
|
||||
/// Must be drawn before DefaultProperty in order to receive input
|
||||
public static void DrawSelectionButtonForManagedReference(this SerializedProperty property,
|
||||
Rect position, Color color, IEnumerable<Func<Type, bool>> filters = null)
|
||||
{
|
||||
|
||||
var backgroundColor = color;
|
||||
|
||||
var buttonPosition = position;
|
||||
buttonPosition.x += EditorGUIUtility.labelWidth + 1 * EditorGUIUtility.standardVerticalSpacing;
|
||||
buttonPosition.width = position.width - EditorGUIUtility.labelWidth - 1 * EditorGUIUtility.standardVerticalSpacing;
|
||||
buttonPosition.height = EditorGUIUtility.singleLineHeight;
|
||||
|
||||
var storedIndent = EditorGUI.indentLevel;
|
||||
EditorGUI.indentLevel = 0;
|
||||
var storedColor = GUI.backgroundColor;
|
||||
GUI.backgroundColor = backgroundColor;
|
||||
|
||||
|
||||
var names = ManagedReferenceUtility.GetSplitNamesFromTypename(property.managedReferenceFullTypename);
|
||||
var className = string.IsNullOrEmpty(names.ClassName) ? "Null (Assign)" : names.ClassName;
|
||||
var assemblyName = names.AssemblyName;
|
||||
if (GUI.Button(buttonPosition, new GUIContent(className, className + " ( "+ assemblyName +" )" )))
|
||||
property.ShowContextMenuForManagedReference(buttonPosition, filters);
|
||||
|
||||
GUI.backgroundColor = storedColor;
|
||||
EditorGUI.indentLevel = storedIndent;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
11
DefaultUI/SerializeReferenceInspectorButton.cs.meta
Normal file
11
DefaultUI/SerializeReferenceInspectorButton.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 50b013bc3b4409b438f8781dee4dbbf1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
21
DefaultUI/SerializeReferenceInspectorMiddleMouseMenu.cs
Normal file
21
DefaultUI/SerializeReferenceInspectorMiddleMouseMenu.cs
Normal file
@ -0,0 +1,21 @@
|
||||
#if UNITY_EDITOR
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
public static class SerializeReferenceInspectorMiddleMouseMenu
|
||||
{
|
||||
public static void ShowContextMenuForManagedReferenceOnMouseMiddleButton(this SerializedProperty property,
|
||||
Rect position, IEnumerable<Func<Type, bool>> filters = null)
|
||||
{
|
||||
var e = Event.current;
|
||||
if (e.type != EventType.MouseDown || !position.Contains(e.mousePosition) || e.button != 2)
|
||||
return;
|
||||
|
||||
property.ShowContextMenuForManagedReference(filters);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
11
DefaultUI/SerializeReferenceInspectorMiddleMouseMenu.cs.meta
Normal file
11
DefaultUI/SerializeReferenceInspectorMiddleMouseMenu.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ba51bcbc90077924abfcf504152b4a51
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user