【发布时间】:2016-12-22 21:37:00
【问题描述】:
不知道出了什么问题。将一些代码外包到另一个类中会出现问题。如果以下代码在同一个类中,则可以正常工作。
SearchClient.cs
void callExposeAPi (string id)
{
ExposeClient exposeClient = (new GameObject("ExposeClient")).AddComponent<ExposeClient>();
exposeClient.loadExpose(id);
}
ExposeClient.cs
public Text _baserentText; // is attached to Text in Unity
public void loadExpose(string id)
{
[some API stuff...]
Debug.Log(result.exposeexpose.realEstate.baseRent); // 480
makeUseOfExposeUI(result.exposeexpose.realEstate);
}
void makeUseOfExposeUI (Realestate realestate)
{
Debug.Log(realestate.baseRent); // 480
_baserentText.text = realestate.baseRent.ToString();
}
【问题讨论】:
标签: c# unity3d gameobject