Giter Club home page Giter Club logo

tween.cs's Introduction

Tween.cs

No need for using, everything necessary is in global namespace. Just drop Tween.cs anywhere in your project.

yield return new Tween(gameObject)
    .Position.X.Add(10, Easing.BounceOut)
    .Scale.To(Vector2.one * 0.5f, Easing.BounceOut)
    .Duration(1)
    .Then
    .Color.To(Color.red)
    .Duration(0.5f)
    .StartCoroutine(this);

Tween class provides shortcuts for .Transform.Position, .Transform.Scale and .Transform.Rotation...

yield return new Tween(gameObject)
    // This
    .Position.To(Vector3.left)
    .Scale.X.From(0).Add(2)
    .Rotation.Z.From(0).To(90)
    .Duration(1)
    .Then
    // Equals to this
    .Transform.Position.To(Vector3.left)
    .Transform.Scale.X.From(0).Add(2)
    .Transform.Rotation.Z.From(0).To(90)
    .Duration(1)
    .StartCoroutine(this);

... and for color and alpha (works for Graphic, SpriteRenderer and CanvasGroup)

yield return new Tween(gameObject)
    .Color.To(Color.red)
    .Alpha.To(0)
    .Duration(1)
    .StartCoroutine(this);

There are also a couple of extensions for common components

yield return new Tween(gameObject)
    .Image().FillAmount.To(1)
    .Text().FontSize.From(20).To(24)
    .AudioSource().Volume.To(0)
    .Duration(5)
    .StartCoroutine(this);

All easings can be passed in To() and Add() methods

yield return new Tween(gameObject)
    .Position.Add(Vector3.one, Easing.SineOut)
    .Scale.X.From(0).Add(2, Easing.BounceInOut)
    .Rotation.Z.From(0).Add(90, Easing.ExpoOutIn)
    .Color.To(Color.red, Easing.QuartIn)
    .Duration(1)
    .StartCoroutine(this);

StartCoroutine(this) is necessary for things to work.

Todo

  • Different playbacks (like loop, backwards, etc.)
  • Attach different game object
  • Wait(), Set(), Delay()

Maybe?

  • Custom Unity editor
  • Standard tweens (then we will need Tweens to be tweakable after constructing)

tween.cs's People

Contributors

razenpok avatar

Stargazers

 avatar

Watchers

 avatar

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.