Using variables without overflow
I have a 2 scripts test.cs and test2.cs. I want it test2 to access test, and it works, but i don't want to make a new variable every function. Maybe the code will tell more :D
Current Code (works):
using MrRockis.Test;
namespace MrRockis.Test.Actions
{
public class test2 : MonoBehaviour
{
public void Test()
{
promo = new Test();
Debug.Log (promo.statusText.text);
}
}
}
But i don't want to type "promo = new Test(); inside every function! This code gives stack overflow error:
using MrRockis.Test;
namespace MrRockis.Test.Actions
{
public class test2 : MonoBehaviour
{
private Test promo = new Test(); //This row gives me the error
public void Test()
{
Debug.Log (promo.statusText.text);
}
}
}
How could i do this without putting "promo = new Test();" inside every function?
Comment
Your answer
Follow this Question
Related Questions
Method Group 1 Answer
Easy question: X axis overriding Y. Please help! :D 0 Answers