var mainTexture : Texture
Description
The main material's texture.
The same as using GetTexture or SetTexture with "_MainTex" name.
See Also: SetTexture, GetTexture.
var texture :
Texture;
renderer.material.mainTexture = texture;
using UnityEngine;
using System.Collections;
public class example :
MonoBehaviour {
public Texture texture;
void Awake() {
renderer.material.mainTexture = texture;
}
}
import UnityEngine
import System.Collections
class example(
MonoBehaviour):
public texture as
Texture def
Awake():
renderer.material.mainTexture = texture
Another example:
var textures :
Texture[];
var changeInterval :
float = 0.33;
function Update() {
if( textures.length == 0 )
return;
var index :
int =
Time.time / changeInterval;
index = index % textures.length;
renderer.material.mainTexture = textures[index];
}