Background Manager

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
hellwalker
Posts: 112
Joined: Tue Jan 19, 2016 11:37 pm

Background Manager

Post 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.
User avatar
Tony Li
Posts: 21721
Joined: Thu Jul 18, 2013 1:27 pm

Re: Background Manager

Post by Tony Li »

Awesome! Thanks for sharing this! I like how you tied it into the persistent data system, too.
User avatar
Alatriste
Posts: 181
Joined: Wed Nov 11, 2015 5:07 pm
Contact:

Re: Background Manager

Post by Alatriste »

Thanks for sharing! This can very useful! :)
User avatar
Abelius
Posts: 312
Joined: Fri Jul 21, 2017 12:45 pm

Re: Background Manager

Post 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:
Unity 2019.4.9f1
Dialogue System 2.2.15
User avatar
Alatriste
Posts: 181
Joined: Wed Nov 11, 2015 5:07 pm
Contact:

Re: Background Manager

Post 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!
User avatar
Tony Li
Posts: 21721
Joined: Thu Jul 18, 2013 1:27 pm

Re: Background Manager

Post 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.
User avatar
Alatriste
Posts: 181
Joined: Wed Nov 11, 2015 5:07 pm
Contact:

Re: Background Manager

Post 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?
User avatar
Alatriste
Posts: 181
Joined: Wed Nov 11, 2015 5:07 pm
Contact:

Re: Background Manager

Post 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...
User avatar
Tony Li
Posts: 21721
Joined: Thu Jul 18, 2013 1:27 pm

Re: Background Manager

Post 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.
Post Reply