A game about forced loneliness, made by TACStudios
1using System.Collections; 2using System.Collections.Generic; 3using UnityEngine; 4using TMPro; 5 6[ExecuteInEditMode] 7public class GetSampleInfos : MonoBehaviour 8{ 9 public enum Type 10 { 11 Introduction, 12 Title, 13 Description 14 } 15 16 public Type type; 17 public GameObject prefab; 18 19 private TextMeshPro TextMeshProComponent = null; 20 21 // Start is called before the first frame update 22 IEnumerator Start() 23 { 24 yield return new WaitForSeconds(0); 25 UpdateText(); 26 } 27 28 void UpdateTextMeshProReference() 29 { 30 TextMeshProComponent = this.GetComponent<TextMeshPro>(); 31 if(TextMeshProComponent == null) 32 Debug.LogError($"TextMeshPro Component cannot be found on this GameObject: {this.gameObject.name}"); 33 } 34 35 // Called when something has changed in the script 36 void OnValidate() 37 { 38 UpdateText(); 39 } 40 41 void UpdateText() 42 { 43 if(TextMeshProComponent == null) 44 UpdateTextMeshProReference(); 45 46 switch(type) 47 { 48 case Type.Introduction: 49 TextMeshProComponent.text = SamplesShowcase.GetSanitizedIntroduction(); 50 break; 51 case Type.Title: 52 TextMeshProComponent.text = SamplesShowcase.GetSanitizedTitle(prefab.name); 53 break; 54 case Type.Description: 55 TextMeshProComponent.text = SamplesShowcase.GetSanitizedDescription(prefab.name); 56 break; 57 } 58 } 59 60}