Quantcast
Channel: Questions in topic: "namespace"
Viewing all articles
Browse latest Browse all 398

Using variables without overflow

$
0
0
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?

Viewing all articles
Browse latest Browse all 398

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>