統(tǒng)一:創(chuàng)建新類實(shí)例時(shí)為NULL我陷入了非常愚蠢的境地:我正在創(chuàng)建泛型類的新實(shí)例,但它返回“怪異”NULL。 Rule rule2 = new Rule(); // initiate the class
Debug.Log(rule2); //1st debug
rule2.RuleSetup(r: "CaughtEnough", li: 0); //setting up the parameters
Debug.Log(rule2.rule); //2nd debug第一次調(diào)試給我 null
UnityEngine.Debug:Log(Object)同時(shí),設(shè)置參數(shù)工作,第二次調(diào)試給我 CaughtEnough
UnityEngine.Debug:Log(Object)它應(yīng)該在適當(dāng)?shù)念悓?shí)例中。它給我?guī)?lái)的一個(gè)(到目前為止)問(wèn)題是,如果我調(diào)用這個(gè)規(guī)則類實(shí)例 Invoke(rule, 0f);它給出了NullReferenceException錯(cuò)誤。但同時(shí)實(shí)際的功能 CaughtEnough();工作正常,就像預(yù)期的那樣。有什么想法,問(wèn)題的根源是什么,以及如何克服它?UPD還發(fā)布了規(guī)則類的安裝部分,盡管這很簡(jiǎn)單public class Rule : MonoBehaviour {public string rule;public int leftInt;public Dictionary<string, int> leftDict;public float countdown;public int outcome;public CatchManager catchMan;public Net net;// Use this for initializationvoid Start () { RuleSetup(); }public void RuleSetup(string r = "NoRule", int li = 0, Dictionary<string, int> ld = null, float cd = float.PositiveInfinity) { rule = r; leftInt = li; leftDict = ld; countdown = cd;}.....
統(tǒng)一:創(chuàng)建新類實(shí)例時(shí)為NULL
12345678_0001
2019-07-03 10:36:35