Question About a Main Menu Scene

Announcements, support questions, and discussion for the Dialogue System.
nitrox32
Posts: 68
Joined: Sat Dec 01, 2018 10:41 am

Question About a Main Menu Scene

Post by nitrox32 »

I'm creating a menu screen where the player can return in order to change settings, load a new game, start a new game, etc. When starting in the Main Menu the mouse cursor is visible and is responding. When I click the New Game or Load Game button the new scene starts as expected. The new scene is set to not have the mouse cursor visible (Control Cursor State unticked). I also created a small script that reloads the Main Menu when when I press F5. Upon pressing F5 the scene returns to the Main Menu. Only this time the mouse cursor is not visible in the Main Menu. Any Idea why? Shouldn't the mouse cursor settings go back the original settings in the Main Menu scene? Also, is my script necessary? Does DM have something would change scenes upon a key press already?
User avatar
Tony Li
Posts: 22056
Joined: Thu Jul 18, 2013 1:27 pm

Re: Question About a Main Menu Scene

Post by Tony Li »

Hi,

1. Put your Dialogue Manager in the Main Menu scene. When you get to the point in your project where you need to load a saved game including Dialogue System data from the Main Menu scene, the Dialogue Manager will need to be there.

2. Set the Dialogue Manager's Input Device Manager > Input Device to Mouse, or untick Control Cursor State.

The Dialogue System doesn't have something that will return to the Main Menu scene solely on a keypress, but it has something close. You can do this:

1. Set up a UI button (e.g., "Return to Menu").
2. Add a UI Button Key Trigger component to the button, and set the Key to F5.
3. Add a Save System Methods component to the button.
4. Configure the UI button's OnClick() event to call SaveSystemMethods.LoadScene. In the text field, enter the name of the Main Menu scene.
nitrox32
Posts: 68
Joined: Sat Dec 01, 2018 10:41 am

Re: Question About a Main Menu Scene

Post by nitrox32 »

Thanks for getting back to me. I set up my scenes as you suggested. The problem I still there. This only happens when going back to the Main Menu. Upon returning the mouse doesn't respond at all and the cursor is missing. I can tell the mouse isn't working because when I turn on the Mouse Tracking feature in Windows 10 and press the control button (which will highlight where the cursor is) it stays in the same place no matter where I move it. Could this have something to do with me using UCC and the UCC save system?
nitrox32
Posts: 68
Joined: Sat Dec 01, 2018 10:41 am

Re: Question About a Main Menu Scene

Post by nitrox32 »

Here is an update on the behavior I'm seeing. Currently the Main Menu scene is the only scene with Control Cursor State enabled. When I start in the Main Menu scene then load a new scene the cursor disappears as expected however when I return to the Main Menu the mouse no longer works. This behavior I've mentioned already, however when I enable Control Cursor State in the other scenes and return to the Main Menu the mouse cursor appears and moves, it just doesn't respond to mouse clicks. I not sure if this helps in diagnosing the problem but any help you can give me would be appreciated.
User avatar
Tony Li
Posts: 22056
Joined: Thu Jul 18, 2013 1:27 pm

Re: Question About a Main Menu Scene

Post by Tony Li »

Try to make your Dialogue Managers consistent across all scenes. As a test, remove the Dialogue Managers from all scenes except the Main Menu.

On the Main Menu's Dialogue Manager, tick Control Cursor State and UNtick Control Graphic Raycasters.

I'm updating to the latest UCC right now to check if it has any bearing on this.

Are you using regular Unity Input or Rewired?
nitrox32
Posts: 68
Joined: Sat Dec 01, 2018 10:41 am

Re: Question About a Main Menu Scene

Post by nitrox32 »

Regular Input. I have removed DM from all my scenes except the Main Menu and unticked Control Graphic Raycasters. I have mouse movement when I return to the Main Menu but the buttons that have to do with loading a scene or creating a new game (buttons using DM save system) don't respond to clicks. That's not entirely true, the button animation plays, but the actual loading of a new scene doesn't happen. The other buttons (exit game, audio and video settings, etc.) do respond normally.
User avatar
Tony Li
Posts: 22056
Joined: Thu Jul 18, 2013 1:27 pm

Re: Question About a Main Menu Scene

Post by Tony Li »

Did you hook up those buttons to a SaveSystem component or to a SaveSystemMethods component on the button? I recommend hooking them up to a SaveSystemMethods component:
saveSystemMethods.png
saveSystemMethods.png (30.11 KiB) Viewed 1168 times
This component will automatically find the SaveSystem.

If you hook up the button directly to the SaveSystem component, it's possible that it can become disconnected when changing scenes.
nitrox32
Posts: 68
Joined: Sat Dec 01, 2018 10:41 am

Re: Question About a Main Menu Scene

Post by nitrox32 »

That did it! I did not have my buttons set up correctly. I do have a question about the cursor. I would like to have the cursor visible on my menu scene but not on the game scenes. Is this possible? I am using the keyboard and mouse for controls for both the Menu and Game scenes. I just don't want to see the cursor in game.
User avatar
Tony Li
Posts: 22056
Joined: Thu Jul 18, 2013 1:27 pm

Re: Question About a Main Menu Scene

Post by Tony Li »

It's probably simplest to remove the Input Device Manager component from the Dialogue Manager. Add a script to the Main Menu scene that makes the cursor visible, since UCC will have left it invisible when returning from a gameplay scene.

Code: Select all

using UnityEngine;
public class SetMouseCursorVisible : MonoBehaviour {
    void Start() {
        Cursor.visible = true;
        Cursor.lockState = CursorLockMode.None; // fixed typo.
    }
}
nitrox32
Posts: 68
Joined: Sat Dec 01, 2018 10:41 am

Re: Question About a Main Menu Scene

Post by nitrox32 »

I just tried your code. I'm getting an error "The name 'LockState ' doesn't exist in the current context". I'm not a coder so what does this error mean? So right now this is what is happening, the scenes are transitioning properly so it appears that my initial problem has been fixed. However I'm trying to get the cursor to not be visible when the Game scene starts and become visible in the Main Menu. Here is how my scenes are set up:

Main Menu scene - Dialogue Manager set up with the Input Device Manager unticked.
Game scene - UCC saver added to the main character and Position Saver, Dialogue Manager added to scene, Unity's Input Device Manager Enabled, Script for when I press F5 to return to main menu.

Behaviors witnessed:

Scenario 1: When starting from the Main Menu then going to the Game scene:
The cursor is visible in the Menu scene and not visible in the Game scene. The F5 script doesn't respond in the game scene so I cannot return to the Main Menu.

Scenario 2: When starting from the game scene then moving to the Main Menu:

The cursor is not visible when Game scene starts. The F5 script responds in the game and I can return to the Main Menu. However when returning to the Game scene from the Main Menu the cursor becomes visible again and the F5 still responds as expected. One thing that is puzzling in this scenario is that upon returning to the Main Menu pressing the F5 key will cause the Main Menu to reload even though the F5 script isn't attached anywhere in the Main Menu scene. This doesn't occur in scenario 1. Another thing that occurs is that when switching back and forth between scenes the cursor will sometimes not be visible as desired. This seems to be occurring randomly.

Perhaps there is a conflict between Unity's Input Manager and DM's Input Device Manager? I have tried unticking DM's Input Manager in the Game scene but it had no effect. If I untick Unity's Input Manager the player controls do not respond. I hope this helps understand the problem. Perhaps getting the getting the CursorLockState error in the script you sent would help. BTW I using the current version of UCC and DM as well as Unity 2018.3.5f1. Thanks for any guidance you can give.
Post Reply