Created
February 21, 2020 16:24
-
-
Save kyubuns/d482a71498a3e49bffbdb0a811631ca3 to your computer and use it in GitHub Desktop.
BasicShapeSpriteDemo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using System.Threading.Tasks; | |
using AnimeTask; | |
using BasicShapeSprite; | |
using UnityEditor; | |
using UnityEngine; | |
public class Demo : MonoBehaviour | |
{ | |
[SerializeField] private List<Square> squares = new List<Square>(); | |
public async void Start() | |
{ | |
var bottomLeft = squares[0]; | |
var topLeft = squares[1]; | |
var bottomRight = squares[2]; | |
var topRight = squares[3]; | |
const float movedPos = 1.5f; | |
const float moveDuration = 0.6f; | |
const float easeR = 0.5f; | |
const float easeDuration = 0.3f; | |
await Anime.Delay(1f); | |
await Task.WhenAll( | |
new[] | |
{ | |
Anime.PlayTo(Easing.Create<OutExpo>(new Vector3(-movedPos, movedPos), moveDuration), TranslateTo.LocalPosition(topLeft.transform)), | |
Anime.PlayTo(Easing.Create<OutExpo>(new Vector3(movedPos, movedPos), moveDuration), TranslateTo.LocalPosition(topRight.transform)), | |
Anime.PlayTo(Easing.Create<OutExpo>(new Vector3(-movedPos, -movedPos), moveDuration), TranslateTo.LocalPosition(bottomLeft.transform)), | |
Anime.PlayTo(Easing.Create<OutExpo>(new Vector3(movedPos, -movedPos), moveDuration), TranslateTo.LocalPosition(bottomRight.transform)), | |
Anime.Play(Easing.Create<OutQuint>(0, easeR, easeDuration), TranslateTo.Action<float>(x => | |
{ | |
topLeft.bottomLeft = topLeft.bottomRight = topLeft.topRight = x; | |
})), | |
Anime.Play(Easing.Create<OutQuint>(0, easeR, easeDuration), TranslateTo.Action<float>(x => | |
{ | |
topRight.bottomLeft = topRight.bottomRight = topRight.topLeft = x; | |
})), | |
Anime.Play(Easing.Create<OutQuint>(0, easeR, easeDuration), TranslateTo.Action<float>(x => | |
{ | |
bottomLeft.bottomRight = bottomLeft.topLeft = bottomLeft.topRight = x; | |
})), | |
Anime.Play(Easing.Create<OutQuint>(0, easeR, easeDuration), TranslateTo.Action<float>(x => | |
{ | |
bottomRight.bottomLeft = bottomRight.topLeft = bottomRight.topRight = x; | |
})), | |
} | |
); | |
await Anime.Delay(0.3f); | |
await Task.WhenAll( | |
new[] | |
{ | |
Anime.Play(Easing.Create<OutBounce>(1f, 0.1f, 0.6f), TranslateTo.Action<float>(x => | |
{ | |
topLeft.border = topRight.border = bottomLeft.border = bottomRight.border = x; | |
})), | |
} | |
); | |
await Anime.Delay(0.3f); | |
await Task.WhenAll( | |
new[] | |
{ | |
Anime.Play(Easing.Create<InOutCubic>(easeR, 1, 1f), TranslateTo.Action<float>(x => | |
{ | |
topLeft.bottomLeft = topLeft.bottomRight = topLeft.topRight = topLeft.topLeft = x; | |
topRight.bottomLeft = topRight.bottomRight = topRight.topRight = topRight.topLeft = x; | |
bottomLeft.bottomLeft = bottomLeft.bottomRight = bottomLeft.topRight = bottomLeft.topLeft = x; | |
bottomRight.bottomLeft = bottomRight.bottomRight = bottomRight.topRight = bottomRight.topLeft = x; | |
})), | |
} | |
); | |
await Anime.Delay(0.3f); | |
await Anime.Play(Easing.Create<OutQuart>(0.1f, 1.0f, 0.5f), TranslateTo.Action<float>(x => | |
{ | |
topLeft.border = topRight.border = bottomLeft.border = bottomRight.border = x; | |
})); | |
await Anime.Delay(0.3f); | |
await Task.WhenAll( | |
new[] | |
{ | |
Anime.PlayTo(Easing.Create<OutQuart>(new Vector3(-1, 1), moveDuration), TranslateTo.LocalPosition(topLeft.transform)), | |
Anime.PlayTo(Easing.Create<OutQuart>(new Vector3(1, 1), moveDuration), TranslateTo.LocalPosition(topRight.transform)), | |
Anime.PlayTo(Easing.Create<OutQuart>(new Vector3(-1, -1), moveDuration), TranslateTo.LocalPosition(bottomLeft.transform)), | |
Anime.PlayTo(Easing.Create<OutQuart>(new Vector3(1, -1), moveDuration), TranslateTo.LocalPosition(bottomRight.transform)), | |
Anime.Play(Easing.Create<OutQuint>(1, 0, easeDuration), TranslateTo.Action<float>(x => | |
{ | |
topLeft.bottomLeft = topLeft.bottomRight = topLeft.topRight = x; | |
})), | |
Anime.Play(Easing.Create<OutQuint>(1, 0, easeDuration), TranslateTo.Action<float>(x => | |
{ | |
topRight.bottomLeft = topRight.bottomRight = topRight.topLeft = x; | |
})), | |
Anime.Play(Easing.Create<OutQuint>(1, 0, easeDuration), TranslateTo.Action<float>(x => | |
{ | |
bottomLeft.bottomRight = bottomLeft.topLeft = bottomLeft.topRight = x; | |
})), | |
Anime.Play(Easing.Create<OutQuint>(1, 0, easeDuration), TranslateTo.Action<float>(x => | |
{ | |
bottomRight.bottomLeft = bottomRight.topLeft = bottomRight.topRight = x; | |
})), | |
Anime.Play(Easing.Create<OutQuint>(1, easeR, easeDuration), TranslateTo.Action<float>(x => | |
{ | |
topLeft.topLeft = x; | |
})), | |
Anime.Play(Easing.Create<OutQuint>(1, easeR, easeDuration), TranslateTo.Action<float>(x => | |
{ | |
topRight.topRight = x; | |
})), | |
Anime.Play(Easing.Create<OutQuint>(1, easeR, easeDuration), TranslateTo.Action<float>(x => | |
{ | |
bottomLeft.bottomLeft = x; | |
})), | |
Anime.Play(Easing.Create<OutQuint>(1, easeR, easeDuration), TranslateTo.Action<float>(x => | |
{ | |
bottomRight.bottomRight = x; | |
})), | |
} | |
); | |
EditorApplication.ExitPlaymode(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment