playMaker

Author Topic: Serialize interface into Playmaker Action is not working  (Read 2804 times)

BagarraoEduardo

  • Playmaker Newbie
  • *
  • Posts: 2
Serialize interface into Playmaker Action is not working
« on: March 29, 2024, 05:17:56 AM »
Hello,

I have this action:

Code: [Select]
using System;
using LonelyJane.Services;
using LonelyJane.Services.Interfaces;
using Sirenix.OdinInspector;
using Sirenix.Serialization;
using UnityEngine;

namespace HutongGames.PlayMaker.Actions
{

[ShowOdinSerializedPropertiesInInspector]
public class InputMovementCallbackData : MonoBehaviour, ISerializationCallbackReceiver, ISupportsPrefabSerialization
{
[SerializeField, HideInInspector]
private SerializationData serializationData;

[OdinSerialize]
public IRewiredService RewiredService;

        public SerializationData SerializationData { get => serializationData; set => serializationData = value; }

        public void OnAfterDeserialize()
        {
UnitySerializationUtility.DeserializeUnityObject(this, ref serializationData);
        }

        public void OnBeforeSerialize()
        {
            UnitySerializationUtility.SerializeUnityObject(this, ref serializationData);
        }
    }

[ActionCategory(ActionCategory.Input)]
[Tooltip("Detects if the player is moving or not, calling an event according to it.")]
public class InputMovementCallback : FsmStateAction
{
public InputMovementCallbackData Data;

// Code that runs on entering the state.
public override void OnEnter()
{
Finish();
}


}

}

This, together with Odin Inspector, makes possible we pass interfaces on the Inspector. However, it appears it doesn't work in Playmaker(first attachment, called "Interface").

However, if change to the class instead of the interface, it works(second attachment, called "Class":

Code: [Select]
using System;
using LonelyJane.Services;
using LonelyJane.Services.Interfaces;
using Sirenix.OdinInspector;
using Sirenix.Serialization;
using UnityEngine;

namespace HutongGames.PlayMaker.Actions
{

[Serializable]
public class InputMovementCallbackData
{
public RewiredService RewiredService;
    }

[ActionCategory(ActionCategory.Input)]
[Tooltip("Detects if the player is moving or not, calling an event according to it.")]
public class InputMovementCallback : FsmStateAction
{
public InputMovementCallbackData Data;

// Code that runs on entering the state.
public override void OnEnter()
{
Finish();
}


}

}

There's any way or workaround to pass an interface instead of the class itself? 

Thank you so much in advance.

Best Regards,
Eduardo Bagarrão

BagarraoEduardo

  • Playmaker Newbie
  • *
  • Posts: 2
Re: Serialize interface into Playmaker Action is not working
« Reply #1 on: March 29, 2024, 05:26:42 AM »
Update: I know there's actions for Rewired, but I'm asking specifically the part of passing interfaces, because I'm planning to pass others to actions in the future.

Thank you so much in advance.

Best Regards,
Eduardo