Material.SetTextureOffset 设置纹理偏移

function SetTextureOffset (propertyName : string, offset : Vector2) : void


Sets the placement offset of texture propertyName.


Common texture names used by Unity's builtin shaders:

"_MainTex" is the main diffuse texture .This can also be accessed via mainTextureOffset property.
"_MainTex"是主要的漫反射纹理,也能通过 mainTextureOffset 属性访问

"_BumpMap" is the normal map.

"_Cube" is the reflection cubemap.

参见: mainTextureOffset 属性, GetTextureOffset .

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	public float scrollSpeed = 0.5F;
	void Update() {
		float offset = Time.time * scrollSpeed;
		renderer.material.SetTextureOffset("_MainTex", new Vector2(offset, 0));
// Scroll main texture based on time

var scrollSpeed : float = 0.5;

function Update () {
	var offset : float = Time.time * scrollSpeed;
	renderer.material.SetTextureOffset ("_MainTex", Vector2 (offset,0));
Page last updated: 2011-1-22