unity背景缓动动效

这算是一个很常见的小功能,比如我们在玩横版游戏的时候,背景动画会以一定的频率运动,其实现方式也有很多种。

比如,使用UGUI的image+animtion动画的方式,自己k桢实现。

还可以使用材质球本身的功能来实现,关键函数如下:

cs 复制代码
 public Material material;
    public float _offset;
    private int paraId;

    void Start()
    {
        material = GetComponent<Image>().material;

        paraId = Shader.PropertyToID("factor");
    }

    // Update is called once per frame
    void Update()
    {
        material.SetTextureOffset("_MainTex", new Vector2(_offset, 0));
    }

配合的材质球如下:

相关推荐
在路上看风景3 小时前
2.Square Grid
unity
程序猿阿伟3 小时前
《突破Unity热更新瓶颈:底层函数调用限制与生态适配秘籍》
unity·游戏引擎
龙智DevSecOps解决方案5 小时前
Perforce《2025游戏技术现状报告》Part 3:不同行业挑战以及Unreal、Godot、自研游戏引擎的应用趋势
游戏引擎·godot·游戏开发·perforce
在路上看风景5 小时前
13. UGUI合批
unity
jtymyxmz18 小时前
《Unity Shader》12.2调整屏幕的亮度、饱和度和对比度
unity·游戏引擎
AllBlue1 天前
unity嵌入安卓界面,如何显示状态
android·unity·游戏引擎
tealcwu1 天前
【Unity技巧】实现在Play时自动保存当前场景
java·unity·游戏引擎
tealcwu1 天前
【Unity基础】实现Scroll View跟随动态内容滚动
java·unity·游戏引擎
野奔在山外的猫1 天前
【文档】VSCode 配置 Unity 环境流程
unity
技术小甜甜1 天前
[Godot排错] 上传 Google Play Console 封闭测试时签名证书不匹配错误的解决方案
游戏引擎·godot·游戏开发