【转】【UNITY3D 游戏开发之四】有关实现2D帧序列帧播放相关—ANIMATING TILEDTEXTURE

简介:
本站文章均为  李华明Himi 原创,转载务必在明显处注明: 
转载自【黑米GameDev街区】 原文链接:  http://www.himigame.com/unity3d-game/1592.html

 

Himi 尝试使用了此作者《CSharp – SpritSheet.cs》代码段,发现其中有一个算法估计是作者大意写错了。这样改了就矩形也都支持了。

 

Author: Joachim Ante

Contents

 [hide

Description

This script animates a texture containing tiles of an animation. You can give it a framerate to determine the speed of the animation and set how many tiles on x, y there are.

Usage

Attach this script to the object that has a material with the tiled texture. To avoid distortion, the proportions of the object must be the same as the proportions of each tile (eg 1:2 for the sheet below).

Here is an example of how to lay out a texture for it (Thanks to BigBrainz for providing it):Torchanimation 135.png

(Leo Nogueira) Adding a simple image with multiple rows for testing purposes and a modified version of the C# Script:

TilesTestPNG.png

JavaScript – AnimatedTextureUV.js

CSharp – SpritSheet.cs

This is just a CSharp version of the AnimatedTextureUV.js above.

CSharp – SpritSheetNG.cs

The CSharp version of the script was not working with multiple rows so i made some changes.

CSharp – AnimateTiledTexture

A version using coroutines. Slightly faster since it doesn’t update every frame and only sets the texture scale once.

相关文章
|
4月前
|
vr&ar 开发工具 图形学
Unity引擎:收费模式和服务升级,为游戏开发带来更多可能性
Unity引擎:收费模式和服务升级,为游戏开发带来更多可能性
|
5月前
|
C# 图形学
【Unity】2D游戏-愤怒的小鸟教学实战(附源码和实现步骤 超详细)
【Unity】2D游戏-愤怒的小鸟教学实战(附源码和实现步骤 超详细)
194 1
|
7月前
|
vr&ar 开发工具 图形学
Unity引擎:收费模式和服务升级,为游戏开发带来更多可能性
Unity引擎:收费模式和服务升级,为游戏开发带来更多可能性
|
11月前
|
存储 图形学 Android开发
【游戏开发】使用unity创建2D游戏
Unity是一种非常强大的游戏引擎,可以帮助你创建各种类型的游戏,包括2D游戏。在本文中,我们将教你如何使用Unity创建2D游戏。首先,你需要确保你已经下载并安装了最新版本的Unity。如果你还没有安装Unity,可以从官方网站下载免费的Unity Hub来管理你的Unity版本。
393 0
|
11月前
|
图形学
【游戏开发】unity透明特效的制作方法
Unity是一种强大的游戏开发引擎,它支持许多不同的特效和图形效果。其中一种常用的特效是透明特效,它可以使游戏中的材质变得半透明或完全透明。在本文中,我们将介绍如何使用Unity创建透明特效。
528 0
|
11月前
|
JavaScript 前端开发 vr&ar
【游戏开发】unity入门教程
Unity是一款非常受欢迎的游戏引擎,它可以用于开发2D和3D游戏以及虚拟现实和增强现实应用程序。如果你是一个刚开始接触Unity的开发者,这篇教程将为你提供一些有用的指导。
226 0
|
11月前
|
前端开发 定位技术 图形学
【Ruby 2D】【unity learn】抬头显示血条
【Ruby 2D】【unity learn】抬头显示血条
|
11月前
|
机器人 图形学 Ruby
【unity learn】【Ruby 2D】角色发射飞弹
【unity learn】【Ruby 2D】角色发射飞弹
|
11月前
|
机器人 图形学 Ruby
【Ruby 2D】【unity learn】控制敌人随机运动以及动画控制
【Ruby 2D】【unity learn】控制敌人随机运动以及动画控制
|
图形学 Windows
Unity报错之 No Sprite Editor Window registered. Please download 2D Sprite package from Package Manager
Unity2019操作对图集进行操作编辑出错:No Sprite Editor Window registered. Please download 2D Sprite package from Package Manager.
1056 0
Unity报错之 No Sprite Editor Window registered. Please download 2D Sprite package from Package Manager