Can I expose a custom struct in a MonoBehavior based script?

barskey 3 years ago updated by Lazlo Bonin (Lead Developer) 3 years ago 3

I have a script attached to a GameObject in which I use a custom struct to create a List of structs. Something like this:

public class MoveHistory : MonoBehaviour {
    public struct MoveFrame {
        public float deltaTime; // Time.deltaTime
        public Vector3 pos; // position         public MoveFrame (float t, Vector3 p) {             deltaTime = t;
            pos = p;
        }     }     private List<MoveFrame> frames;     // function to add list omitted for brevity     public MoveFrame GetFrame (int i) {         return frames [i];
    } }

When I use this script in a flow graph, for example, it will return a struct of type MoveFrame. Can I get the members of this struct, or expose it somehow?

As a workaround I could write separate getters for each member of my list item, but I would like to know if there is a more efficient way.

Bolt Version:
Unity Version:
Scripting Backend:
.NET Version (API Compatibility Level):

Cancel AOT safe Mode and add MoveFrame type.     Tools > Ludiq > Project Settings


Pending Review

That's correct, although you shouldn't have to disable AOT safe mode. :)