Added serializable action.
This commit is contained in:
@@ -5,6 +5,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using SerializableFunc.Runtime;
|
||||
using UnityEditor;
|
||||
using UnityEditor.UIElements;
|
||||
using UnityEditorInternal;
|
||||
@@ -12,11 +13,11 @@ using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using Utilities.Extensions.SystemExtensions;
|
||||
using Utilities.Extensions.UIToolkit;
|
||||
using UnityUtilities.SerializableDataHelpers;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
namespace UnityUtilities.SerializableDataHelpers.UnityEditorUtilities
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(SerializableAction), true)]
|
||||
[CustomPropertyDrawer(typeof(SerializableFuncBase<>), true)]
|
||||
public class SerializableFuncBasePropertyDrawer : PropertyDrawer
|
||||
{
|
||||
@@ -169,7 +170,11 @@ namespace UnityUtilities.SerializableDataHelpers.UnityEditorUtilities
|
||||
|| string.IsNullOrWhiteSpace(targetMethodProperty.stringValue)) return false;
|
||||
|
||||
Type[] funcArguments = GetFuncTypeArguments(funcProperty);
|
||||
Type returnType = funcArguments.Last();
|
||||
Type returnType = typeof(void);
|
||||
if (funcArguments.Length > 0)
|
||||
{
|
||||
returnType = funcArguments.Last();
|
||||
}
|
||||
|
||||
MethodInfo targetMethod = targetObjectProperty.objectReferenceValue
|
||||
.GetType()
|
||||
@@ -561,8 +566,15 @@ namespace UnityUtilities.SerializableDataHelpers.UnityEditorUtilities
|
||||
{
|
||||
if (info.IsSpecialName) return false;
|
||||
|
||||
Type returnType = funcParameters.Last();
|
||||
if (info.ReturnType != returnType) return false;
|
||||
if (funcParameters.Length > 0)
|
||||
{
|
||||
Type returnType = funcParameters.Last();
|
||||
if (info.ReturnType != returnType) return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (info.ReturnType == typeof(void)) return true;
|
||||
}
|
||||
|
||||
ParameterInfo[] parameters = info.GetParameters();
|
||||
if (parameters.Length != (funcParameters.Length - 1)) return false;
|
||||
|
||||
Reference in New Issue
Block a user