LoadPrefabs.csUnity記事: 目次
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
using UnityEditor; using UnityEngine; /// <summary> /// /// Unity 2018.2.16f1 /// /// </summary> public class LoadGameObject : MonoBehaviour { // Use this for initialization private void Start() { // 1. Resourcesフォルダから読み込む GameObject prefabFromResources = Resources.Load("Prefabs/Prefab1") as GameObject; // 2. 任意のフォルダから読み込む GameObject prefabFromAssets = AssetDatabase.LoadAssetAtPath<GameObject>("Assets/Prefabs/Prefab2.prefab"); // 読み込めたかチェック Debug.Log(prefabFromResources.name); Debug.Log(prefabFromAssets.name); } } |