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

How do I call a variable from another script? (C#)

$
0
0
Hi, I'm trying to call a variable from another script, this variable is inside of a namespace., so I'm having trouble to archieve this. THE SCRIPT TRYING TO ACCESS THE VARIABLE: using System; using UnityEngine; [RequireComponent(typeof(UnityFunction.Class_One))] public class Class_Two : MonoBehaviour { private UnityFunction.Class_One the_other_var; public string the_string; void Start() { the_other_var = GetComponent (); } void Update() { the_string = the_other_var.the_var; } } THE SCRIPT WITH THE VARIABLE: using System; using UnityEngine; namespace UnityFunction { public class Class_One : MonoBehaviour { public string the_var; void Start() { the_var = "Hi"; } } }

Viewing all articles
Browse latest Browse all 398


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