42 lines
961 B
C#
42 lines
961 B
C#
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using System.Xml.Linq;
|
||
using UnityEngine;
|
||
using UnityEngine.UIElements;
|
||
|
||
public class NPCController : MonoBehaviour
|
||
{
|
||
public static NPCController instance;
|
||
|
||
public List<RecuseNpc> npcsList = new List<RecuseNpc>();//存放每个生成的npc的脚本
|
||
public GameObject npc;//npc人物预制体
|
||
|
||
|
||
|
||
|
||
|
||
|
||
// Start is called before the first frame update
|
||
void Start()
|
||
{
|
||
instance = this;
|
||
}
|
||
|
||
public void InitNPC(Vector3 v,NpcData npcData)
|
||
{
|
||
// 使用指定的世界坐标位置来实例化 NPC,而不是依赖 trans 位置
|
||
GameObject go = GameObject.Instantiate(npc, v, Quaternion.identity); // 直接指定位置和旋转
|
||
RecuseNpc recuseNpc = go.GetComponent<RecuseNpc>();
|
||
recuseNpc.SetNPCInfo(npcData.UserId);//初始化npcid
|
||
npcsList.Add(recuseNpc);//将生成的NPC的脚本加入list存放
|
||
}
|
||
|
||
|
||
|
||
// Update is called once per frame
|
||
void Update()
|
||
{
|
||
|
||
}
|
||
}
|