Page 1 of 1

CursorManager not re-hiding cursor on conversation end

Posted: Thu Apr 07, 2022 11:45 am
by destrucity
I am having an issue where the CursorManager is hiding my cursor properly at the start of the game, then showing it properly when a conversation starts, but when a conversation ends, it does not re-hide the cursor.

Here is a video of the issue:



I am on the educational version of Dialogue System (2_2_23).

Any ideas on how to have the cursor rehide / lock on conversation end? Let me know if there is any additional info I can provide.

Thanks for your help!

Re: CursorManager not re-hiding cursor on conversation end

Posted: Thu Apr 07, 2022 1:51 pm
by Tony Li
Hi,

Is CursorManager your own script?

If so, how is it detecting when the conversation starts?

Instead of using CursorManager to show the cursor when the conversation starts, what if you just tick the Dialogue System Trigger's "Show Cursor During Conversation"? This will show the cursor when the conversation starts and hide it when the conversation ends.

If you want to use CursorManager for that, add an OnConversationEnd(Transform) method that hides the cursor.

Re: CursorManager not re-hiding cursor on conversation end

Posted: Thu Apr 07, 2022 6:32 pm
by destrucity
Ha wow sorry, this is an old project and I thought that was one of the built in scripts. Glad to know about the Dialogue Trigger option, but I'd also appreciate any insight into what's wrong with the code I evidently wrote. 😂 I think I am using a solution similar to what you recommended. Thanks!

Code: Select all

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using PixelCrushers.DialogueSystem;
using System;

/// <summary>
/// Hides and locks cursor at start of game, shows cursor and unlocks during conversations.
/// </summary>
public class CursorManager : MonoBehaviour
{
    private void Awake()
    {
        DialogueManager.instance.GetComponent<PixelCrushers.InputDeviceManager>().controlCursorState = false;
        UpdateCursorVisibility(false);
    }
    private void UpdateCursorVisibility(bool shouldShowCursor)
    {
        Cursor.visible = shouldShowCursor;
        Cursor.lockState = shouldShowCursor ? CursorLockMode.None : CursorLockMode.Locked;
    }

    private void OnConversationEnded(Transform t)
    {
        UpdateCursorVisibility(false);
    }

    private void OnConversationStarted(Transform t)
    {
        UpdateCursorVisibility(true);
    }
    private void OnEnable()
    {
        DialogueManager.instance.conversationStarted += OnConversationStarted;
        DialogueManager.instance.conversationEnded += OnConversationEnded;
    }

    private void OnDisable()
    {
        DialogueManager.instance.conversationStarted -= OnConversationStarted;
        DialogueManager.instance.conversationEnded -= OnConversationEnded;
    }
}

Re: CursorManager not re-hiding cursor on conversation end

Posted: Thu Apr 07, 2022 8:59 pm
by Tony Li
I may need more details than that. By itself, it looks like that should work. However, since you're telling the Dialogue System's Input Device Manager to not touch the cursor, make sure your Dialogue System Trigger's "Show Cursor During Conversation" is UNticked.