- Home /
Editor Script for selecting class property for saving
I am looking to provide fellow designers with a save to text tool which gives them the ability to select components of a gameobject and fields of the components for saving. For example, if we have the following class:
public class Character : Monobehaviour
{
public Vector2 position;
public Vector2 velocity;
etc
}
My users would be able to select the Character component of an object and then choose position from a drop down menu, my save script is then passed some kind of reference to the position field and can use this to save data during play mode.
I am not looking for someone to write the code for me but can anyone point me in the right direction please?
Answer by MarshCZA · Apr 15, 2020 at 03:15 PM
For anyone with a similar problem, I had to use some really messy reflection to get this to work.
This is where I started and is what I am using at the moment to display the field names and then to later get their values during saves: https://docs.microsoft.com/en-us/dotnet/api/system.reflection.fieldinfo?view=netframework-4.8