Changing Scene Problems

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
salam
Posts: 4
Joined: Wed May 29, 2019 7:46 am

Changing Scene Problems

Post by salam »

Hi, I have made a home button with: public void startGame(string scene) {

Application.LoadLevel(scene); }

Put the button on canvas under the Dialogue Manager.

When i press it, other scene is loaded but all the buttons and recent conversations from previous scene is coming too. Basically the Canvas from Dialogue Manager is showing.

I want them disappear when i change screen and reappear when i go back to that previous screen.

for example: HOME button: I want to exit the game scene in the middle of a conversation, go to home page for changing an option lets say and when i come back to the previous game scene i want it the conversation continue from the same place.

I have auto save load script on dialogue manager.

Please help me for the solution.
User avatar
Tony Li
Posts: 22056
Joined: Thu Jul 18, 2013 1:27 pm

Re: Changing Scene Problems

Post by Tony Li »

Hello,

One solution is to simply hide the dialogue panel. You could use code like this:

Code: Select all

DialogueManager.PlaySequence("SetDialoguePanel(false)");
SceneManager.LoadScene(scene); //<-- Newer version of Application.LoadLevel(scene);
After returning to the dialogue scene, use this:

Code: Select all

DialogueManager.PlaySequence("SetDialoguePanel(true)");
---

If that won't work for you for some reason, you can save the game before leaving the dialogue scene. To do this, set up the save system and add a Conversation State Saver component to the Dialogue Manager. Then use code like this:

Code: Select all

PixelCrushers.SaveSystem.SaveToSlot(0);
DialogueManager.StopConversation();
SceneManager.LoadScene(scene);
To return to the dialogue scene, don't use SceneManager.LoadScene or Application.LoadLevel. Instead, load the saved game:

Code: Select all

PixelCrushers.SaveSystem.LoadFromSlot(0);
salam
Posts: 4
Joined: Wed May 29, 2019 7:46 am

Re: Changing Scene Problems

Post by salam »

CODE: SELECT ALL

DialogueManager.PlaySequence("SetDialoguePanel(false)"); is closing perfectly the conversation but not opening again with:

DialogueManager.PlaySequence("SetDialoguePanel(true)");

what might be the problem?

I added two button on canvas as DialogOn DialogOFF >

public void DialogOn()
{
Debug.Log("dialogOn");
DialogueManager.PlaySequence("SetDialoguePanel(true)");
}
public void DialogOff()
{
Debug.Log("dialogoff");
DialogueManager.PlaySequence("SetDialoguePanel(false)");
}

DialogOff button has no problems. DialogOn button writing the Debug.Log command to console but not activating dialog box.

Saving scenes out of auto save may cause problem, confusion for coming home scene from multiple scenes , am i wrong?
User avatar
Tony Li
Posts: 22056
Joined: Thu Jul 18, 2013 1:27 pm

Re: Changing Scene Problems

Post by Tony Li »

Please make sure you're using Dialogue System version 2.1.6 or higher. (Version 2.1.6 is the current version as of this post.)

Version 2.1.6 fixed a bug in SetDialoguePanel(true).
salam
Posts: 4
Joined: Wed May 29, 2019 7:46 am

Re: Changing Scene Problems

Post by salam »

Thank you I am using save method now and working.

How can i get rid of buttons or other canvas elements of dialogue manager such as quest HUD or my custom buttons when i change screen?


Now When i go to home screen i disable buttons of dialogue screen: public void DisableButton(GameObject buton)
{
if (buton.activeSelf == true)
{
buton.SetActive(false);
}
}

However when i return to dialogue scene with
PixelCrushers.SaveSystem.LoadFromSlot(0);


There is a script attached to an empty game object in the dialogue scene:

I use this function in void Start or Void Awake


Public Gameobject homeButton; (i assign "home button" gameobject to this on script on empty game object)

void Start (){ ActivateButon(homebutton) }

void ActivateButon(GameObject buton)
{
Debug.Log("activate buton");
if (buton.activeSelf == false
)
{

buton.SetActive(true);

}
}

it writes debug.log to console but nothing else happening.

I tried this function as well to go home screen and make buttons not visible:

public void SizetoZero(GameObject buton)
{
if (buton.activeSelf == true)
{

buton.GetComponent<RectTransform>().localScale = new Vector3(0, 0, 0);
// buton.SetActive(false);


}
}

It makes butoton size 0 when i got to home scene.

again when i return to dialogue scene with
PixelCrushers.SaveSystem.LoadFromSlot(0);

void SizetoOne(GameObject buton)
{
Debug.Log("sizeeee1111");

buton.GetComponent<RectTransform>().localScale = new Vector3(1, 1, 1);
// buton.SetActive(true);

}

when i go back to dialogue screen debug.log writes but button size does NOT change to 1.

How can i get rid of buttons or other canvas elements of dialogue manager such as quest HUD or my custom buttons when i change screen?
Last edited by salam on Wed May 29, 2019 1:56 pm, edited 1 time in total.
User avatar
Tony Li
Posts: 22056
Joined: Thu Jul 18, 2013 1:27 pm

Re: Changing Scene Problems

Post by Tony Li »

Hi,

If the quest tracker HUD is the only thing that's left to hide, you can call its HideTracker() and ShowTracker() methods. For example:

Code: Select all

FindObjectOfType<StandardUIQuestTracker>().HideTracker();
If other things inside the Dialogue System's Canvas are visible and you want to hide the entire Canvas, you can write a short bit of code.

To hide the Canvas:

Code: Select all

DialogueManager.displaySettings.dialogueUI.GetComponentInParent<Canvas>().enabled = false;
To show the Canvas again:

Code: Select all

DialogueManager.displaySettings.dialogueUI.GetComponentInParent<Canvas>().enabled = true;
Post Reply