1 Resources.load 是将物体加载到内存中去, 2 Instantitate 是在Unity 中生成该物体,之后场景中就会出现该物体 示例: using UnityEngine; using System.Collections; using System.Collections.Generic; public class Choose_LoadObject : MonoBehaviour { public List<Transform> transformList; public List<string> contentList= new List<string>(); private string server; public GameObject floatingPrefab; private GameObject target; void Start () { server = "http://www.vrbeyond.com/kejian/"; PlayerPrefs.SetString("server", server); StartCoroutine(Loadobj()); target = GameObject.Find("Target"); } void Update() {} IEnumerator Loadobj() { string pathJD= server + "JD.php"; using (WWW contentText = new WWW(pathJD)) { yield return contentText; string contentString = contentText.text; string [] contentStringArray= contentString.Split('\n'); for(int i = 0; i < contentStringArray.Length; i++) { if (i == 0) { continue; } if (i == 2) { break; } string[] contentItemStringArray= contentStringArray[i].Split('$'); GameObject go= Instantiate<GameObject>(floatingPrefab); go.name = contentItemStringArray[0]; // 节点 go.transform.Find("nameSprite/nametext").GetComponent<TextMesh>().text = contentItemStringArray[1]; //名字 go.transform.position = transformList[i].position; string prefabPath = "Hourse" + "/" + contentItemStringArray[0] + "/" + contentItemStringArray[0] + "_GJJG_Hand"; GameObject modle= Resources.Load<GameObject>(prefabPath); GameObject modleGo = Instantiate<GameObject>(modle); modleGo.transform.SetParent(go.transform); modleGo.transform.localScale = new Vector3(0.12f, 0.12f, 0.12f); modleGo.transform.localPosition = new Vector3(0f, 0f, 0.5825443f); modleGo.transform.Find("_标注").gameObject.SetActive(false); modleGo.transform.Find("跟踪物体").gameObject.SetActive(false); string spritePath = "Hourse" + "/" + contentItemStringArray[0] + "/" + contentItemStringArray[0] + "_sprite"; Sprite s = Resources.Load<Sprite>(spritePath); go.transform.Find("nameSprite").GetComponent<SpriteRenderer>().sprite = s; } } } }