- Home /
How do I bring variables from two scripts to one then have them print on a canvas text?
I'm trying to bring some strings and integers from two scripts to one. Once they have been transferred I want them to be printed on a canvas. The first script contains these lines.
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class ThalassioLifetimeVarScript : MonoBehaviour {
public float ThalassioLifeTimeVar = 600f;
public float DeathSpeedVar = .5f;
// Update is called once per frame
void Update () {
//LIVING DEAD STUFF
if (ThalassioLifeTimeVar < 0) {
Debug.Log ("Dead");
}
else if (ThalassioLifeTimeVar > 0)
{
Debug.Log ("Living");
}
//LIFESPAN COUNTER
ThalassioLifeTimeVar -= DeathSpeedVar * Time.deltaTime;
Debug.Log ("Life left " + (System.Math.Round(ThalassioLifeTimeVar,1)));
}
}
I wish to take out the LifeTime variable and have it printed in the text of the UI, once its there I want it to update.
This is the next views variables, they are all strings.
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class ThalassioInfoStringsScript : MonoBehaviour {
public string ThalassioCreature = "Thalassio";
public string ThalassioFood = "Autotrophic";
public string ThalassioClass = "Phytoplankton";
}
I wish to get all of these scripts to one script and have them put onto a canvas text. Please help, comment if something is not clear
Your answer

Follow this Question
Related Questions
Canvas UI Priority layers 1 Answer
Displaying variable on UI text every frame (JS) 1 Answer
Transfering Variables Between Sections [SOLVED] 2 Answers
Save what you write in textarea as variable? 1 Answer
Canvas text's font problem 1 Answer