Page 1 of 1

Issues with Changing UI at Runtime

Posted: Sat Apr 24, 2021 9:31 am
by Reznik
Hi, I'm having some challenges getting a UI change mid-conversation working properly and was wondering if anyone may have encountered this before or could help.

I know there is another thread on this and I've modeled my code based on that. Here is the Start() code for my ChangeUI Seqeuncer Command:

Code: Select all

// Get the values of the parameters:
            uiEntry = GetParameter(1);
            convoID = GetParameterAsInt(0);

            string title = DialogueManager.LastConversationStarted;
            DialogueManager.StopConversation();
            GameState.CutScene = true;
            DialogueManager.UseDialogueUI(GameObject.Find(uiEntry));
            GameObject cam = GlobalFunctions.FindObject(GameObject.Find("SceneCamHolder"), "SceneCamMain");
            if (cam == null)
                cam = GameObject.Find("SceneCamMain");

            DialogueManager.DisplaySettings.cameraSettings.sequencerCamera = cam.GetComponent<Camera>();
            DialogueManager.DisplaySettings.cameraSettings.alternateCameraObject = cam;
            Debug.Log("Set Camera");
            DialogueManager.StartConversation(title, DialogueManager.CurrentActor, DialogueManager.CurrentConversant, convoID);
            Stop();
The above code works, but there is some weirdness around the camera I cannot figure out. The 'SceneCamMain' is set as the main camera object in the Dialogue Manager GameObject but when i do a UI change and stop and restart the conversation, it causes the dialogue manager to create a clone of my SceneCamMain Object. To prevent that, I have to assign the cam to the sequencer camera and alterateCameraObject as shown above. This works but it also causes the camera location to change for some reason and I have to reset the location in sequence code.

The main problem with this is that for like a microsecond, the player can see the camera location adjusting before it goes back to the right spot. It's not terrible, but a bit disruptive and not super smooth. If there is a way I can either force the camera to stay where it is between UI changes or change the UI without needing to stop and restart the conversation, that would be super helpful.

Thanks! This is a fantastic product and is really helping cut down on the complexity of existing code I had.

Re: Issues with Changing UI at Runtime

Posted: Sat Apr 24, 2021 10:56 am
by Tony Li
Hi,

Instead of switching the entire UI, can you just use a different subtitle panel and/or menu panel? If so, then you can assign panels to participants' Dialogue Actor components (e.g., an overhead bubble panel) or use the [panel=#] markup tag or SetPanel() sequencer commands.

If not, then the issue with the camera is that the sequencer moves the camera back to its original, pre-conversation position when a conversation ends. It sounds like your DialogueManager.StopConversation() is moving the camera back to its original position, and then on the next frame whatever controls the camera is moving it into the right place.

Is your SceneMainCam tagged 'MainCamera'? If so, try unassigning it from the Dialogue Manager's Camera & Cutscene Settings > Sequencer Camera and Alternate Camera Object. This should get the sequencer to use it directly instead of making a clone.

Re: Issues with Changing UI at Runtime

Posted: Sat Apr 24, 2021 11:05 am
by Reznik
Thanks for the prompt response, that makes a lot of sense. I was so narrowly focused on the issue I wasn't considering the camera was returning to start.

Regarding the panel suggestion, I saw that mentioned in another thread. The desired effect I'm trying to achieve is switching seemlessy between letterbox and VN ui to give the impression of cutscene to dialogue. Is that something I could do through Panel reassignment?

Re: Issues with Changing UI at Runtime

Posted: Sat Apr 24, 2021 11:33 am
by Tony Li
Yes and no. You'd have to combine both into one dialogue UI, and do something like set up the VN panel's Unfocus animation to animate those black bars disappearing. In that regard, it's more work to set up in the UI in the Unity editor. But you won't have to worry about the camera since the conversation won't be temporarily stopped.

Re: Issues with Changing UI at Runtime

Posted: Sat Apr 24, 2021 3:15 pm
by Reznik
I seem to have this working mostly as expected now. The MainCamera tag did the trick regarding the clone.

As for the camera reset bit, in case anyone else has this problem and is interested, I created a second, temporary camera where I set the the position and rotation of the main camera just before stopping the conversation and making it active while the main cam is set to inactive. Once the conversation restarts on the new node with the new ui, i set the main cam to the desired position and re-activate while setting the temp cam to inactive.

Re: Issues with Changing UI at Runtime

Posted: Sat Apr 24, 2021 4:03 pm
by Tony Li
Thanks for the writeup. In the next update, I'll make the sequencer's originalCameraPosition property settable. This way you can set it to the current position so the camera won't move when the conversation ends.

Re: Issues with Changing UI at Runtime

Posted: Sat Apr 24, 2021 4:13 pm
by Reznik
That would be fantastic, thanks!