Giter VIP home page Giter VIP logo

mgs.animation's Introduction

[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]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.