I want to have a score board on a separate scene than the conversation. How do I reference the those conversation variables from a separate scene?
Also, I was wondering which guide would be best for learning how to create my own UI or GUI mainly for bringing in my own assets?
Exterior Score element
Re: Exterior Score element
I suggest using the Dialogue System's Lua environment. Store the score in a variable. In your other scene, call DialogueLua.GetVariable() in a script to get the variable's value. For example:malt wrote:I want to have a score board on a separate scene than the conversation. How do I reference the those conversation variables from a separate scene?
1. In your dialogue database, on the Variables tab, create a new variable named Score. Set the Type to Number.
2. Update the variable however you want -- for example, using the Dialogue System's PlayMaker Set Variable action, or DialogueLua.SetVariable() in script. Or say you want to add 10 to the score in a conversation. In a dialogue entry's Script field, use:
Code: Select all
Variable["Score"] = Variable["Score"] + 10
Code: Select all
UnityEngine.UI.Text scoreLabel; // Reference to your score UI element.
void Start() {
scoreLabel.text = DialogueLua.GetVariable("Score").AsInt;
}
The Dialogue System supports many GUI systems. I prefer using Unity UI. It takes a little time to learn, but Unity provides good tutorials.malt wrote:Also, I was wondering which guide would be best for learning how to create my own UI or GUI mainly for bringing in my own assets?
You could take one of two approaches:
1. Drop the Generic Bundled UI into your scene as a child of the Dialogue Manager GameObject. This will immediately give you a working UI. You can then rearrange the layout and change the textures to your liking. This is how I make custom UIs these days.
2. Alternatively, lay out your UI elements first. Then add a Unity UI Dialogue UI component and hook it up as described in this video tutorial.
Re: Exterior Score element
I can see how I would be able to use this:
My question may come from a lack of understanding, but would I need any type of save system like I've seen in tutorials to do this:
1.From my level select scene a UI button is pressed that loads that respective level which is a conversation
2.The conversation is triggered OnStart of that scene
3.The win of a conversation is a condition that is dependent on a score variable which each response has.(If that doesn't make sense here is a link to my hidden values system thread: viewtopic.php?f=3&t=295)
4.The conversation ends with the player either winning or losing where the last player dialogue selection updates a wins variable on specific player response
5.A game object is set as active that gives the player information if they win or lose this object has a child ui button that goes back to the level select scene onClick.
6.If he/she wins the conversation a text field is updated and this would continue for every single level.
7. The level button that was pressed is now grayed out and cannot be selected again.
I may be able to use a loop in the start or update method IF what I think happens doesn't actually happen, but I'm sure you have a better idea than I do. I assume an old scene is destroyed after a new scene is loaded to conserve memory. So, if it does happen do you have any idea what I could do to update a variable so that each time a win is reached in conversation is met in a conversation.
It seems that a single database will share variables, so would a different conversation change those values? Because I'm looking to have my score reset at the start of each conversation and my wins to carry over in order to update that variable correctly.
Also, I can't thank you enough for your help. If there is anything I can do!!! I brag on your product in my game dev class, and will leave a great review in the assets store, but you guys have been saviors!!!
Code: Select all
void Start() {
UnityEngine.UI.Text scoreLabel; // Reference to your score UI element.
scoreLabel.text = DialogueLua.GetVariable("Score").AsInt;
}
1.From my level select scene a UI button is pressed that loads that respective level which is a conversation
2.The conversation is triggered OnStart of that scene
3.The win of a conversation is a condition that is dependent on a score variable which each response has.(If that doesn't make sense here is a link to my hidden values system thread: viewtopic.php?f=3&t=295)
4.The conversation ends with the player either winning or losing where the last player dialogue selection updates a wins variable on specific player response
5.A game object is set as active that gives the player information if they win or lose this object has a child ui button that goes back to the level select scene onClick.
6.If he/she wins the conversation a text field is updated and this would continue for every single level.
7. The level button that was pressed is now grayed out and cannot be selected again.
I may be able to use a loop in the start or update method IF what I think happens doesn't actually happen, but I'm sure you have a better idea than I do. I assume an old scene is destroyed after a new scene is loaded to conserve memory. So, if it does happen do you have any idea what I could do to update a variable so that each time a win is reached in conversation is met in a conversation.
It seems that a single database will share variables, so would a different conversation change those values? Because I'm looking to have my score reset at the start of each conversation and my wins to carry over in order to update that variable correctly.
Also, I can't thank you enough for your help. If there is anything I can do!!! I brag on your product in my game dev class, and will leave a great review in the assets store, but you guys have been saviors!!!
Re: Exterior Score element
Hi,
Thanks for the kind words about the Dialogue System!
If you put the Dialogue Manager GameObject in your level select scene, it will carry through to other scenes. This includes its variable values. Other GameObjects in the level select scene will be destroyed by default when changing scenes.
Thanks for the kind words about the Dialogue System!
If you put the Dialogue Manager GameObject in your level select scene, it will carry through to other scenes. This includes its variable values. Other GameObjects in the level select scene will be destroyed by default when changing scenes.
- In your dialogue database, define a variable named "Wins". Set its Type to Number and its Value to 0.
- In your level select scene, add a script like in my previous post, except use the variable "Wins":
Code: Select all
DialogueLua.GetVariable("Wins").AsInt;
- In the START node of your conversations, reset Score to zero by setting the Script field to:
Code: Select all
Variable["Score"] = 0;
- Define variables that match your level names, such as "Level1", "Level2", etc. Set their Type to Boolean and Value to False.
- In the START node of your conversations, use the Script field to set the variable true. For example, in the Level2 conversation:
Code: Select all
Variable["Level2"] = true;
- In the level select scene, check the variable values. For example, add this script to each level button:
Code: Select all
using UnityEngine; using PixelCrushers.DialogueSystem; public class LevelButton : MonoBehaviour { public string levelName; //<-- Set to "Level1", etc. public void Start() { // Disables the button if we've already visited the level. var button = GetComponent<UnityEngine.UI.Button>(); if (button != null) button.interactable = !DialogueLua.GetVariable(levelName).AsBool; } public void OnClick() { //<-- Assign this to the button's OnClick event. Application.LoadLevel(levelName); } }