【Unity3D自学记录】Resources加载

创建一个文件夹命名为Resources,将预设好的场景拖入

例如Resources中有 A ,B两个预设

创建一个脚本

using UnityEngine;
using System.Collections;

public class ResourcesLoadObj : MonoBehaviour
{

    bool ol = false;

    private string[] roadName = new string[] { "A", "B" };
    void Start()
    {
        for (int i = 0; i < roadName.Length; i++)
        {
            GameObject obj = Resources.Load(roadName[i]) as GameObject;
            Instantiate(obj);
        }
    }
}


你可能感兴趣的:(unity3d)