Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Copyright (c) 2016-2025 Kai Clavier [kaiclavier.com] Do Not Distribute
- using UnityEngine;
- using System.Collections;
- [ExecuteInEditMode]
- [RequireComponent(typeof(SuperTextMesh))]
- public class STMPagination : MonoBehaviour {
- public SuperTextMesh originalText;
- public SuperTextMesh overflowText;
- public void Awake(){
- if(originalText == null)
- {
- originalText = GetComponent<SuperTextMesh>();
- }
- //clear on runtime
- if(overflowText != null)
- overflowText.text = "";
- }
- public void OverflowLeftovers()
- {
- if(overflowText == null) return;
- overflowText.text = originalText.leftoverText.TrimStart();
- //if there's no text, Rebuild() doesn't get called anyway
- //use TrimStart() to remove any spaces that might have carried over.
- }
- //is this implementation better? causes errors when the object isn't defined...
- //sort of a non-issue tho, an error *should* be returned if the next text field isn't defined!
- public void OverflowLeftovers(SuperTextMesh stm)
- {
- if(overflowText == null) return;
- overflowText.text = stm.leftoverText.TrimStart();
- }
- public void Reset()
- {
- originalText = GetComponent<SuperTextMesh>();
- }
- //update, just use delegate events to subscribe automatically!
- public void OnEnable()
- {
- originalText.OnCompleteEvent += OverflowLeftovers;
- }
- public void OnDisable()
- {
- originalText.OnCompleteEvent -= OverflowLeftovers;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment