Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ismslv/Unity_Tween
Unity tweening system
https://github.com/ismslv/Unity_Tween
action csharp easing fmlht movement rotation scaling task timer tween unity unity3d
Last synced: about 1 hour ago
JSON representation
Unity tweening system
- Host: GitHub
- URL: https://github.com/ismslv/Unity_Tween
- Owner: ismslv
- License: apache-2.0
- Created: 2019-04-07T10:42:07.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-04-16T20:43:15.000Z (over 5 years ago)
- Last Synced: 2024-08-03T05:15:56.116Z (3 months ago)
- Topics: action, csharp, easing, fmlht, movement, rotation, scaling, task, timer, tween, unity, unity3d
- Language: C#
- Size: 2.66 MB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Unity_Tween
![Screenshot](Screenshot.gif)
Version 0.22Simple tweening system with easing.
```
public enum TaskType {
move,
moveLocal,
moveArc,
moveArcLocal,
rotate,
rotateLocal,
scale,
colorMaterial,
colorSprite,
actionFloat,
timerSimple,
moveUI,
tweenMesh
};Tween.a.MoveTo(what, where, time, ease, callback);
```## Adding to a project
1. Add Tween.cs to a GameObject## Usage examples
```csharp
using FMLHT;
```Moving:
```csharp
Tween.MoveTo(objTransform, new Vector3(0, 100, 0), 3f, Easing.Ease.Linear, () => {
//I've been moved!
});
```Rotating locally:
```csharp
Tween.RotateToLocal(objTransform, Quaternion.Euler(rotationTo), 3f, Easing.Ease.EaseOutElastic, () => {
//I've been rotated!
});
```Complex tween:
```csharp
Action order66 = f => {
jediCount = Mathf.Lerp(jediCountTotal, 0, f);
empireStregth = 1 - f;
saberLight = Color.Lerp(Color.blue, Color.red, f);
};
Tween.ActionFloat(order66, 0f, 1f, 10f, Easing.Ease.EaseInExpo);
```Action is returned as `Task`, so that you can refer to it later:
```csharp
Tween.Task tomJob;
void BeginJob() {
//Catch Jerry!
tomCheck = Tween.DoAfter(10f, () => {
if (!Jerry.isCaught) {
Tom.BeginJob();
}
});
}///
void Update() {
if (Jerry.isCaught) {
Tween.DeleteTask(tomCheck);
}
}
```## Tween mesh
1. Add component ```MeshTween``` to an empty mesh.
2. Assign meshes with equal vertex count to new states
3. Ajust tween value in inspector or in script:```csharp
//Directly with method
tweenMesh.SetState(0, 1f);
tweenMesh.SetState(1, 0f);
tweenMesh.UpdateCurrentState();//Tween with method
//Updates automatically
tweenMesh.Between(0, 1, 0f);//Directly to objects
tweenMesh.states[0].Weight = 1f;
tweenMesh.states[1].Weight = 0f;
tweenMesh.UpdateCurrentState();//Animated
Tween.TweenMesh(
tweenMesh, //MeshTween
0, //state from
1, //state to
0f, //value from
1f, //value to
0.5f, //time
Easing.Ease.Linear
);
```