Question about background field in VN framework

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
DragoonHP
Posts: 62
Joined: Tue Jan 15, 2019 8:17 am

Question about background field in VN framework

Post by DragoonHP »

So I read that I can change background by providing a "background" field in the conversation menu and then, DS will try to load the image from Resource folder.

Now my question is,
  • What if I need to position the images before displaying them? Most of my backgrounds are slightly bigger than the camera so I need to manually scale them.
  • How to animate the background? Let's say I want to pan the background from left to right.
User avatar
Tony Li
Posts: 22056
Joined: Thu Jul 18, 2013 1:27 pm

Re: Question about background field in VN framework

Post by Tony Li »

DragoonHP wrote: Wed Jan 23, 2019 3:36 pmWhat if I need to position the images before displaying them? Most of my backgrounds are slightly bigger than the camera so I need to manually scale them.
The Gameplay scene has a GameObject named Background Canvas. This has a child GameObject named Background. This GameObject's Rect Transform is configured to stretch to fit the screen. When you assign an image, it will fit the image to the screen. It's just a UI Image, and a script named BackgroundManager assigns different image assets to it. If you don't want it to stretch to fit the screen, you can change this behavior by changing the values of the Image component.
DragoonHP wrote: Wed Jan 23, 2019 3:36 pmHow to animate the background? Let's say I want to pan the background from left to right.
You could create an animation using Unity's Animation window, set up an animator controller, and then use any of the Animator sequencer commands, such as AnimatorPlay(), to control it. (More info on sequences: Cutscene Sequence Tutorial)
DragoonHP
Posts: 62
Joined: Tue Jan 15, 2019 8:17 am

Re: Question about background field in VN framework

Post by DragoonHP »

Tony Li wrote: Wed Jan 23, 2019 4:16 pm If you don't want it to stretch to fit the screen, you can change this behavior by changing the values of the Image component.
If I do this, the changes will be applied to all the background images right? Is there a way by which I can apply specific transform properties to specific backgrounds?
Tony Li wrote: Wed Jan 23, 2019 4:16 pm You could create an animation using Unity's Animation window, set up an animator controller, and then use any of the Animator sequencer commands, such as AnimatorPlay(), to control it. (More info on sequences: Cutscene Sequence Tutorial)
Thanks. In the starting I was wondering how to add it to the Background field, but looking back on it, that was a dumb idea.
User avatar
Tony Li
Posts: 22056
Joined: Thu Jul 18, 2013 1:27 pm

Re: Question about background field in VN framework

Post by Tony Li »

For these cases, you could ignore the VR Framework's Background feature and handle it yourself using SetActive() sequencer commands. The Background feature is really just a convenience; you're not required to use it.

You could create a whole bunch of background images with unique GameObject names, set them up exactly the way you want, and then set them all inactive.

When you get to a dialogue entry node where you want to change the background image (say from ImageA to ImageB), use this Sequence:

Code: Select all

SetActive(ImageA,false);
SetActive(ImageB,true)
To make sure the right background gets remembered in saved games, add an Active Saver component for each image. Add them to the Background Canvas since that GameObject stays active.
DragoonHP
Posts: 62
Joined: Tue Jan 15, 2019 8:17 am

Re: Question about background field in VN framework

Post by DragoonHP »

Thanks!
Post Reply