mirror of
https://github.com/maxartz15/UnitySerializedReferenceUI.git
synced 2024-11-21 23:25:36 +01:00
editor namespace
This commit is contained in:
parent
0d04c50612
commit
acec8003c1
@ -4,9 +4,11 @@ using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
[CustomPropertyDrawer(typeof(SerializeReferenceButtonAttribute))]
|
||||
public class SerializeReferenceButtonAttributeDrawer : PropertyDrawer
|
||||
namespace Textus.SerializeReferenceUI.Editor
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(SerializeReferenceButtonAttribute))]
|
||||
public class SerializeReferenceButtonAttributeDrawer : PropertyDrawer
|
||||
{
|
||||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
|
||||
{
|
||||
return EditorGUI.GetPropertyHeight(property, true);
|
||||
@ -26,5 +28,6 @@ public class SerializeReferenceButtonAttributeDrawer : PropertyDrawer
|
||||
|
||||
EditorGUI.EndProperty();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@ -4,9 +4,11 @@ using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
[CustomPropertyDrawer(typeof(SerializeReferenceMenuAttribute))]
|
||||
public class SerializeReferenceMenuAttributeDrawer : PropertyDrawer
|
||||
namespace Textus.SerializeReferenceUI.Editor
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(SerializeReferenceMenuAttribute))]
|
||||
public class SerializeReferenceMenuAttributeDrawer : PropertyDrawer
|
||||
{
|
||||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
|
||||
{
|
||||
return EditorGUI.GetPropertyHeight(property, true);
|
||||
@ -22,5 +24,6 @@ public class SerializeReferenceMenuAttributeDrawer : PropertyDrawer
|
||||
EditorGUI.PropertyField(position, property, true);
|
||||
EditorGUI.EndProperty();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@ -6,8 +6,10 @@ using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
public static class ManagedReferenceUtility
|
||||
namespace Textus.SerializeReferenceUI.Editor
|
||||
{
|
||||
public static class ManagedReferenceUtility
|
||||
{
|
||||
/// Creates instance of passed type and assigns it to managed reference
|
||||
public static object AssignNewInstanceOfTypeToManagedReference(this SerializedProperty serializedProperty, Type type)
|
||||
{
|
||||
@ -103,7 +105,7 @@ public static class ManagedReferenceUtility
|
||||
{
|
||||
if (string.IsNullOrEmpty(typename))
|
||||
{
|
||||
return ("","");
|
||||
return ("", "");
|
||||
}
|
||||
|
||||
string[] typeSplitString = typename.Split(char.Parse(" "));
|
||||
@ -112,5 +114,6 @@ public static class ManagedReferenceUtility
|
||||
|
||||
return (typeAssemblyName, typeClassName);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@ -5,8 +5,10 @@ using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
public static class SerializeReferenceGenericSelectionMenu
|
||||
namespace Textus.SerializeReferenceUI.Editor
|
||||
{
|
||||
public static class SerializeReferenceGenericSelectionMenu
|
||||
{
|
||||
/// Purpose.
|
||||
/// This is generic selection menu (will appear at position).
|
||||
/// Filtering.
|
||||
@ -14,7 +16,7 @@ public static class SerializeReferenceGenericSelectionMenu
|
||||
/// As well ass type or interface restrictions.
|
||||
/// As well as any custom restriction that is based on input type.
|
||||
/// And it will be performed on each Appropriate type found by TypeCache.
|
||||
public static void ShowContextMenuForManagedReference(this SerializedProperty property, Rect position, IEnumerable<Func<Type,bool>> filters = null)
|
||||
public static void ShowContextMenuForManagedReference(this SerializedProperty property, Rect position, IEnumerable<Func<Type, bool>> filters = null)
|
||||
{
|
||||
GenericMenu context = new GenericMenu();
|
||||
FillContextMenu(filters, context, property);
|
||||
@ -59,9 +61,9 @@ public static class SerializeReferenceGenericSelectionMenu
|
||||
genericMenuContext.AddItem(new GUIContent(entryName), false, AssignNewInstanceCommand, new GenericMenuParameterForAssignInstanceCommand(type, property));
|
||||
}
|
||||
|
||||
private static void AssignNewInstanceCommand(object objectGenericMenuParameter )
|
||||
private static void AssignNewInstanceCommand(object objectGenericMenuParameter)
|
||||
{
|
||||
GenericMenuParameterForAssignInstanceCommand parameter = (GenericMenuParameterForAssignInstanceCommand) objectGenericMenuParameter;
|
||||
GenericMenuParameterForAssignInstanceCommand parameter = (GenericMenuParameterForAssignInstanceCommand)objectGenericMenuParameter;
|
||||
Type type = parameter.Type;
|
||||
SerializedProperty property = parameter.Property;
|
||||
property.AssignNewInstanceOfTypeToManagedReference(type);
|
||||
@ -78,5 +80,6 @@ public static class SerializeReferenceGenericSelectionMenu
|
||||
public readonly SerializedProperty Property;
|
||||
public readonly Type Type;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@ -4,8 +4,10 @@ using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
public static class SerializeReferenceInspectorButton
|
||||
namespace Textus.SerializeReferenceUI.Editor
|
||||
{
|
||||
public static class SerializeReferenceInspectorButton
|
||||
{
|
||||
/// 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)
|
||||
{
|
||||
@ -26,7 +28,7 @@ public static class SerializeReferenceInspectorButton
|
||||
string className = isNull ? "Null (Assign)" : ClassName;
|
||||
string assemblyName = AssemblyName;
|
||||
|
||||
if (GUI.Button(buttonPosition, new GUIContent(className, className + " ( "+ assemblyName +" )")))
|
||||
if (GUI.Button(buttonPosition, new GUIContent(className, className + " ( " + assemblyName + " )")))
|
||||
{
|
||||
property.ShowContextMenuForManagedReference(buttonPosition, filters);
|
||||
}
|
||||
@ -34,5 +36,6 @@ public static class SerializeReferenceInspectorButton
|
||||
GUI.backgroundColor = storedColor;
|
||||
EditorGUI.indentLevel = storedIndent;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@ -4,8 +4,10 @@ using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
public static class SerializeReferenceInspectorMiddleMouseMenu
|
||||
namespace Textus.SerializeReferenceUI.Editor
|
||||
{
|
||||
public static class SerializeReferenceInspectorMiddleMouseMenu
|
||||
{
|
||||
public static void ShowContextMenuForManagedReferenceOnMouseMiddleButton(this SerializedProperty property, Rect position, IEnumerable<Func<Type, bool>> filters = null)
|
||||
{
|
||||
Event e = Event.current;
|
||||
@ -16,5 +18,6 @@ public static class SerializeReferenceInspectorMiddleMouseMenu
|
||||
|
||||
property.ShowContextMenuForManagedReference(filters);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user