nameID | 属性名称 ID,使用 Shader.PropertyToID 获取。 |
name | The name of the texture property as defined in the shader. For example: "_MainTex". |
value | 纹理位置偏移。 |
Sets the placement offset of a given texture. The name
parameter is defined in the shader. This method creates a new Material instance.
另请参阅:mainTextureOffset 属性、GetTextureOffset、SetTexture。
using UnityEngine;
public class Example : MonoBehaviour { // Scroll main texture based on time
float scrollSpeed = 0.5f; Renderer rend;
void Start() { rend = GetComponent<Renderer> (); }
void Update() { float offset = Time.time * scrollSpeed; rend.material.SetTextureOffset("_TextureName", new Vector2(offset, 0)); } }