Hello!
I am sure this is a simple fix, but for the life of me I cannot find the answer here or figure it out myself.
I would like to alternate focus on 2 NPCs as they converse with the PC.
The fade works great, but the new NPC image remains on the topmost layer as shown in images.
I am using the VN template, and have assigned NPC 2 to Panel 2, which I don't think is a great solution given in the future there will be multiple conversations with multiple NPCs, and at times they will take the primary position...
Any pointers appreciated!!
Alternate focus on NPC portrait images
Re: Alternate focus on NPC portrait images
Hi,
I want to make sure I understand what you're asking.
The NPC is who speaking has focus, and the other NPCs are faded to a darker tint.
However, you also want the NPC who has focus to be rendered on top of the other portraits, correct? For example, in the third image, the NPC holding the paper is darkened, but he is rendered on top of the focused NPC (Cacey) and covers the focused NPC's elbow. Instead, you want the focused NPC to be on top so that his elbow is not covered?
I want to make sure I understand what you're asking.
The NPC is who speaking has focus, and the other NPCs are faded to a darker tint.
However, you also want the NPC who has focus to be rendered on top of the other portraits, correct? For example, in the third image, the NPC holding the paper is darkened, but he is rendered on top of the focused NPC (Cacey) and covers the focused NPC's elbow. Instead, you want the focused NPC to be on top so that his elbow is not covered?
Re: Alternate focus on NPC portrait images
Hello!
Yes that's correct. I would like them to be the topmost image when they are in focus.
This example isn't great because it is only the elbow, but I will have others which are more crowded.
D
Yes that's correct. I would like them to be the topmost image when they are in focus.
This example isn't great because it is only the elbow, but I will have others which are more crowded.
D
Re: Alternate focus on NPC portrait images
Hi,
You can put all of your portrait images on the same hierarchy level in your dialogue UI, and add a small script like this to your subtitle panels:
Here's an example scene:
DS_VNBringToFrontExample_2022-08-24.unitypackage
It's a copy of one of the VN example scenes on the Extras page, but I moved the portraits to the same hierarchy level (in a GameObject named "Portraits") and added the script above to the subtitle panels.
You can put all of your portrait images on the same hierarchy level in your dialogue UI, and add a small script like this to your subtitle panels:
BringToFrontOnFocus .cs
Code: Select all
using UnityEngine;
using PixelCrushers.DialogueSystem;
[RequireComponent(typeof(StandardUISubtitlePanel))]
public class BringToFrontOnFocus : MonoBehaviour
{
private StandardUISubtitlePanel panel;
private void Awake()
{
panel = GetComponent<StandardUISubtitlePanel>();
}
private void Start()
{
panel.onFocus.AddListener(BringPortraitToFront);
}
private void BringPortraitToFront()
{
panel.portraitImage.transform.SetAsLastSibling();
}
}
DS_VNBringToFrontExample_2022-08-24.unitypackage
It's a copy of one of the VN example scenes on the Extras page, but I moved the portraits to the same hierarchy level (in a GameObject named "Portraits") and added the script above to the subtitle panels.
Re: Alternate focus on NPC portrait images
Thanks Tony,
I have included the script and childed the portraits, and the layering seems to be working well now, if a little abrupt.
However the darkening of the portraits is no longer working?
Image shows what I mean and also the portraits in hierarchy.
What have I done here?
I have included the script and childed the portraits, and the layering seems to be working well now, if a little abrupt.
However the darkening of the portraits is no longer working?
Image shows what I mean and also the portraits in hierarchy.
What have I done here?
Re: Alternate focus on NPC portrait images
Hi,
Since they're sprites, there's only "in front of" or "behind". I'm not sure how you'd make it less abrupt, unless you were perhaps to do some kind of temporary blending of the portraits, but I don't think that would actually look good.
I forgot about the animation. The dark/light fading is handled by animations. In Unity, animations work on GameObjects in a hierarchy. Since the hierarchy was changed (moving the portraits to be children of a shared GameObject), the current animation isn't able to work with it. This should work:
1. Move the portrait images back to their original places as children of Subtitle Panel 0, Subtitle Panel 1, etc., so the animations will work again.
2. Put the entire Subtitle Panel 0, Subtitle Panel 1, etc., GameObjects in a shared GameObject instead.
3. Make this small change to the script:
Since they're sprites, there's only "in front of" or "behind". I'm not sure how you'd make it less abrupt, unless you were perhaps to do some kind of temporary blending of the portraits, but I don't think that would actually look good.
I forgot about the animation. The dark/light fading is handled by animations. In Unity, animations work on GameObjects in a hierarchy. Since the hierarchy was changed (moving the portraits to be children of a shared GameObject), the current animation isn't able to work with it. This should work:
1. Move the portrait images back to their original places as children of Subtitle Panel 0, Subtitle Panel 1, etc., so the animations will work again.
2. Put the entire Subtitle Panel 0, Subtitle Panel 1, etc., GameObjects in a shared GameObject instead.
3. Make this small change to the script:
Code: Select all
using UnityEngine;
using PixelCrushers.DialogueSystem;
[RequireComponent(typeof(StandardUISubtitlePanel))]
public class BringToFrontOnFocus : MonoBehaviour
{
private StandardUISubtitlePanel panel;
private void Awake()
{
panel = GetComponent<StandardUISubtitlePanel>();
}
private void Start()
{
panel.onFocus.AddListener(BringPortraitToFront);
}
private void BringPortraitToFront()
{
panel.transform.SetAsLastSibling(); //<-- THIS CHANGE.
}
}
Re: Alternate focus on NPC portrait images
Thanks Tony!
Looking good now. I wonder if this is something others might want in their visual novel set up?
I'll keep going with the game and no doubt be in touch again if I hit another road bump - thanks again!!
Cheers!
Looking good now. I wonder if this is something others might want in their visual novel set up?
I'll keep going with the game and no doubt be in touch again if I hit another road bump - thanks again!!
Cheers!
Re: Alternate focus on NPC portrait images
Good thinking. I'll add this to the VN template prefab.