Giter Club home page Giter Club logo

unity-n-animation's Introduction

n-animation

block animating...

The basic idea behind this package is that you want to run a series of minor animations and effects, and, occasionally, wait until some of them are done before you continue with other actions.

For example, you drag an object and want it smoothly 'snap back' into the original position, and lock the UI until the animation is completed.

The other part of the motivation for this is that calling a million Update() calls is actually significantly slower than calling a custom UpdateMe() function a million times in a single Update() function. There's more background on that here: http://blogs.unity3d.com/2015/12/23/1k-update-calls/

Usage

Very simply to create an animation implement the IAnimation interface on a behaviour and add it to an object. If the object is to be destroyed before the target is, use the AnimationManager.Spawn() function to create a temporary object.

You can then use the AnimationManager type to register handlers for various callbacks like completion, stream completion, etc.

If you want a custom animation curve, simply implement a new IAnimationCurve.

See the tests in the Editor/ folder for each class for usage examples.

The tests folder has a bunch of examples as well.

Multitarget animations

Sometimes you want an animation such as a multi-target 'burst' animation that scatters targets in all directions.

For this sort of animation, you still extend IAnimation for the primary animation, but then call AddChildren() with either a specific GameObject or with some type that extends IAnimationChildSelector that can resolve a source for animated objects.

Notice specifically that unlike the main animation, no component is added to the child objects to bind then to a specific animation; only the parent object has an animation component attached to it.

A number of default selectors can be founder under selectors.

Install

From your unity project folder:

npm init
npm install shadowmint/unity-n-animation --save
echo Assets/packages >> .gitignore
echo Assets/packages.meta >> .gitignore

The package and all its dependencies will be installed in your Assets/packages folder.

Development

Setup and run tests:

npm install
npm install ..
cd test
npm install
gulp

Remember that changes made to the test folder are not saved to the package unless they are copied back into the source folder.

To reinstall the files from the src folder, run npm install .. again.

Tests

All tests are wrapped in #if ... blocks to prevent test spam.

You can enable tests in: Player settings > Other Settings > Scripting Define Symbols

The test key for this package is: N_ANIM_TESTS

unity-n-animation's People

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.