Playmaker Forum

Bug Reporting => PlayMaker Bug Reporting => Topic started by: Swift_Illusion on September 10, 2012, 03:25:57 AM

Title: Get property in prefab loosing settings after building [SOLVED]
Post by: Swift_Illusion on September 10, 2012, 03:25:57 AM
I've got a frustrating bug where I'm trying to get a game object form a scene, which because I'm trying to get that with prefab that is spawned into the scene, I can't simply get the game object, I have to get it's game object 'property' and assign that to a value, and use that value in the FSM.
The problem is, as soon as I try and build the game, the 'get property' object reverts to it's original state (as if you had just added it from the action manager) and so the game bugs out and it doesn't function.
It only does that when building the game, not when pressing the play button to preview it through the editor.
Currently my only workaround is to have the objects hidden in the actual scene and clone them, and in the FSM get the game object directly without using the 'get property' action.
Title: Re: Get property in prefab loosing settings after building and running project
Post by: Alex Chouls on September 26, 2012, 04:20:05 PM
I sent you an invite to the beta group. Please let me know if it fixes the issue you're seeing. If not, a small repro project would be very helpful.

Thanks!
Alex
Title: Re: Get property in prefab loosing settings after building and running project
Post by: Swift_Illusion on September 28, 2012, 05:45:10 PM
Thank you very much, I'm extremely thankful, and honored to have been invited into the beta group :)!
I've just finished doing further experimentation and detailing all of that, with an example project,
over in a topic in that beta group :).
Title: Re: Get property in prefab loosing settings after building and running project
Post by: TonkRogerio on November 21, 2013, 06:34:07 AM
Any news on this problem?
Title: Re: Get property in prefab loosing settings after building and running project
Post by: Alex Chouls on November 21, 2013, 09:56:39 AM
I think the specific issue in this thread has been fixed. What problem are you seeing? Remember that Unity prefabs cannot store references to scene objects. That is a Unity limitation.
Title: Re: Get property in prefab loosing settings after building and running project
Post by: TonkRogerio on November 21, 2013, 10:30:26 AM
This certainly makes my job a lot more difficult :/

So is there any way of going round this problem?

I have a prefab of a trigger and a ngui label with your current position.
On enter, the trigger saves the ngui label's current text (Fields). Then it sends an event to the ngui label, changing it to say "Near goblin lair".
On exit, The saved string gets send to the ngui label, changing it back to (Fields).

The trigger has to be a prefab unfortunately.

I should also mention that there will be multiple similar trigger prefabs and they all change the label to say something different.


Edit:- Well it just came to me. I guess I can store the game object on the thing that spawns the prefab. Then It can send that spawn the label game object. Going to try it now.
Title: Re: Get property in prefab loosing settings after building and running project
Post by: jeanfabre on November 28, 2013, 03:40:20 AM
Hi,

 yes, this is fine as a limitation ( and a very logical one, because a prefab can be spawned in different scenes, so it can not reference anything outside it's own hierarchy).

 As you said, simply keep the reference of what you want to reach outside the prefab, or get it when the prefab instantiated itself, using either some logical steps, like Find, or by keeping your ref in a global playmaker variable. Else the game can always fire an event to the nely created prefab with a reference of what it needs to know.

Bye,

 Jean
Title: Re: Get property in prefab loosing settings after building and running project
Post by: TonkRogerio on December 08, 2013, 06:36:48 AM
Sorry for the late reply.

Yes I have figured out how to solve this issue. I basically need to pass game objects from a non-prefab game object that is always in the scene, to the new loaded prefabs.

It's not as bad as I thought tbh.

Thanx for the help though.