Page 1 of 1

Background Manager

Posted: Fri Jun 30, 2017 10:36 pm
by hellwalker
Hi Guys,

I made a simple setup to easily manage 2d backgrounds in Visual Novel/Adventure type games. I hope someone else will find this useful as well.

With this you can setup the database of different backgrounds and change them with DS Sequence command. And optionally save/load current BG.
It supports sprite BG and Prefab type BG. And has Scaling/Position offset options.

Image

You can use SetBackground(BGName) to set the BG if you use one Background Manager. Where BGName is the name of the BG in database.
You can use SetBackground(BGName, Gameobjectname) to target a specific Background Manager if you use several of them. Gameobjectname parameter is the name of the Gameobject that BackgroundManager is attached to.

Check the SecondaryBG toggle for all additional Background Managers.

You can add PersistentDataBackgroundManager to same GameObject you have attached BackgroundManager script to and this will save and load current BG with DS save system. But to use this you have to make sure each BackgroundManager gameobject has unique name, as the name is used as identifier in saves.

In the package you can find example scene that demonstrates BG manager in use.
You can download the package here: https://drive.google.com/open?id=0B81Lv ... nY3aUQ3RW8
Be sure to import Dialogue System plugin before you import this.

Re: Background Manager

Posted: Sat Jul 01, 2017 7:59 am
by Tony Li
Awesome! Thanks for sharing this! I like how you tied it into the persistent data system, too.

Re: Background Manager

Posted: Tue May 22, 2018 6:18 am
by Alatriste
Thanks for sharing! This can very useful! :)

Re: Background Manager

Posted: Tue May 22, 2018 1:22 pm
by Abelius
Oh, I've totally missed this out! And my side project is a VN-ish game. :roll:

Thanks for finding it for me, Alatriste, and for making it in the first place, Hellwalker. :mrgreen:

Re: Background Manager

Posted: Wed May 23, 2018 4:30 am
by Alatriste
Tony, a question about using the Background Manager script together with your VN package: is it a good idea to use them together, or the way the VN package is done makes unnecessary using BM?

Thanks!

P.d. You're welcome Abelius!

Re: Background Manager

Posted: Wed May 23, 2018 8:08 am
by Tony Li
As handy as it is, you probably don't need this script with the Visual Novel Framework. In the Visual Novel Framework, if your dialogue entry has a field named Background containing an image name, it will try to load the image from Resources and show it as the background.

Re: Background Manager

Posted: Sun Jun 03, 2018 5:18 am
by Alatriste
One more question regarding the Background Manager included in the VN Package:

Should I use only one BM in the scene to control the Background changes within the same scene? (for instance, imagine I have a general view of a room and then close up views for some objects) I guess the goal here is to have only one BM and replace the backgrounds using the variables, but I'm not sure about how to associate the background with a specific variable. :|

What I was trying so far was to create a "Resource" folder in the root of the project, then place there all my backgrounds and use the "Background Variable" field to call them from the dialogue (SetVariable("Background Variable") = "Room001_01") but that doesn't seem to work.

And if not, how do I load the desired background into the BM?

Re: Background Manager

Posted: Sun Jun 03, 2018 6:08 am
by Alatriste
Found I think, part of the answer:

Creating a "Background" field in your conversation. From there, you can just assign the name of the background you have in the "Resources" folder. Cannot believe was so easy. :oops:

The problem is that when I connect the 1st conversation to the 2nd. the background doesn't change...

Re: Background Manager

Posted: Sun Jun 03, 2018 10:47 am
by Tony Li
Hi,

You can also add a "Background" field to dialogue entry nodes and to actors.

If the dialogue entry node has a Background field, it will load the background image when that node plays.

If the actor has a Background field, it will load the background image whenever that actor speaks.