脚本对象在主机中初始化,在客户端中为null。为什么?

时间:2018-08-11 17:59:14

标签: unity3d

到目前为止,我一直在调试我的代码以在Unity2D上联网。到目前为止,当我尝试初始化不是 SyncVar的生成对象中的字段时,根据Log命令,传递给该字段的对象显示为空。

public void InitiateManagers(GameManager game_manager, BoardManager board_manager)
{
    this.game_manager = game_manager;
    this.board_manager = board_manager;

    Debug.Log(board_manager); //prints null when client runs in editor, wheras prints "BoardManager" if the host runs on the editor

    board_manager.RegisterBuilding(this.gameObject); // error occurs here because board_manager is null in client
}

谁能解释为什么Unity似乎只能一次 检索对象?

0 个答案:

没有答案