Page 1 of 1

Saving a reference using Playmaker

Posted: Wed Sep 01, 2021 9:19 pm
by Binkey
This might be a stupid question, but how do I save just a reference to a game object using playmaker?

I'll try to explain the scenario I'm trying to accomplish.

I have a gameobject (wire) with an FSM that has two gameobject (pins) variables that it uses to position itself. I want to save the reference to these two objects and load them back into those variables at runtime. What really happens when I save those variables, is that it saves everything to do with those game objects (pins) (name, enabled, all components and their values, etc.), and when I load those variables, it just applies all those properties to the game objects (pins) I'm trying to reference and the pins variables are null.

I understand that when you save a gameobject with easy save, it's supposed to save all information accompanying that gameobject, but I simply want a one line, reference value to it, as if I were saving it as an integer or a string.

Thank you

Re: Saving a reference using Playmaker

Posted: Thu Sep 02, 2021 7:46 am
by Joel
Hi there,

To do this with PlayMaker you would need to create a script with a GameObject field and save this script. Fields of UnityEngine.Object types are stored by reference. Once loaded, you can then set your variable to the value of this field.

All the best,
Joel

Re: Saving a reference using Playmaker

Posted: Thu Sep 02, 2021 10:55 pm
by Binkey
Fantastic.

This worked perfectly for me. Thank you for the great tool. :)