daily pastebin goal
63%
SHARE
TWEET

Untitled

a guest Jan 22nd, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using TMPro;
  4. using UnityEngine;
  5. using UnityEngine.UI;
  6.  
  7.  
  8. public class GameManager : MonoBehaviour
  9. {
  10.  
  11.     public GameObject DialogueObject;
  12.     public TextMeshProUGUI characterNameText;
  13.     public TextMeshProUGUI dialogText;
  14.     public System.Action dialogOnFinishAction;
  15.  
  16.     private void Awake()
  17.     {
  18.         ShowDialog("some text", "some text", null);
  19.     }
  20.  
  21.     public void ShowDialog(string CharacterName, string Text, System.Action onFinish)
  22.     {
  23.  
  24.         characterNameText.text = CharacterName;
  25.         dialogText.text = Text;
  26.         onFinish = dialogOnFinishAction;
  27.  
  28.         DialogueObject.SetActive(true);
  29.     }
  30.  
  31.     // Start is called before the first frame update
  32.     void Start()
  33.     {
  34.         DialogueObject.SetActive(false);
  35.     }
  36.  
  37.     // Update is called once per frame
  38.     void Update()
  39.     {
  40.        if ((Input.GetKeyDown(KeyCode.KeypadEnter)))
  41.         {
  42.           if(dialogOnFinishAction != null)
  43.             {
  44.                 return;
  45.             }
  46.           else{
  47.                 System.Action action = dialogOnFinishAction;
  48.                 dialogText = null;
  49.                 action();
  50.             }
  51.         }
  52.  
  53.     }
  54. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top