Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class Game : MonoBehaviour
- {
- //Current Dialog and display text
- public Text disTxt;
- public Dialog curDlg;
- void Start ()
- {
- updateDialog();
- }
- void Update (){
- //Gets input then sends to chooseOption.
- for (int i = 0; i < 12; i++) {
- if (Input.GetButtonDown ("b" + i)){chooseOption (i);}
- }
- }
- //Updates dialog text and options.
- void updateDialog(){
- disTxt.text = curDlg.dialogTxt + "\n\n";
- for (int opt = 0; opt < curDlg.options.Count; opt++) {
- disTxt.text += opt + 1 + ". " + curDlg.options [opt].optionTxt + "\n";
- }
- }
- //Changes active Dialog.
- void switchDialog(int i){
- if(curDlg.options.Count>i){
- curDlg = curDlg.options [i].optionDir;
- }
- }
- }
- --------------------------------------------------------------------------------------------------------------------------------------
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- [CreateAssetMenu(menuName = "txtAdv/dialog")]
- public class Dialog : ScriptableObject {
- [TextArea] public string dialogTxt;
- public List<Option> options;
- [System.Serializable]
- public class Option
- {
- public string optionTxt;/*Option description*/
- public Dialog optionDir;/*Link to the next dialog*/
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement