0
我有一堂課,我想讓serializable
(查看檢查器中的一些公共變量),但我也需要在該課程中使用Coroutines
。要在我的課程中使用Coroutines
,我必須從MonoBehaviour繼承它。但是,我不能使用serializable
類的功能。帶有協程的可序列化類?
public class Act1HomeAwake : MonoBehaviour
{
public Act1_1HomeAwake act1_1HomeAwake;
public void StartAct1(int subActNumber)
{
switch(subActNumber)
{
case 1: act1_1HomeAwake.StartSubAct1_1(); break;
}
}
}
[System.Serializable]
public class Act1_1HomeAwake // : MonoBehaviour
{
// don't see this 2 variables in the inspector WITH inheriting from MonoBehaviour
public OpenCloseAnimation openCloseEyesScript;
public Text textTipsTasksComponent;
// WITHOUT inheriting from MonoBehaviour compiler don't understand this construction
StartCoroutine("OpenCloseEyesAnimation");
}
您的代碼無效C#?你正嘗試從任何類成員之外調用一個方法。 –