Suppress Pause Panel in Intro Scene

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Arctichorse9
Posts: 25
Joined: Wed Sep 25, 2024 11:26 pm
Location: New York City
Contact:

Suppress Pause Panel in Intro Scene

Post by Arctichorse9 »

I have an Intro Scene after the Start Scene (Main Menu scene) that leads to the first playable scene in the game.

I need to suppress the button that loads the Pause Panel in the Intro scene and I can't figure out how to do it.

Any help is appreciated. Thanks.
User avatar
Tony Li
Posts: 22091
Joined: Thu Jul 18, 2013 1:27 pm

Re: Suppress Pause Panel in Intro Scene

Post by Tony Li »

Hi,

Try adding a script like this to the intro scene:

DisablePauseMenuInThisScene.cs

Code: Select all

using UnityEngine;
using PixelCrushers.DialogueSystem.MenuSystem;
public class DisablePauseMenuInThisScene : MonoBehaviour
{
    private Pause pause;
    void Awake() { pause = FindFirstObjectByType<Pause>(); }
    void Start() { if (pause != null) pause.enabled = false; }
    void OnDestroy() { if (pause != null) pause.enabled = true; }
}
Arctichorse9
Posts: 25
Joined: Wed Sep 25, 2024 11:26 pm
Location: New York City
Contact:

Re: Suppress Pause Panel in Intro Scene

Post by Arctichorse9 »

Thank you so much for this. I spent hours trying to get something similar last night but had many error messages.

This gives me one error message and I'm sure it's me and not the code.

The error message is: Assets\HidePauseButton.cs(10,17): error CS0246: The type or namespace name 'PauseMenuButton' could not be found (are you missing a using directive or an assembly reference?)

My button that shows the Pause Panel is called PauseMenuButton.

So in your code I replaced Pause with PauseMenuButton.

Was that wrong? Your help is most appreciated.
User avatar
Tony Li
Posts: 22091
Joined: Thu Jul 18, 2013 1:27 pm

Re: Suppress Pause Panel in Intro Scene

Post by Tony Li »

Hi,

If PauseMenuButton is a UI Button you might want to deactivate the button GameObject entirely. In that case, use:

Code: Select all

using UnityEngine;
public class DisablePauseMenuInThisScene : MonoBehaviour
{
    void Start() { GameObjectUtility.GameObjectHardFind("PauseMenuButton").SetActive(false); }
    void OnDestroy() { GameObjectUtility.GameObjectHardFind("PauseMenuButton").SetActive(true); }
}
Arctichorse9
Posts: 25
Joined: Wed Sep 25, 2024 11:26 pm
Location: New York City
Contact:

Re: Suppress Pause Panel in Intro Scene

Post by Arctichorse9 »

Thank you. I will try that. It’s really only important on mobile.
Arctichorse9
Posts: 25
Joined: Wed Sep 25, 2024 11:26 pm
Location: New York City
Contact:

Re: Suppress Pause Panel in Intro Scene

Post by Arctichorse9 »

Yay! I can sleep tonight! I don't completely understand why but as I advance in knowledge undoubtedly I will.
: )

This works perfectly:

Code: Select all

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

public class HidePauseButton : MonoBehaviour
{

        //private gameObject PauseMenuButton;
        void Start()
        {
            
            GameObject.Find("PauseMenuButton").SetActive(false);
        }
    
        void OnDestroy()
        {
            GameObject.Find("PauseMenuButton").SetActive(true);
        }
 
 }
Thank so much!!!!!!
User avatar
Tony Li
Posts: 22091
Joined: Thu Jul 18, 2013 1:27 pm

Re: Suppress Pause Panel in Intro Scene

Post by Tony Li »

Glad to help!
Post Reply