playMaker

Author Topic: Get property in prefab loosing settings after building [SOLVED]  (Read 4676 times)

Swift_Illusion

  • Playmaker Newbie
  • *
  • Posts: 41
    • Midnight Tinkering
Get property in prefab loosing settings after building [SOLVED]
« on: September 10, 2012, 06: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.
« Last Edit: December 09, 2013, 01:42:41 PM by jeanfabre »

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3987
  • Official Playmaker Support
    • LinkedIn
Re: Get property in prefab loosing settings after building and running project
« Reply #1 on: September 26, 2012, 07: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

Swift_Illusion

  • Playmaker Newbie
  • *
  • Posts: 41
    • Midnight Tinkering
Re: Get property in prefab loosing settings after building and running project
« Reply #2 on: September 28, 2012, 08: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 :).

TonkRogerio

  • Playmaker Newbie
  • *
  • Posts: 24
Re: Get property in prefab loosing settings after building and running project
« Reply #3 on: November 21, 2013, 08:34:07 AM »
Any news on this problem?

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3987
  • Official Playmaker Support
    • LinkedIn
Re: Get property in prefab loosing settings after building and running project
« Reply #4 on: November 21, 2013, 11: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.

TonkRogerio

  • Playmaker Newbie
  • *
  • Posts: 24
Re: Get property in prefab loosing settings after building and running project
« Reply #5 on: November 21, 2013, 12:30:26 PM »
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.
« Last Edit: November 21, 2013, 12:43:56 PM by TonkRogerio »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Get property in prefab loosing settings after building and running project
« Reply #6 on: November 28, 2013, 05: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

TonkRogerio

  • Playmaker Newbie
  • *
  • Posts: 24
Re: Get property in prefab loosing settings after building and running project
« Reply #7 on: December 08, 2013, 08: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.