Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Copyright (c) 2019 Kai Clavier [kaiclavier.com] Do Not Distribute
- using UnityEngine;
- using System.Collections;
- using Fleece;
- public class STMDrawstring : MonoBehaviour {
- private Drawstring drawstring = new Drawstring(); //used for managing dialogue trees
- public Jumper startPassageRef; //works as a reference to the starting passage
- public SuperTextMesh stm;
- //subscribe and unsubscrbe to STM's OnCompleteEvent
- void OnEnable()
- {
- stm.OnCompleteEvent += TextIsDoneReading;
- }
- void OnDisable()
- {
- stm.OnCompleteEvent -= TextIsDoneReading;
- }
- public void TextIsDoneReading()
- {
- if(drawstring.passage != null)
- {
- //This can be used to invoke...
- //drawstring.GetChoices()
- //when STM is done reading!
- Debug.Log(drawstring.GetChoices().Length);
- }
- }
- [ContextMenu("Begin")]
- public void Begin()
- {
- //start at default passage
- Begin(startPassageRef.passage);
- }
- public void Begin(Passage passage)
- {
- //start at specified passage
- stm.text = drawstring.Begin(passage);
- }
- [ContextMenu("Continue")]
- public void Continue()
- {
- stm.text = drawstring.Continue(); //
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement