#Using game objects from another scene in a script

1 messages · Page 1 of 1 (latest)

errant plume
#

I have an AR scene that I built a simple mini-game in. I wanted to add another AR mini-game to my project so I split off the reusable game objects/code into a "AR" scene and have a separate scene "ARShooter" contain that code/objects for each specific mini-game. Unfortunately this doesn't work because I can't use game objects (XROrigin/plane manager) from another scene in my minigame scene. So am I forced to create duplicate XROrigins for every one of my mini-games? I was hoping to avoid that.

#

The only other option I can see is having all the mini-games in one scene which seems worse then the above situation.

dark sedge
#

a) make the objects you want to use everywhere DDOL or b) load and unload the minigame scenes additively on top of the main scene as needed

errant plume
#

B is what I am attempting to do. However, unless I am misunderstanding, neither of your suggest approaches will work due to the limitation that I can't use game objects from another scene in a script.

#

I guess I can have an object attached to the AR scene script and get access to it through my service locator.

dark sedge
#

You can't use objects from a scene that hasn't been loaded. You can use them if both scenes are loaded.

#

If you mean that you can't drag references to objects in the inspector then yes that's a limitation but there's nothing wrong with setting the references by other means

errant plume
#

@dark sedge : Is there any standardized /best practice ways to set the reference?

faint jackal
spice prawn
#

the latter would be the easiest, since you don't need to go and find the correct minigame object (imagine if you had two or more minigames loaded at the same time!)