LoginSignup
2

More than 5 years have passed since last update.

複数の画像をResourcesフォルダから読み込んで表示する

Last updated at Posted at 2014-09-28

ローカルから画像を読み込んで表示する方法を記載しました。
特に難しい事ではないですけども(汗)

スクリーンショット 2014-09-28 21.12.56.png


using UnityEngine;
using System.Collections;

public class ResourcesTextureLoaders : MonoBehaviour {

    public GameObject _prefab;
    public Material _material;
    GameObject[,,] _instance = new GameObject[2,2, 3];

    private int num = 0;

    void Start ()
    {
        for (int z=0; z<2; z++)
        {
            for (int j = 0; j < 2; j++)
            {
                for (int i = 0; i < 3; i++)
                {
                    num += 1;

                    _instance [z,j, i] = Instantiate(Resources.Load("LoadPrefab")) as GameObject;
                    _instance [z,j, i].renderer.material.mainTexture = Resources.Load("p" + num) as Texture2D;
                    _instance [z,j, i].transform.localPosition = new Vector3(i * 80 - 80, j * 80 - 40f, z*80);
                    _instance [z,j, i].transform.rotation = Quaternion.Euler(90, 180, 0);
                    _instance [z,j, i].transform.localScale = new Vector3(5, 5, 7);
                }
            }  
        }
    }   
}

※位置や回転やスケールは適当な感じで合わせる為に入れています。

Assets>Resourceフォルダから画像を読み込んでます。

スクリーンショット 2014-09-28 21.14.45.png

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2