- Home /
Add dynamically texture to 3D Object
Hi
I have a folder in c:/Img/ with some images and i want to make them dynamically textures form my 3D Object. I have this code
using UnityEngine;
using System.Collections;
using System.IO;
public class ListImgs : MonoBehaviour {
public Texture2D textureIs;
GameObject MyCube;
void Awake () {
MyCube = GameObject.Find ("Cube2");
string image = "c:/Img/a.jpg";
void Start () {
textureIs = Resources.Load (image, typeof(Texture2D)) as Texture2D;
MyCube.renderer.material.mainTexture = textureIs;
}
}
And does not work for me. It gives an empty cube.
What is the problem
Comment
Best Answer
Answer by AlwaysSunny · Aug 31, 2014 at 05:46 PM
Resources.Load only works on assets within the project's Assets folder.
This thread has two examples of loading from outside your project's assets.