Common error, googled but can’t find an answer that works
using UnityEngine;
using System.Collections;
public class ImageFromAssets : MonoBehaviour {
void Start (){
// Use this for initialization
var go = new GameObject.CreatePrimitive(PrimitiveType.Plane);
var rend = go.GetComponent.<Renderer>();
rend.material.mainTexture = Resources.Load("cube_0") as Texture;
}
// Update is called once per frame
void Update () {
}
}
I don’t know anything about C# or C++, but maybe this might work,
var mytextures : Texture2D[];
var which : int = 0;
function Start(){
var go = new GameObject.CreatePrimitive(PrimitiveType.Plane);
var rend = go.GetComponent(Renderer);
rend.material.mainTexture = mytextures[which];
}
It’s in Java however, but it will create a Plain with the specified texture in your array