Advertisement
Guest User

Untitled

a guest
Apr 26th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.08 KB | None | 0 0
  1.        // Data.
  2.         public Dictionary<string, Tx> Texts = new Dictionary<string, Tx>();
  3.         public class Tx
  4.         {
  5.             public object updater; // What function to call for updated information.
  6.         }
  7.        
  8.         //creates a new dictionary entry + what to call for updated information, like the score.
  9.         public void TextAdd(object updater)
  10.         {
  11.             Texts.Add("Score", new Tx());
  12.             Texts[i].updater = updater;
  13.         }
  14.  
  15.         // The updated score number.
  16.         public int Update_Score()
  17.         {
  18.             return 0; // <--- returns some score number.
  19.         }
  20.  
  21.         // Simply calls each entry in the dictionary and runs/calls the updater function (from variable), if present.
  22.         private void update()
  23.         {
  24.             foreach (KeyValuePair<string, Tx> i in new Dictionary<string, Tx>(Texts))
  25.             {
  26.                 Texts[i.Key].text.text = Texts[i.Key].updater.ToString();
  27.             }
  28.          }
  29.  
  30.         // Calls TextAdd() to add a new entry for the score.
  31.         private void Start()
  32.         {
  33.             TextAdd(Update_Score());
  34.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement