Page 1 of 1

Timescale goes back to 1 mid-conversation (UIS shop/crafter)

Posted: Fri Jan 10, 2025 12:42 pm
by Cloid1
Hello,

I'm trying to setup a shopkeeper/crafter using Opsive's Ultimate Inventory System.

One node contains the opencrafting sequence: OpenCrafting([crafter], [craftMenu], [playerInventory]).
This node has children, so the conversation doesn't end upon opening or closing the crafting menu.
However, the game unpauses upon closing the crafting menu and I regain character control with dialogue options still on the screen.
I end up having to finish the conversation with mouse movement both panning the camera and navigating the dialogue menu.

Any help is appreciated.

Re: Timescale goes back to 1 mid-conversation (UIS shop/crafter)

Posted: Fri Jan 10, 2025 3:00 pm
by Tony Li
Hi,

When UIS closes a menu panel whose "Set TimeScale To Zero When Menu Is Opened" checkbox is ticked, such as the shop/crafter panels, it always sets time scale to 1.

You can add a script to the Crafting/Shop Menu to set time scale back to 0 if a conversation is active. The example script below hooks into the menu's DisplayPanel component > OnPanelClose() event:

Code: Select all

using System.Collections;
using UnityEngine;
using Opsive.UltimateInventorySystem.UI.Panels;
using PixelCrushers.DialogueSystem;

[RequireComponent(typeof(DisplayPanel))]
public class RemainPausedIfConversationActive : MonoBehaviour
{

    private void Start()
    {
        GetComponent<DisplayPanel>().OnClose += CheckConversationOnClose;
    }

    private void CheckConversationOnClose()
    {
        if (DialogueManager.isConversationActive)
        {
            StartCoroutine(PauseAtEndOfFrame());
        }
    }

    private IEnumerator PauseAtEndOfFrame()
    {
        yield return new WaitForEndOfFrame();
        Time.timeScale = 0;
    }
}

Re: Timescale goes back to 1 mid-conversation (UIS shop/crafter)

Posted: Fri Jan 10, 2025 6:55 pm
by Cloid1
Thank you so much!

Re: Timescale goes back to 1 mid-conversation (UIS shop/crafter)

Posted: Fri Jan 10, 2025 7:36 pm
by Tony Li
Glad to help!