Page 1 of 1
Suppress Pause Panel in Intro Scene
Posted: Wed Oct 23, 2024 2:48 am
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.
Re: Suppress Pause Panel in Intro Scene
Posted: Wed Oct 23, 2024 8:25 am
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; }
}
Re: Suppress Pause Panel in Intro Scene
Posted: Wed Oct 23, 2024 2:36 pm
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.
Re: Suppress Pause Panel in Intro Scene
Posted: Wed Oct 23, 2024 3:06 pm
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); }
}
Re: Suppress Pause Panel in Intro Scene
Posted: Wed Oct 23, 2024 5:41 pm
by Arctichorse9
Thank you. I will try that. It’s really only important on mobile.
Re: Suppress Pause Panel in Intro Scene
Posted: Wed Oct 23, 2024 7:31 pm
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!!!!!!
Re: Suppress Pause Panel in Intro Scene
Posted: Wed Oct 23, 2024 8:10 pm
by Tony Li
Glad to help!