Forum rules - please read before posting.

Global scripts

Hi there,
I'm wondering if anybody has any advice where global scripts are concerned.

I know how to add a script to a scene by attaching it to an object, but what if I want the script to run across all scenes? Doesn't make sense to have to create an empty object for each scene just for this purpose.

A bit of a novice programmer, hopefully didn't miss the obvious answer...

Thanks!

Comments

  • If you want a quick solution, you can just add the script in question to the PersistentEngine prefab (found in Assets/AdventureCreator/Resources).

    Otherwise, you'll want to make use of Unity's DontDestroyOnLoad function, which prevents an object from being deleted after a scene change.  As this is not related to AC, however, you should search Unity's forums and Answers pages for more info about how to use it.
  • Awesome! Thanks for pointing me towards the PersistentEngine Chris.

    I have used DontDestroyOnLoad for music in the past (before I learned how to do it in ActionLists) but that still seemed a bit clumsy when testing individual scenes.

    Thanks again for the help.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.