itween event脚本名称怎么设置

unity动画插件Hotween的使用 – unity3d游戏开发
Hotween与itween类似,也是一个插值插件,都是对位移,缩放,旋转,颜色等数值进行插值,各有各的优势。如果做一般常见的动画建议使用Hotween,但是遗憾的是Hotween不支持路径动画,如果支持就完美了。
官方网站:
根据Hotween官方网站介绍,hotween是运行快,类型安全和面向对象的unity插件,兼容unity所有的脚本语言,并且在官方网站上有和unity对比的demo(),一般情况下两者性能上的对比不是太明显,但是当游戏对象多的时候hotween的优势就显现出来了. 这也是我选择hotween的原因,下面介绍hotween在unity中的使用.
首先去下载hotween插件,然后把hotween解压到Assets/Plugins目录下(Plugins文件夹需要自己创建),节点结构大致是这样子的;
开始编写代码使用.
首先要在类前面引用hotween的命名空间
using UnityE
using System.C
using Holoville.HOT
public class HotweenTest : MonoBehaviour {
&&&&void Start () {
二、Hotween的基本使用方法
ok,引入完毕,然后在第一个例子中我会使用Transform对象,但是要记住一点的是hotween只能对物体的任何非静态的公有属性或者字段做动画.
HOTween.To(gameObject.transform, 1,
&position&, new Vector3(10,20,30));
当然大多数情况下,我们做插值动画这些参数控制是远远不够的,那就需要添加更多的控制参数,
HOTween.To(transform,2,new TweenParms().Prop(&position&,new Vector3(10,20,30)).Prop(&rotation&,new Vector3(0,720,0)).Prop(&localScale&,new Vector3(10,10,10)).Ease(EaseType.EaseInBack).Loops(3,LoopType.Yoyo).Delay(1));
代码看起来很长,不是很好理解,那我们换一种方式:
TweenParms parms = new TweenParms();
parms.Prop(&position&, new Vector3(10,20,30));
parms.Prop(&rotation&, new Vector3(0,720,0));
parms.Prop(&localScale&, new Vector3(10,10,10));
parms.Ease(EaseType.EaseInBack);
parms.Loops(3,LoopType.Yoyo);
parms.Delay(1);
HOTween.To(myGameObject.transform, 2, parms );
这两种写法的动画效果是一模一样的,其中loops方法我觉得是做的比较好的,可以设置循环次数,itween是没有的
三、HOTween Sequence 动画队列
有时候我们需要播放一系列的动画,比如说:移动到远点–&旋转180–&放大2倍。。。
这时候就可以考虑使用hotween的队列动画.
Sequence&mySequence = new Sequence(new
SequenceParms().Loops(3,LoopType.Yoyo));
mySequence.Append(HOTween.To(myGameObject1.transform, 1, new TweenParms().Prop(&position&, new Vector3(0,0,0)).Ease(EaseType.EaseOutBounce)));
mySequence.Prepend(HOTween.To(myGameObject2.transform, 1, new TweenParms().Prop(&position&, new Vector3(10,20,30)).Prop(&rotation&, new Vector3(0,720,0)).Prop(&localScale&, new Vector3(4,4,4)).Ease(EaseType.EaseInElastic)));
mySequence.Insert(1, HOTween.To(myGameObject3.transform, 1, new TweenParms().Prop(&position&, new Vector3(10,20,30)).Prop(&rotation&, new Vector3(0,720,0)).Prop(&localScale&, new Vector3(4,4,4)).Ease(EaseType.EaseOutQuad)));
mySequence.play();
mySequence.PlayForward();
mySequence.PlayBackwards();
四、回调函数 Call back 不带参数的回调可以这样写:
HOTween.To(transform, 1, new TweenParms().Prop(&position&, new Vector3(10,20,30)).OnComplete(completeCallBack()));
private void completeCallBack() {
需要带一个或者多个参数的回调函数:
HOTween.To(transform, 1, new TweenParms().Prop(&position&, new Vector3(10,20,30)).OnComplete(completeCallBack,350,Vector3.one));
private void completeCallBack(TweenEvent e) {
&&Debug.Log(e.parms[0]);
&&Debug.Log(e.parms[1]);
&&Debug.Log(e.tween);
五、以speed为计量单位 一般我们使用Hotween开始一个动画,第二个参数是p_duration表示是时长,好想也没有找到如何根据速度来控制动画。 最近必须要用到speed,就找了一下,发现可以这样用:
TweenParms parms = new TweenParms();
parms.Prop(&position&,new Vector3(100,200,50));
parms.SpeedBased(true);
HOTween.To(FurnacePanel,5,parms);
当在代码中设置SpeedBased为true之后,第二个参数就以速度来表示了,值越大自然运动的越快
本分类共有文章33篇,更多信息详见
& 2012 - 2014 &
&All Rights Reserved. &
/*爱悠闲图+*/
var cpro_id = "u1888441";
/*爱悠闲底部960*75*/
var cpro_id = "u1888128";查看: 6897|回复: 8
最后登录注册时间阅读权限20积分358
设计实习生, 积分 358, 距离下一级还需 142 积分
纳金币300 精华0
上一节我们讲了iTween路径动画的制作过程。这一节我们看下怎么动态调用它,和创建多个路径的方法,动态切换的方法。& &首先打开上次做的项目,选择player物体,在Inspector视图中讲iTween Event下的play Automatically的选框勾掉。因为我们要动态控制动画的播放,不需要它运行时就播放了。这些做完之后就开始写代码了,创建一个C#脚本,命名为Animation control,并写入一下代码:public class Animationcontrol : MonoBehaviour {& && && &public GameO//带路径动画的物体& && && &void OnGUI()& && && &{& && && && && && & if (GUI.Button(new Rect(10, 70, 50, 30), &play&))& && && && && && & {& && && && & //播放路径动画& && && && && && && && && & iTweenEvent.GetEvent(player,&firstevent&).Play();& && && && && && & }& && && && && && & if (GUI.Button(new Rect(100, 70, 50, 30), &stop&))& && && && && && & {& && && && && &//停止路径动画& && && && && && && && && & iTweenEvent.GetEvent(player,&firstevent&).Stop();& && && && && && & }& && && &}}分析上面的脚本。我们用iTweenEvent.GetEvent(player,&firstevent&).Play();和iTweenEvent.GetEvent(player,&firstevent&).Stop();来控制动画的停止和播放,其中player为带有路径动画的物体,&firstevent&需要与路径动画的名称保持一致。就是Inspector视图中讲iTween Event下的Name的值脚本完成后,讲脚本添加到我们的摄像机上。将player拖放到变量player运行游戏,点击play按钮动画开始运行,点击stop按钮,动画停止运行。下面我们来看下怎么给一个物体添加多段路径,及切换。选中我们path物体,在给他添加一个ITweenPath。如图:给path name命名为second pathParhColor最好与第一个颜色分开的颜色分开Node Count改为5。然后设置关键点。制作完成后。在Scene中就出现了两条路径 选择player物体。在给他添加一个。ITween Event设置如下:勾选path并选择secnd path,勾选time设置时间为20.勾选easetype选择linear设置匀速运动。如图:这样我们就给物体player添加了两段路径动画,下面我们就用代码来控制这两段动画代码如下: public class Animationcontrol : MonoBehaviour {& && && &public GameO//带有动画的物体& && && &void OnGUI()& && && &{& && && && && && & if (GUI.Button(new Rect(10, 70, 50, 30), &firstAN&))& && && && && && & {& && && && &//路径1的起始位置& && && && && && && && && & player.transform.position =new Vector3(-94.50654f, 17.2556f, 15.62861f);& && && && &//播放动画1& && && && && && && && && & iTweenEvent.GetEvent(player,&firstevent&).Play();& && && && &//停止动画2& && && && && && && && && & iTweenEvent.GetEvent(player,&secondevent&).Stop();& && && && && && & }& && && && && && & if (GUI.Button(new Rect(100, 70, 50, 30), &secondAN&))& && && && && && & {& && && && &//路径2的起始位置& && && && && && && && && & player.transform.position =new Vector3(-95.15093f, 10f, 1.327053f);& && && && &//播放动画2& && && && && && && && && & iTweenEvent.GetEvent(player,&secondevent&).Play();& && && && &//停止动画1& && && && && && && && && & iTweenEvent.GetEvent(player,&firstevent&).Stop();& && && && && && & }& && && &}}添加到游戏物体,运行游戏。这样就算OK了。& &
最后登录注册时间阅读权限100积分70484
纳金币59208 精华17
很实用的教程,推荐一下!
最后登录注册时间阅读权限0积分-5
限制会员, 积分 -5, 距离下一级还需 5 积分
纳金币1 精华0
很实用的教程,推荐一下!
最后登录注册时间阅读权限0积分-5
限制会员, 积分 -5, 距离下一级还需 5 积分
纳金币1 精华0
确切的说,这是iTween 配合 iTween visual editor 的教程
最后登录注册时间阅读权限10积分84
设计初学者, 积分 84, 距离下一级还需 16 积分
纳金币14 精华0
拜讀第二篇 感謝分享!!!
最后登录注册时间阅读权限10积分61
设计初学者, 积分 61, 距离下一级还需 39 积分
纳金币8 精华0
正好用到,非常感谢
最后登录注册时间阅读权限10积分61
设计初学者, 积分 61, 距离下一级还需 39 积分
纳金币8 精华0
路径少还行,路径多了就蛋疼了
最后登录注册时间阅读权限10积分52
设计初学者, 积分 52, 距离下一级还需 48 积分
纳金币3 精华0
下载个看看
最后登录注册时间阅读权限50积分1346
助理设计师, 积分 1346, 距离下一级还需 654 积分
纳金币505 精华0
推荐 长知识了 ! 谢谢指导
活跃且尽责职守的版主
站长推荐 /1
纳金名模第89期路灯3D模型:数量100个,大小为720MB。完全免费下载哦!这样的福利我和我的小伙伴们都惊呆了!!下载地址:
400-067-3919
Powered by - X2.5
Narkii Inc.iTween and NGUI
Pages: [1]
Topic: iTween and NGUI &(Read 9588 times)
on: June 08, :38 PM »
I'm having an issue with trying to animate a ngui sprite using itween. When the tween runs the sprite moves WAY more than the tween amount...I created a simple test scene with only one sprite with one script attached. The only code in the script:void Start()& & {& & & & iTween.MoveBy(gameObject,
Vector3(-64.0f, 0, 0), 10.0f);& & }&The sprites transform is:P X 0 Y 0 Z 0R X 0 Y 0 Z 0S X 48 Y 64 Z 1When I play the scene the x position reported for the sprite gameobject is: -15249.34If I attach the same script to a simple cube it moves as it should.Whats going on?
« Last Edit: June 08, :26 PM by BSECaleb »
« Reply #1 on: June 08, :02 PM »
You dont want to use NGUI's built in tweening? I'm not familiar with iTween so i'm unsure what it could be doing.
« Reply #2 on: June 08, :18 PM »
As far as I can tell nguis built in tweening doesn't have an option for relative movement, which is what iTweens moveby does. I know I could probably just get the current position, calculate the new position based on how much I want to move on each axis, and then use the built in tweening to move in an absolute way but I would rather keep it simple. I also want to understand what is going on in ngui that makes the sprites translation work. I have to confess that I'm a bit confused about how to deal with translation on a ngui widget since translation is in pixel units instead of world units.FWIW, MoveBy defaults to translation in local space.
« Last Edit: June 08, :33 PM by BSECaleb »
« Reply #3 on: June 08, :32 PM »
Sounds like iTween is moving it in world space (transform.position). NGUI's tweens are based in local space (transform.localPosition).
« Reply #4 on: June 08, :29 PM »
So it looks like this may be a bug in iTween. The documentation says it defaults to local space. I even tried manually setting the space to self in the hash arguments. I think iTween is still trying to move in world space. When I use HOTween and set it to animate localPosition it works as expected.
« Reply #5 on: June 11, :26 AM »
HelloI didn't try MoveBy, but I'd tried MoveTo, and it works. Hope this helps.iTween.MoveTo(gameObject,& &iTween.Hash(&position&, new Vector3(-1000, gameObject.transform.localPosition.y, Btns.transform.localPosition.z), &time&, 1, &islocal&, true )));&&&&&&&&&&&&&&&&&&Ding
« Reply #6 on: June 11, :56 AM »
Well MoveTo sounds like a direction position you specifiy and MoveBy sounds like a given distance to move.ArenMook, you might want to put the difference between transform.position and transform.localPosition as a sticky/faq because that issue seems to be catching out a lot of people.
« Reply #7 on: June 11, :54 AM »
Why not check on Unity Scrip reference?This is not a Ngui question, this is Unity knowledge.Check here:And about iTween:
terencekwan
« Reply #8 on: October 04, :07 PM »
I have the same problem. To solve it, remember to add: &islocal&, true
« Reply #9 on: October 05, :00 AM »
iTween FadeTo is also not working.& It works on regular game objects using the same shader.
« Reply #10 on: October 05, :36 PM »
Use TweenColor. iTween and NGUI are two completely different packages.
« Reply #11 on: October 24, :52 PM »
Using a different tween engine for each plugin is not desirable.... especially when dedicated tween libraries have so many more features.& Is there any easy way to fade a panel + children with the built in Tween library.& From a UI perspective that is a pretty critical piece of functionality.
« Reply #12 on: October 24, :41 PM »
iTween was not designed to work with NGUI. Built-in tweening was. NGUI doesn't expose a lot of public variables -- which is the only thing iTween can tween. NGUI exposes properties -- which built-in tweening was built to use.
« Reply #13 on: August 21, :57 PM »
I know this topic is loooong since dead, but for those of you who still actively use iTween in their projects I figured I'd post this. its worth noting that you should be aware that when using itween for NGUI widgets, you should always take into account the UIRoot's transform scale value. This is likely why most people are experiencing such radical positioning problems (and assuming that its defaulting to world space). Hope this helps!
« Reply #14 on: September 06, :46 PM »
I know this topic is loooong since dead, but for those of you who still actively use iTween in their projects I figured I'd post this. its worth noting that you should be aware that when using itween for NGUI widgets, you should always take into account the UIRoot's transform scale value. This is likely why most people are experiencing such radical positioning problems (and assuming that its defaulting to world space). Hope this helps!works well! Maybe a good solution!Thank u.
Pages: [1]unity3d动画插件iTween-路径动画的制作
内容摘要:unity3d动画插件iTween-路径动画的制作iTween是一个动画库,用它可以轻松实现各种动画,晃动,旋转,移动,褪色,上色,控制音频等等我今天主要是说一下用iTween来制作一段路径动画的方法和步骤。首先我们下载iTween插件并安装,官方商店就有,免费的。 安装方法很
  unity3d动画插件iTween-路径动画的制作iTween是一个动画库,用它可以轻松实现各种动画,晃动,旋转,移动,褪色,上色,控制音频等等我今天主要是说一下用iTween来制作一段路径动画的方法和步骤。首先我们下载iTween插件并安装,官方商店就有,免费的。
  安装方法很简单,可以再Project视图中单击鼠标右键,选择ImportPackage-&CustomPackage找到下载插件的文件夹,导入插件即可。也可以直接将插件拷贝到工程文件中的Assets文件夹中,回到unity3d中双击iTweenVisualEditor文件即可导入插件。插件导入成功后,即可在菜单栏中的Component中多出了一个iTween选项,并且在Component-&Scripts中多出了三个选项,这些都是我们马上要用到的。好了,准备工作已做完,下面开始制作我们的路径动画了。首先制作一个简单的场景。然后创建一个简单的场景,命名为path,制作路径。
  选择我们新建的path然后在Component-&Scripts中选择ITweenPcth,添加完成后即可在Inspector视图中看到我们添加的ITweenPcth属性PathName是路径的名称。我们命名为firstpath。PathColor为路径线的颜色。将他改成红色。一遍可以清晰的看到他。NodeCount为路径的关键点数量,下面Node为每个关键点坐标。我们将NodeCount的值改为6,然后设置关键点的坐标。方法1:直接改变Node下的想,x,y,z的值。防范2:在Scene视图中直接拖动每个点的坐标。制作好后的结果如图:到这里路径已经制作好了,下面将一下怎么把这条路径和我们的运动物体连接起来呢。首先我们建立一个CUBE作为要运动的物体命名为player。选择我们新建的player然后点击菜单栏的Component-&iTween-&iTweenEvent.添加完成后在Inspector视图中看到iTweenEvent属性。属性非常多。下面介绍几个长影属性。Name:为动画时间的名称。命名为MyFirstEventShowIconInScene:是否在场景中显示图标,勾选改选项。
  PlayAutomatically:是否在运行是自动播放,勾选改选项。EventType下拉框选择MoveTo,Path勾选选择Path-〉firstpath,在往下勾选Time,时间设置为30;勾选easetype设置为linear设置为匀速;设置好之后如图:好了可以运行游戏了。发现盒子沿着我们设置的路径开始运动了。(住:因为参数太多。还没有完全研究,希望大家一起研究学习,有不对的地方还望高手指教)这个就写这么多了。关于动态调用,和几个路径相互切换下次再讲吧。来源:纳金网
&&责任编辑:中国农村网
&&&&&&温馨提示:您正在浏览的文章是“unity3d动画插件iTween-路径动画的制作”
&&&&&&原载地址:
&&&&&&版权声明:本网站刊载的资讯由网友提供分享,资讯内容纯属作者个人观点,不表示农村网同意其说法或描述,仅为提供更多信息,也不构成任何建议。网友转载请注明原作者姓名及出处。如有侵犯到您的版权,请与我们联系。对于农村网的原创作品,受国家知识产权保护,版权属于农村网所有。转载务必注明出处及作者。凡用于商业用途需征得书面同意,否则追究法律责任。

我要回帖

更多关于 mysql event 设置 的文章

 

随机推荐