mirror of
https://github.com/maxartz15/UnitySerializedReferenceUI.git
synced 2025-06-28 07:06:08 +02:00
Folders redirection
This commit is contained in:
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 827f3a2847b39a94eb6fcbdb0d73d6ca
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,8 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public class SerializeReferenceButtonAttribute : PropertyAttribute
|
||||
{
|
||||
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c64e0f68b41b48939c9b98cc29a19b20
|
||||
timeCreated: 1579584059
|
@ -0,0 +1,31 @@
|
||||
#if UNITY_EDITOR
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
[CustomPropertyDrawer(typeof(SerializeReferenceButtonAttribute))]
|
||||
public class SerializeReferenceButtonAttributeDrawer : PropertyDrawer
|
||||
{
|
||||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
|
||||
{
|
||||
return EditorGUI.GetPropertyHeight(property, true);
|
||||
}
|
||||
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
|
||||
|
||||
EditorGUI.BeginProperty(position, label, property);
|
||||
|
||||
var labelPosition = new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight);
|
||||
EditorGUI.LabelField(labelPosition, label);
|
||||
|
||||
var typeRestrictions = SerializedReferenceUIBuiltInTypeRestrictions.GetAllBuiltInTypeRestrictions(fieldInfo);
|
||||
property.DrawSelectionButtonForManagedReference(position, typeRestrictions);
|
||||
|
||||
EditorGUI.PropertyField(position, property, GUIContent.none, true);
|
||||
|
||||
EditorGUI.EndProperty();
|
||||
}
|
||||
}
|
||||
#endif
|
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5a07638044724309b6088c28a11a15af
|
||||
timeCreated: 1579584059
|
@ -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 = SerializeReferenceTypeNameUtility.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(filters);
|
||||
|
||||
GUI.backgroundColor = storedColor;
|
||||
EditorGUI.indentLevel = storedIndent;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 50b013bc3b4409b438f8781dee4dbbf1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -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
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ba51bcbc90077924abfcf504152b4a51
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ff8136ca43f822642adfa6388b137133
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,8 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public class SerializeReferenceMenuAttribute : PropertyAttribute
|
||||
{
|
||||
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4f1c372fa681cf146973df30a0d969fd
|
||||
timeCreated: 1579584059
|
@ -0,0 +1,26 @@
|
||||
#if UNITY_EDITOR
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
[CustomPropertyDrawer(typeof(SerializeReferenceMenuAttribute))]
|
||||
public class SerializeReferenceMenuAttributeDrawer : PropertyDrawer
|
||||
{
|
||||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
|
||||
{
|
||||
return EditorGUI.GetPropertyHeight(property, true);
|
||||
}
|
||||
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
EditorGUI.BeginProperty(position, label, property);
|
||||
|
||||
var typeRestrictions = SerializedReferenceUIBuiltInTypeRestrictions.GetAllBuiltInTypeRestrictions(fieldInfo);
|
||||
property.ShowContextMenuForManagedReferenceOnMouseMiddleButton(position, typeRestrictions);
|
||||
|
||||
EditorGUI.PropertyField(position, property, true);
|
||||
EditorGUI.EndProperty();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eaa31b1c39ee9424abe12fa0034d9d1b
|
||||
timeCreated: 1579584059
|
Reference in New Issue
Block a user