Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: heavygunner on December 05, 2018, 10:23:16 PM

Title: [Solved] Keeping UI & another object on all scenes
Post by: heavygunner on December 05, 2018, 10:23:16 PM
Hi !

I made a casual game with 20 levels. 20 scenes.
I created UI only for one scene so far. Also UI , Camera & another GameManager (with lot of FSM) should be common for all scenes.

I made prefab of both UI, Camera & game Manager and put on all other scenes. it not worked. It gave so much "missing target" error. (GameManager has an FSM to enable * disable UI screen)

Ya ! Entire project ruined  >:( >:( >:( >:( . Now I loaded backup project. How can I put the UI, Camera & Game Manager to all other scenes?

Thanks
Title: Re: Keeping UI & another object on all scenes
Post by: heavygunner on December 06, 2018, 05:05:27 AM
However, Well, I tried Don'tDestroyOnLoad. But, I didn't made it.
However, I m gonna redesign 20 levels again (won't take more than an hour) with new UI.

But, still looking for easiest solution
Title: Re: Keeping UI & another object on all scenes
Post by: jeanfabre on December 06, 2018, 06:31:59 AM
Hi,

 you have likely hardcoded references of gameobjects so when you move scenes, it looses the references.

make one scene for your UI and load that scene additively, then create a system so that it can communicate without hard reference but instead find gameobjects by tag or within a look up list available on each scene.

Bye,

 Jean
Title: Re: Keeping UI & another object on all scenes
Post by: DanielThomas on December 06, 2018, 01:42:47 PM
I don't know if it's bad practice, but things that will be used in all scenes you could put under one prefab, references inside the same prefab should work.
I like it mostly because rolldown menus are way more convenient when sending and getting variables between objects.

Something I'm curious about is how Unity works if you do a 'find game object' on the first frame when the game startup is there a chance the object hasn't been created in the scene yet? Or do Unity create all objects, then starts running through scripts/components?
Title: Re: Keeping UI & another object on all scenes
Post by: djaydino on December 06, 2018, 04:26:10 PM
Hi.

Load scene additive would be a good way to go like jean suggested.

Here's a tutorial about load scene async additive :

Title: Re: Keeping UI & another object on all scenes
Post by: heavygunner on December 06, 2018, 10:29:50 PM
Hi.

Load scene additive would be a good way to go like jean suggested.

Here's a tutorial about load scene async additive :

Hi !

Thank you :)
It worked.

I added DontDestroyOnLoad to Gamemanager & other necessary objects.

But, I have a Restart Function too. If Player lost, he can Restart level. Once Restarted Level, I see objects I added DontDestroyOnLoad doubled. Everything doubled. How can i fix it ?
Title: Re: Keeping UI & another object on all scenes
Post by: heavygunner on December 06, 2018, 10:36:07 PM
Hi.

Load scene additive would be a good way to go like jean suggested.

Here's a tutorial about load scene async additive :

Hi !

Thank you :)
It worked.

I added DontDestroyOnLoad to Gamemanager & other necessary objects.

But, I have a Restart Function too. If Player lost, he can Restart level. Once Restarted Level, I see objects I added DontDestroyOnLoad doubled. Everything doubled. How can i fix it ?
I searched on Ecosystem for SINGLETONE . Got no results.
Found it after spelled correctly.

But, I don't know how to use it. Will try and update thread later
Title: Re: Keeping UI & another object on all scenes
Post by: heavygunner on December 07, 2018, 12:03:32 AM
This method is working well. Even Singleton.
Unfortunately, The way I designed game is not compatible with these action. I have 20 Scenes, Each scenes had different Small maps. Each map has 10 Spawn points. So, FSM losing reference to spawn points upon restart & Load next levels.

So, Again I have to resume redesign the levels.

Thank you for everyone's input. learned important things today.
Title: Re: Keeping UI & another object on all scenes
Post by: djaydino on December 07, 2018, 01:23:35 AM
Hi.
Maybe you can use arrays or array maker to place the spawn points in.
Title: Re: Keeping UI & another object on all scenes
Post by: heavygunner on December 07, 2018, 06:47:16 AM
Oh !
I did manually :D
Will use this in future if wanted.

thank you very much