GuiManager2的用法,想让GUI旋转缩放是很简单的.doc_第1页
GuiManager2的用法,想让GUI旋转缩放是很简单的.doc_第2页
GuiManager2的用法,想让GUI旋转缩放是很简单的.doc_第3页
GuiManager2的用法,想让GUI旋转缩放是很简单的.doc_第4页
GuiManager2的用法,想让GUI旋转缩放是很简单的.doc_第5页
已阅读5页,还剩11页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

如要转载必须注明转帖自CocoaChina论坛。GUIManager 2是besuser发表于unity官方论坛的一个Unity插件,主要用在iPhone上。插件地址:/viewtopic.php?t=43084本站下载地址:/bbs/job.php?action-download-pid-92520-tid-15677-aid-8094.html优点:(这个东西真的很强大,直接拿它做一个游戏也不是不可能的) 支持3D旋转缩放 将描绘GUI元素缩减为1个drawcall,极大地提高效率 支持材质地图,多个GUI元素可以放到一张图片上,节省内存 GUI元素的所有属性都可以设置动画 支持逐帧角色动画 支持Touch事件 所有GUI元素都支持淡入淡出。 可以对GUI元素调色 动态缩放 GUIText和GUITexture均可集成进场景内 支持10个GUI层 支持iPhone上5个点同时触摸 同时支持Unity iPhone和Unity 可以调节GUI上的哪部分响应触摸事件 与屏幕分辨率无关,并非仅仅支持iPhone 比上一版更容易设置 完美像素元素碰撞支持,也可以支持非规则物体的触摸事件。设置方法:1 建立一个空的项目。2 把下载来的包导入到这个项目里。3 建一个空的GameObject,取名为GUI。找到PlugIns目录里面的GUIManager脚本,拽上去。然后设置屏幕的分辨率(比如480x320),如果需要iTouch支持,也同样把PlugIns目录的iTouch脚本也拽进去。4 再建立一个空的GameObject,随便取名。比如我取名叫quadmgr,拽到刚才建立的GUI下面。然后在PlugIns目录找到GuiQuadMgr这个脚本(不要看原文,他写错了),拽到刚创建的quadmgr上。拽完后,把Position和Rotation改成0 0 0,scale改成1 1 1。5 重复上面,建个空的GameObject,拽到quadmgr下面,随便取名,比如button。然后把PlugIns目录里的GUIQuadObj这个脚本拽上去。6 然后需要调整属性了:先点选回quadmgr,里面有个Material属性。如果你导入了这个插件包,里面有个默认的material,你可以用,叫TestMaterial。先用着吧。你可以看看这个TestMaterial,用的Shader是GUIManager With Backface。另外还有一个Shader叫GUIManager。这两个区别就是一个翻过来也会显示材质,另一个不会。Alloc Block Size设置为1或者以上即可。7 这里有一堆属性设置,很简单的英文,不翻译了。* MColor Set the tint and alpha for the gui object.* MWidth - The width of the gui object* MHeight - The height of the gui object* MLocation - The initial location on the screen this gui object should be at. The anchor is in the middle of the gui.* MRotation - The initial rotation of the gui object.* MScale - The initial scale of the gui object.* MUV - The lower left UV coords of the texture map to skin this gui object.* MDepth - The layer order. Larger value objects gets placed further back.* MAnimUV This is the UV coords for the first frame in a sprite animation filmstrip.* MAnimCols The number of columns for the sprite animation filmstrip.* MAnimMaxFrames The total number of frames in the sprite animation.* MCollider - You can select None, Square or Circular hit areas used for touch inputs.* MCollider Size Size of the touch area associated with this gui object.* MVisible - Is this gui object visible* MEnabled Determine if the gui object will response to inputs like the mouse or touches.8 在quadmgr选好层之后,下面所有子GUI元素都会显示在这个层上。9 在主摄像机的Culling mask里关掉创建的层(这里没搞明白,目前没影响使用)。10 创建GUI处理程序。(自带例子里用的是C#,我传的附件用的是Javascript。)把处理程序拽到子对象上(比如刚才那个button)就可以了。然后我再简单说一下处理GUI的脚本程序怎么写:下面这段代码是让图片里的那个字母“G”不停顺时针旋转。请注意看代码的注释。private var thisObj:GUIQuadObj;function Awake()thisObj=gameObject.GetComponent(typeof(GUIQuadObj); /先获取要旋转的对象,那个Gfunction ResetAnimation()thisObj.Rotation=new Vector3(0,0,0); /转完一圈之后归位接着转function Start()/类似的函数还有:AnimateTo, AnimateFrom, AnimateBythisObj.AnimateTo(3, /持续事件gameObject, /回调对象,写gameObject就可以ResetAnimation, /回调函数名null, /回调参数Rotation, /这个参数,可以是Rotation,Location,Scale等,参看上面第7条的属性名,把前面的M去掉,都可以调整new Vector3(0,0,-360),easing,Ani.AnimationEasingType.LinearEasing);/其他的easing方式还有:LinearEasing QuadraticEasing CubicEasing QuarticEasing QuinticEasing SinusoidalEasing ExponentialEasing CircularEasing BackEasing BounceEasing ElasticEasingthisObj.StartAnimation (Ani.Animate.Loop, null, null, null); /循环方式有两种:Ani.Animate.OneShot, Ani.Animate.Loop 再有就是关于Texture地图的问题。例子里面带了个图SampleMenu,刚开始使用的时候,可以直接就改它那个图,试验一下按钮或者动画怎么放。这样一来,使用GUIManager2,你所有的GUI旋转,缩放,动画之类的问题,就都解决了。GUI再也不会看起来很无聊了。附:GuiManager2类的参考:引用GUIQuadObj Class:This class handles the quad for all the GUI elements. It communicates with the GUIQuadMgr to merge all the elements into a single mesh.Parameters:- GUIQuadObj.QuadManager: Gets a pointer to the GUIQuadMgr this object is attached to.- GUIQuadObj.QuadSprite: Gets a pointer to the GUISprite class used internally.- GUIQuadObj.Tint : Set/Get the objects color.- GUIQuadObj.Width: Set/Get the objects pixel width.- GUIQuadObj.Height: Set/Get the objects pixel height.- GUIQuadObj.Location: Set/Get the objects location on the screen in pixel coordinates.- GUIQuadObj.Rotation: Set/Get the objects rotation in degrees. You can do rotation on all three axis. To get rotation with perspective, set the camera under the master GUI object to perspective. Otherwise, youll get orthographic rotations.- GUIQuadObj.Scale: Set/Get the objects scale. One unit represent on width/height value of the object.- GUIQuadObj.UV: Set/Get the UV coordinates for the lower left corner of the quad.- GUIQuadObj.Depth: Set/Get the layer depth of the object. Larger numbers places the object farther back.- GUIQuadObj.AnimUV: Set/Get the UV coordinates of the start of the sprite animation filmstrip.- GUIQuadObj.AnimCols: Set/Get the number of columns in the sprite animation filmstrip.- GUIQuadObj.AnimMaxFrames: Set/Get the total number of frames in the sprite animation.- GUIQuadObj.Visibile: Set/Get the objects visibility.- GUIQuadObj.Enabled: Set/Get whether the object responds to input events.Methods:- void GUIQuadObj.StartFPS (int StartVal, int EndVal, float Speed, FrameMode AnimMode)This functions start the sprite frame animator. The start frame, end frame, and FPS is used to control the animation. The FrameMode determines the playback type:- GUIQuadObj.FrameMode.ForwardOneShot Animated forward once and stop.- GUIQuadObj.FrameMode.ForwardLoop Animate forward looped- GUIQuadObj.FrameMode.BackwardOneShot Animated reversed once and stop.- GUIQuadObj.FrameMode.BackwardLoop Animate reversed looped- GUIQuadObj.FrameMode.Bounce Animate frames back and forth, looped- void GUIQuadObj.StopFPS ()Stop all sprite frame animation.- void GUIQuadObj.AnimateTo (float Duration, GameObject CallbackObj, object CallbackMsg, object CallbackParams, params object args)This function animates the GUI parameters from the current state to the desired state then call the specified callback function.- void GUIQuadObj.AnimateFrom (float Duration, GameObject CallbackObj, object CallbackMsg, object CallbackParams, params object args)This function animates the GUI parameters from the desired state to the current state then call the specified callback function.- void GUIQuadObj.AnimateBy (float Duration, GameObject CallbackObj, object CallbackMsg, object CallbackParams, params object args)This function animates the GUI parameters from the current state by the amounts in the desired state then call the specified callback function.- void GUIQuadObj.StartAnimation (Animate Mode, GameObject CallbackObj, object CallbackMsg, object CallbackParams)Starts a series of buffered animation commands then call the specified callback function. Use Ani.Animate.OneShot or Ani.Animate.Loop for the mode.- voidGUIQuadObj.StopAnimation ()Stops the current animation, but does not clear the buffered animation sequence.- voidGUIQuadObj.ClearAnimation ()Clears all buffered animation commands.- void GUIQuadObj.UpdateTransform ()Updates the vertices of the object if it has moved due to changes in the transform of itself or any of its parents. You must call after changing any of its parents transforms to re-sync the object with the new world coordinates. If you dont do this, the hit areas and the paint area will be in the wrong place.Callbacks/Events:- onGUIUp (iPhoneTouch pTouch)- onGUIDown (iPhoneTouch pTouch)- onGUIMoved (iPhoneTouch pTouch)GUITextObj Class:This class handles the use of the GUIText component. You dont need to use this as you can directly handle GUIText components yourself, but Ive already created a buffer of GUIText elements and this class is the interface. By using this interface, you wont have to create and destroy GUIText components all the time. You can just keep reusing them.Parameters:- GUITextObj.GameObj: Gets a pointer to the gameobject this GUIText component is attached to.- GUITextObj.TextObj: Gets a pointer to the GUIText component.- GUITextObj.GUIActive: Set/Get the flag to determine if the GUIText is being used by someone.- GUITextObj.Text: Set/Get the text string for the GUIText.- GUITextObj.Location: Set/Get the pixelOffset for the GUIText.- GUITextObj.LocX: Set/Get just the pixelOffset.x parameter.- GUITextObj.LocY: Set/Get just the pixelOffset.y parameter.- GUITextObj.GUIDepth: Set/Get the Z transform parameter. This also sets the layering order for the GUIText. The larger the number is closer to the camera it is.- GUITextObj.TextMaterial: Set/Get the material use for text rendering.- GUITextObj.Enabled: Set/Get whether the GUIText is active.Methods:- void GUITextObj.SetFormat (Font pFont, TextAlignment pAlign, TextAnchor pAnchor, float pSpacing, float pTabSize)This function sets up all most of the GUIText parameters.- void GUITextObj.Reset ()This function releases the GUIText from usage and makes it available for reuse.- void GUITextObj.CheckHit (Vector3 Coords)This function checks to see if the user clicked on the component. Pass the mouse input values.- void GUITextObj.AnimateTo (float Duration, GameObject CallbackObj, object CallbackMsg, object CallbackParams, params object args)This function animates the GUIText parameters from the current state to the desired state.- void GUITextObj.AnimateFrom (float Duration, GameObject CallbackObj, object CallbackMsg, object CallbackParams, params object args)This function animates the GUIText parameters from the desired state to the current state- void GUITextObj.AnimateBy (float Duration, GameObject CallbackObj, object CallbackMsg, object CallbackParams, params object args)This function animates the GUIText parameters from the current state by the amounts in the desired state.- void GUITextObj.StartAnimation (Animate Mode, GameObject CallbackObj, object CallbackMsg, object CallbackParams)Starts a series of buffered animation commands. Use Ani.Animate.OneShot or Ani.Animate.Loop for the mode.- voidGUITextObj.StopAnimation ()Stops the current animation, but does not clear the buffered animation sequence.- voidGUITextObj.ClearAnimation ()Clears all buffered animation commands.GUITextureObj Class:This class handles the use of the GUITexture component. You dont need to use this as you can directly handle GUITexture components yourself, but Ive already created a buffer of GUITexture elements and this class is the interface. By using this interface, you wont have to create and destroy GUITexture components all the time. You can just keep reusing them.Parameters:- GUITextureObj.GameObj: Gets a pointer to the gameobject this GUITexture component is attached to.- GUITextureObj.TextObj: Gets a pointer to the GUITexture component.- GUITextureObj.GUIActive: Set/Get the flag to determine if the GUITexture is being used by someone.- GUITextureObj.Image: Set/Get the texture for the GUITexture.- GUITextureObj.Location: Set/Get the pixelInset for the GUITexture.- GUITextureObj.LocX: Set/Get just the pixelInset.x parameter.- GUITextureObj.LocY: Set/Get just the pixelInset.y parameter.- GUITextureObj.LocW: Set/Get just the pixelInset.width parameter.- GUITextureObj.LocH: Set/Get just the pixelInset.height parameter.- GUITextureObj.GUIDepth: Set/Get the Z transform parameter. This also sets the layering order for the GUITexture. The larger the number is closer to the camera it is.- GUITextureObj.Enabled: Set/Get whether the GUITexture is active.Methods:- void GUITextureObj.Reset ()This function releases the GUITexture from usage and makes it available for reuse.- void GUI

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论