using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Test : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
public float scrollSpeed = 0.5f;
// Update is called once per frame
void Update()
{
float offset = Time.time * scrollSpeed;
gameObject.GetComponent<MeshRenderer>().sharedMaterial.SetTextureOffset("_MainTex", new Vector2(0, offset));
}
}


该C#脚本在Unity环境中用于一个游戏对象的MeshRenderer组件,设置了随着游戏时间以特定速度(_scrollSpeed)平移纹理的Offset。在Update函数中,每帧更新一次,通过SetTextureOffset方法改变_MainTex纹理坐标,实现纹理的动态滚动效果。
501

被折叠的 条评论
为什么被折叠?



