查看: 1191|回复: 0
打印 上一主题 下一主题

用贴图动画实现 火的效果

[复制链接]

1602

主题

1

听众

2万

积分

资深设计师

Rank: 7Rank: 7Rank: 7

纳金币
24658
精华
6

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

跳转到指定楼层
楼主
发表于 2012-2-14 14:09:19 |只看该作者 |倒序浏览
贴图动画

一团火焰,跳动,燃烧,希望大家喜欢!
var uvAnimationTileX = 24; //Here you can place the number of columns of your sheet.

                            //The above sheet has 24

var uvAnimationTileY = 1; //Here you can place the number of rows of your sheet.

                          //The above sheet has 1

var framesPerSecond = 10.0;
function Update () {

    // Calculate index

    var index : int = Time.time * framesPerSecond;

    // repeat when exhausting all frames

    index = index % (uvAnimationTileX * uvAnimationTileY);

   

    // Size of every tile

    var size = Vector2 (1.0 / uvAnimationTileX, 1.0 / uvAnimationTileY);

   

    // split into horizontal and vertical index

    var uIndex = index % uvAnimationTileX;

    var vIndex = index / uvAnimationTileX;

    // build offset

    // v coordinate is the bottom of the image in opengl so we need to invert.

    var offset = Vector2 (uIndex * size.x, 1.0 - size.y - vIndex * size.y);

   

    renderer.material.SetTextureOffset ("_MainTex", offset);

    renderer.material.SetTextureScale ("_MainTex", size);

}



转自unity3d8.com
分享到: QQ好友和群QQ好友和群 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
转播转播0 分享淘帖0 收藏收藏0 支持支持0 反对反对0
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

关闭

站长推荐上一条 /1 下一条

手机版|纳金网 ( 闽ICP备08008928号

GMT+8, 2024-5-6 02:31 , Processed in 0.085660 second(s), 32 queries .

Powered by Discuz!-创意设计 X2.5

© 2008-2019 Narkii Inc.

回顶部