/// <summary> /// 创建Npc. /// </summary> public void SpawnNpc(int indexVal) { GameObject obj = null; NpcController npcScript = null; NpcController.NpcEnum npcState = (NpcController.NpcEnum)indexVal; if (Network.peerType == NetworkPeerType.Disconnected) { obj = (GameObject)Instantiate(mNpcPrefab, SpawnPointArray[indexVal].position, SpawnPointArray[indexVal].rotation); NetworkView netView = obj.GetComponent <NetworkView>(); netView.enabled = false; } else { obj = (GameObject)Network.Instantiate(mNpcPrefab, SpawnPointArray[indexVal].position, SpawnPointArray[indexVal].rotation, 0); } npcScript = obj.GetComponent <NpcController>(); npcScript.SetIsNetControlPort(true); npcScript.SetNpcState(npcState); npcScript.SetNpcIndex(indexVal); }