MGS.Animation
MGS.Animation copied to clipboard
Unity plugin for make path animation in scene.
[TOC]
MGS.Animation
Summary
- Unity plugin for make animation in scene.
Platform
- Windows
Environment
- .Net Framework 3.5 or above.
- Unity 5.0 or above.
Technology
Graph
//Get frames from image file.
var image = Image.FromFile(file);
var dimension = new FrameDimension(image.FrameDimensionsList[0]);
var framesCount = image.GetFrameCount(dimension);
var frames = new Bitmap[framesCount];
for (int i = 0; i < framesCount; i++)
{
var bitmap = new Bitmap(image.Width, image.Height);
var graphics = Graphics.FromImage(bitmap);
image.SelectActiveFrame(dimension, i);
graphics.DrawImage(image, Point.Empty);
frames[i] = bitmap;
}
//Get buffer data from bitmap frame.
using (var stream = new MemoryStream())
{
bitmap.Save(stream, format);
return stream.GetBuffer();
}
Loop Mode
timer += speed * Time.deltaTime;
if (timer < 0 || timer > curve.Length)
{
switch (loopMode)
{
case LoopMode.Once:
Stop();
return;
case LoopMode.Loop:
timer -= curve.Length * TimerDirection;
break;
case LoopMode.PingPong:
speed = -speed;
timer = Mathf.Clamp(timer, 0, curve.Length);
break;
}
}
Look Up
var worldUp = Vector3.up;
switch (upMode)
{
case UpMode.TransformUp:
worldUp = transform.up;
break;
case UpMode.ReferenceUp:
if (reference)
{
worldUp = reference.up;
}
break;
case UpMode.ReferenceUpAsNormal:
if (reference)
{
var tangent = (nextPos - timePos).normalized;
worldUp = Vector3.Cross(tangent, reference.up);
}
break;
}
Usage
Curve Animation
- Attach mono curve component to a game object. Learn More
MonoHermiteCurve MonoBezierCurve MonoHelixCurve MonoEllipseCurve MonoSinCurve
- Attach mono animation component to the game object.
MonoCurveAnimation
2D Animation
- Attach mono animation component to a game object.
ImageAnimation RawImageAnimation SpriteAnimation UVFrameAnimation UVAnimation
Demo
- Demos in the path "MGS.Packages/Animation/Demo/" provide reference to you.
Preview
- HermiteCurveAnim
- BezierCurveAnim
- EllipseCurveAnim
- GifAnim
Copyright © 2021 Mogoson. [email protected]