I keep getting this error, but I don't even know what is or isn't static in this context? I have tried solutions like setting instances and checking capitalization but I just get the same error. I want the shop script to change the monney value, which is written into debug until I set up the right U.I.
The Zoney script:
using UnityEngine; using UnityEngine.UI; public class Zoney : MonoBehaviour { public Text Money; public int Monney; private string Mony; // Start is called before the first frame update void Start() { Money = GetComponent<Text>(); } public void setMonney(int Change) { Monney = Change; } // Update is called once per frame void Update() { Mony = Monney.ToString(); Money.text = Mony; } }
The Shop script:
using UnityEngine; public class Shop : MonoBehaviour { public int Change; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { Change += 1; Zoney.setMonney(Change); Debug.Log(Change); } }
https://stackoverflow.com/questions/66073652/unity-error-error-cs0120-an-object-reference-is-required-for-the-non-static-fi February 06, 2021 at 12:46PM
没有评论:
发表评论