• Stars
    star
    318
  • Rank 131,127 (Top 3 %)
  • Language
    C#
  • License
    MIT License
  • Created almost 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Task Animation Library for Unity

AnimeTask

Task Animation Library for Unity
Rx Version! -> kyubuns/AnimeRx

Read this document in other languages: 日本語

Buy Me A Coffee

gif_animation_001

Sample

-> Example of use

Basic

Move from (-5f, 0f, 0f) to (5f, 0f, 0f) over 2 seconds.

await Easing.Create<Linear>(new Vector3(-5f, 0f, 0f), new Vector3(5f, 0f, 0f), 2f).ToLocalPosition(cube);

PlayTo

Move from the current location to a specified location.

await Easing.Create<Linear>(new Vector3(-5f, 3f, 0f), 2f).ToLocalPosition(cube);

Easing

Use InCubic of Easing to move to a specified position.

await Easing.Create<InCubic>(new Vector3(-5f, 3f, 0f), 2f).ToLocalPosition(cube);

Linear

Move at 1 per second for 2 seconds.

await Moving.Linear(1f, 2f).ToLocalPositionX(cube);

Gravity

const float xRange = 5f;
const float yRangeMin = 5f;
const float yRangeMax = 10f;
await Moving.Gravity(
          new Vector2(Random.Range(-xRange, xRange), Random.Range(yRangeMin, yRangeMax)),
          Vector2.down * 9.8f,
          5f
      ).ToLocalPosition(shape)

AnimationCurve

[SerializeField] private AnimationCurve sample12 = default;

public async UniTask Sample12()
{
    await Moving.AnimationCurve(sample12).ToLocalPositionX(cube);
}

CalcDuration

Move by calculating moving time from distance.

await Easing.Create<OutCubic>(new Vector3(5f, 0f, 0f), x => x / 2f)
    .Concat(Easing.Create<OutCubic>(new Vector3(5f, 2f, 0f), x => x / 2f))
    .Concat(Easing.Create<OutCubic>(new Vector3(-5f, 0f, 0f), x => x / 2f))
    .ToLocalPosition(cubes);

TranslateTo.Action

TranslateTo.Action enables you to use the animated values freely.

Easing.Create<Linear>(0, 100, 2f).ToAction<float>(x => Debug.Log(x))

UnscaledTime

You can create your own scheduler, so you can stop time for specific objects.
The default is to use Time.time, and you can also use UnscaledTimeScheduler, which uses Time.unscaledTime.

Easing.Create<Linear>(new Vector3(-5f, 0f, 0f), new Vector3(5f, 0f, 0f), 2f)
    .ToLocalPosition(shape, default, new UnscaledTimeScheduler());

Update Timing

If an update timing is specified in the scheduler, values can be updated at times other than Update.

public class CustomScheduler : IScheduler
{
    public float DeltaTime => Time.deltaTime;
    public PlayerLoopTiming UpdateTiming => PlayerLoopTiming.PreUpdate;
}

Cancel

var cancellationTokenSource = new CancellationTokenSource();
cancellationTokenSource.Token.Register(() => Debug.Log("Cancel"));
cancellationTokenSource.CancelAfter(500);

await Easing.Create<OutCubic>(new Vector3(5f, 0f, 0f), 2f).ToLocalPosition(cubes[0], cancellationTokenSource.Token);

Convert

Convert a float transition to a circular motion.

await Easing.Create<OutCubic>(0.0f, Mathf.PI * 2.0f, 2f)
    .Convert(x => new Vector3(Mathf.Sin(x), Mathf.Cos(x), 0.0f) * 3.0f)
    .ToLocalPosition(go);

Concat

It moves from 5f to 0f in 2 seconds, stops for 1 second, and moves to -5f in 2 seconds.

await Easing.Create<OutCubic>(5f, 0f, 2f)
    .Delay(1f)
    .Concat(Easing.Create<OutCubic>(0f, -5f, 2f))
    .ToLocalPositionX(cubes[0]);

IProgress

Supporting IProgress

await Easing.Create<Linear>(2f).ToProgress(Progress.Create<float>(x => Debug.Log(x)));

AnimationCanceller

var canceller = go.GetAnimationCanceller().Cancel();
Easing.Create<Linear>(1.0f, 0.5f).ToLocalPositionX(go, canceller.Token);

// in other class/scope
var canceller = go.GetAnimationCanceller().Cancel();
Easing.Create<Linear>(0.0f, 0.5f).ToLocalPositionX(go, canceller.Token);

Skip

  • Cancel (using CancellationToken) will stop at the position at the moment of Cancel.
  • Skip (using SkipToken) will move to the last position at the moment of Skip.
var skipTokenSource = new SkipTokenSource();
Easing.Create<OutCubic>(new Vector3(5f, 0f, 0f), 5f).ToLocalPosition(cubes[0], default, skipTokenSource.Token).Forget();
await UniTask.Delay(TimeSpan.FromSeconds(1));
skipTokenSource.Skip();

UniRx.Extensions

var score = new ReactiveProperty<int>(0);
score
    .SubscribeTask(async (x, cancellationToken) =>
    {
        scoreCounter.text = $"{x}";
        await Easing.Create<OutBounce>(2f, 1f, 0.5f).ToLocalScale(scoreCounter, cancellationToken);
    });

Instructions

  • Import AnimeTask via Package Manager
    • https://github.com/kyubuns/AnimeTask.git?path=Assets/AnimeTask
  • Import AnimeTask via UnityPackage

Way of thinking

You can pass two arguments to Play and PlayTo.
The first is the Animator and the second is the Translator, which have distinct roles.

Animator

Takes the elapsed time and returns the current value.

Translator

Reflect the value.

Requirements

  • Requires Unity2020.3 or later

License

MIT License (see LICENSE)

Buy me a coffee

Are you enjoying save time?
Buy me a coffee if you love my code!
https://www.buymeacoffee.com/kyubuns

"I used it for this game!"

I'd be happy to receive reports like "I used it for this game!"
Please contact me by email, twitter or any other means.
(This library is MIT licensed, so reporting is NOT mandatory.)
MessageForm

https://kyubuns.dev/

More Repositories

1

AkyuiUnity

Adobe XD to Akyui to Unity UI
C#
373
star
2

Baum2

Psd to Unity UI(uGUI)
C#
280
star
3

AnimeRx

Rx Tween Animation Library for Unity
C#
200
star
4

Auto9Slicer

Auto 9 slice sprite generator on Unity
C#
152
star
5

AppIconChangerUnity

Change the app icon dynamically in Unity (iOS only)
C#
122
star
6

AnKuchen

Control UI Prefab from Script Library
C#
99
star
7

BasicShapeSprite

BasicShapeSprite is a drawing beautiful squares and circles as sprite for unity.
C#
42
star
8

onion_ring

auto 9 sliced sprite (9 patch) generator
Ruby
40
star
9

AbcConsole

Mobile-friendly debug console
C#
38
star
10

prefab_in_prefab

[deprecated]
C#
38
star
11

AssetBookmarks

An editor extension that allows you to register and display commonly use assets
C#
37
star
12

UnityRemoveDevWatermark

C#
37
star
13

Kuchen

Pub/Sub for Unity
C#
32
star
14

ApureEasing

Easing library for Unity Visual Scripting
C#
26
star
15

Akyui

File format for define game UI
17
star
16

UniClipboard

Clipboard for Unity ( support PC/Mac/iOS )
C#
16
star
17

js_ruby_chat

javascript <-> ( msgpack -> websocket -> msgpack ) <-> server
Ruby
15
star
18

ObjectWeightScale

Display a list of assets that a GameObject refers to and check their sizes.
C#
14
star
19

BridgeJsCoreUnity

The fast JavaScript executor for Unity iOS, macOS by using JavaScriptCore
C#
13
star
20

UniClipboard20xx

Clipboard for Unity2017(Support: Editor, Windows, Mac, iOS)
C#
12
star
21

Adobe-Japan1-List

Adobe-Japan1の文字一覧です。
C#
12
star
22

PostProcessingPaletteSwap

Color palette swap for Unity PostProcessingStack
C#
11
star
23

Aprot

Accelerated Prototyping Framework for Unity
10
star
24

DataBinderForNGUI

NGUIのWidgetに勝手に値いれてくれるやつ
C#
8
star
25

misterioso

枠Work
Ruby
6
star
26

illustrator_replace

イラレデータ内のテキストアイテムをtsvに従って置換してくれるスクリプト
JavaScript
6
star
27

HaxeUnityBenchmark

Haxeで書いたコードをUnity上で動かすにあたり、どんな方法が良いか検討するための実験コード
C#
6
star
28

XdParser

Adobe XD file parser for C#
C#
5
star
29

mini_unity_chan_on_unity

ミニゆにてぃちゃん on Unity
C#
4
star
30

ReflectBall

Unity 1週間ゲームジャム - お題「当てる」
C#
4
star
31

rpg_maker_test

GitHub Pagesでそのままゲームを遊べるようにしてみる。
JavaScript
4
star
32

wakutuke

枠を付ける
Shell
4
star
33

haxe-socketio-chat

haxe + socket.io de chat => WakuRPCのsample_chatに移動しました
Haxe
4
star
34

yogurt

PhotoshopPlugin: レイヤー毎に素早くファイルで保存する
JavaScript
3
star
35

WakuTest

C#
3
star
36

QuizGameSample

AdobeXDを用いたUnityゲーム開発フローのサンプルプロジェクト
ShaderLab
3
star
37

AutomaticOperationTest

C#
2
star
38

MMOM

MMOもどき
JavaScript
2
star
39

AnimeSandbox

AnimeRx & AnimeTask Sandbox
C#
2
star
40

wakusocket

C++
2
star
41

VariableMonitor

C#
2
star
42

warabi

PhotoshopPlugin: レイヤー毎に重ならないようにいい感じに並べてくれる
JavaScript
2
star
43

StreamingAssetsDemo

Qiitaの記事用
C#
2
star
44

codevs

C++
1
star
45

TilemapBugreport

C#
1
star
46

hubot_tokusub

hubotが今日の得サブを教えてくれる
CoffeeScript
1
star
47

DiceCountGame

サイコロ数えるゲームを作ろうとして飽きたやつ
C#
1
star
48

UniRxSandbox

C#
1
star
49

Sample1030918

Unityへのバグ報告用
1
star
50

illustrator_csv_importer

イラレデータにcsvからテキストを流し込むやつ
JavaScript
1
star
51

GIT_SAFE_RESET

git reset --hard HEADで泣いたことがある人向け
1
star
52

BugReportConditionalWeakTable

Unityへのバグ報告用
C#
1
star
53

githooks

core.hooksPath = ~/.githooks
Shell
1
star
54

MsgPackTest

バグ報告用
C#
1
star
55

favme

Flask+jinja2を使用したwebサイト制作時に簡単にXSS対策を出来るようにする便利クラス
Python
1
star
56

prism-theme-gist

GitHub Gist theme for prism.js
HTML
1
star
57

shaved_ice

PhotoshopPlugin: 全部のレイヤーをそれぞれラスタライズする
JavaScript
1
star
58

CheeseCake

C#のコードを綺麗にするやつ
C#
1
star
59

kyubuns

1
star