minor fixes in ActionTintBy.cs
new actions: ActionFadeBy.cs ActionTintTo.cs
This commit is contained in:
19
README.md
19
README.md
@@ -15,27 +15,30 @@ See the examples folder, there's a sample script there.
|
|||||||
|
|
||||||
You can also subclass the Actor and add all the actions you want to the Start() method.
|
You can also subclass the Actor and add all the actions you want to the Start() method.
|
||||||
|
|
||||||
### Included actions (ready and WIP)
|
### Included actions (ready and WIP)
|
||||||
|
All actions are designed to word in 3D scene (i.e. using Vector3 for movement, rotation and scaling).
|
||||||
|
You can use it in 2D with apropriate vectors, but i'm going to add support for 2D actions soon.
|
||||||
|
|
||||||
Base actions
|
Base actions
|
||||||
- [x] Sequence
|
- [x] Sequence
|
||||||
- [x] Parallel
|
- [x] Parallel
|
||||||
- [x] Repeat and Loop *implemented in one action*
|
- [x] Repeat and Loop *implemented in one action*
|
||||||
- [ ] Reverse
|
- [ ] Reverse *not yet, but every reversable action has working reverse() method*
|
||||||
|
|
||||||
Interval actions
|
Interval actions
|
||||||
|
- [x] Delay and RandomDelay *implemented in one action*
|
||||||
- [x] MoveTo
|
- [x] MoveTo
|
||||||
- [x] MoveBy
|
- [x] MoveBy
|
||||||
- [x] RotateTo
|
- [x] RotateTo
|
||||||
- [x] RotateBy
|
- [x] RotateBy
|
||||||
- [x] ScaleTo
|
- [x] ScaleTo
|
||||||
- [x] ScaleBy
|
- [x] ScaleBy
|
||||||
- [x] TintBy
|
- [x] TintBy *if you want to manipulate alpha, your material must support transparency*
|
||||||
- [x] Delay and RandomDelay *implemented in one action*
|
- [x] TintTo *if you want to manipulate alpha, your material must support transparency*
|
||||||
- [ ] TintTo
|
- [ ] FadeOut *if you want to manipulate alpha, your material must support transparency*
|
||||||
- [ ] FadeOut
|
- [ ] FadeIn *if you want to manipulate alpha, your material must support transparency*
|
||||||
- [ ] FadeIn
|
- [ ] FadeTo *if you want to manipulate alpha, your material must support transparency*
|
||||||
- [ ] FadeTo
|
- [x] FadeBy *if you want to manipulate alpha, your material must support transparency*
|
||||||
- [ ] JumpTo
|
- [ ] JumpTo
|
||||||
- [ ] JumpBy
|
- [ ] JumpBy
|
||||||
- [ ] Bezier
|
- [ ] Bezier
|
||||||
|
|||||||
37
src/ActionsInterval/ActionFadeBy.cs
Normal file
37
src/ActionsInterval/ActionFadeBy.cs
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
class ActionFadeBy : ActionInterval
|
||||||
|
{
|
||||||
|
public float delta;
|
||||||
|
|
||||||
|
public ActionFadeBy(float tgtDelta, float tgtDuration)
|
||||||
|
: base(tgtDuration)
|
||||||
|
{
|
||||||
|
delta = tgtDelta;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Action clone()
|
||||||
|
{
|
||||||
|
return new ActionFadeBy(delta, duration);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Action reverse()
|
||||||
|
{
|
||||||
|
return new ActionFadeBy(-delta, duration);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void start()
|
||||||
|
{
|
||||||
|
base.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void stepInterval(float dt)
|
||||||
|
{
|
||||||
|
float d = dt / duration;
|
||||||
|
Color tgtColor = target.gameObject.renderer.material.color;
|
||||||
|
tgtColor[3] += delta * d;
|
||||||
|
target.gameObject.renderer.material.color = tgtColor;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,6 +13,11 @@ class ActionTintBy : ActionInterval
|
|||||||
color = tgtColor * coeff;
|
color = tgtColor * coeff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ActionTintBy(Vector3 tgtColor, float tgtDuration)
|
||||||
|
: this(new Vector4(tgtColor.x, tgtColor.y, tgtColor.z), tgtDuration)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public override Action clone()
|
public override Action clone()
|
||||||
{
|
{
|
||||||
return new ActionTintBy(color / coeff, duration);
|
return new ActionTintBy(color / coeff, duration);
|
||||||
|
|||||||
49
src/ActionsInterval/ActionTintTo.cs
Normal file
49
src/ActionsInterval/ActionTintTo.cs
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
class ActionTintTo : ActionInterval
|
||||||
|
{
|
||||||
|
public Vector4 color;
|
||||||
|
public Vector4 path;
|
||||||
|
protected const float coeff = 1F / 255F;
|
||||||
|
|
||||||
|
public ActionTintTo(Vector4 tgtColor, float tgtDuration)
|
||||||
|
: base(tgtDuration)
|
||||||
|
{
|
||||||
|
color = tgtColor * coeff;
|
||||||
|
path = Vector4.zero;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActionTintTo(Vector3 tgtColor, float tgtDuration)
|
||||||
|
: this(new Vector4(tgtColor.x, tgtColor.y, tgtColor.z), tgtDuration)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Action clone()
|
||||||
|
{
|
||||||
|
return new ActionTintTo(color / coeff, duration);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void start()
|
||||||
|
{
|
||||||
|
base.start();
|
||||||
|
Color tgtColor = target.gameObject.renderer.material.color;
|
||||||
|
path[0] = color[0] - tgtColor[0];
|
||||||
|
path[1] = color[1] - tgtColor[1];
|
||||||
|
path[2] = color[2] - tgtColor[2];
|
||||||
|
path[3] = color[3] - tgtColor[3];
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void stepInterval(float dt)
|
||||||
|
{
|
||||||
|
float d = dt / duration;
|
||||||
|
Vector4 tgt = path * d;
|
||||||
|
Color tgtColor = target.gameObject.renderer.material.color;
|
||||||
|
tgtColor[0] += tgt[0];
|
||||||
|
tgtColor[1] += tgt[1];
|
||||||
|
tgtColor[2] += tgt[2];
|
||||||
|
tgtColor[3] += tgt[3];
|
||||||
|
target.gameObject.renderer.material.color = tgtColor;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,14 +7,16 @@ public class SampleActions : MonoBehaviour
|
|||||||
{
|
{
|
||||||
Action seq = new ActionRepeat (new ActionSequence(new Action[]
|
Action seq = new ActionRepeat (new ActionSequence(new Action[]
|
||||||
{
|
{
|
||||||
new ActionTintBy(new Vector4(-50,50,-50,-50),1),
|
|
||||||
new ActionParallel(new Action[] {
|
new ActionParallel(new Action[] {
|
||||||
new ActionMoveBy(new Vector3(10, 0, 0), 1),
|
new ActionMoveBy(new Vector3(10, 0, 0), 1),
|
||||||
new ActionMoveBy(new Vector3(0, 10, 0), 1),
|
new ActionMoveBy(new Vector3(0, 10, 0), 1),
|
||||||
// new ActionRotateBy(new Vector3(90, 0, 0), 1)
|
new ActionRotateBy(new Vector3(90, 0, 0), 1),
|
||||||
|
new ActionTintBy(new Vector4(-50, 50, -150, 0), 1)
|
||||||
}),
|
}),
|
||||||
new ActionScaleBy(new Vector3(2, 2, 1), 1),
|
new ActionScaleBy(new Vector3(2, 2, 1), 1),
|
||||||
new ActionScaleBy(new Vector3(0.5F, 0.5F, 2), 1),
|
new ActionScaleBy(new Vector3(0.5F, 0.5F, 2), 1),
|
||||||
|
new ActionFadeBy(-1F, 2),
|
||||||
|
new ActionFadeBy(1F, 2),
|
||||||
new ActionDelay(1),
|
new ActionDelay(1),
|
||||||
new ActionRepeat(new ActionSequence(new Action[] {
|
new ActionRepeat(new ActionSequence(new Action[] {
|
||||||
new ActionHide(),
|
new ActionHide(),
|
||||||
@@ -28,7 +30,7 @@ public class SampleActions : MonoBehaviour
|
|||||||
new ActionMoveTo(new Vector3(0, 0, 10), 1),
|
new ActionMoveTo(new Vector3(0, 0, 10), 1),
|
||||||
new ActionScaleTo(new Vector3(2, 2, 2), 1),
|
new ActionScaleTo(new Vector3(2, 2, 2), 1),
|
||||||
new ActionRotateTo(new Vector3(0, 0, 0), 1),
|
new ActionRotateTo(new Vector3(0, 0, 0), 1),
|
||||||
new ActionTintBy(new Vector4(50,-50,50,50),3)
|
new ActionTintTo(new Vector4(67, 105, 181, 255),3)
|
||||||
}), 5);
|
}), 5);
|
||||||
gameObject.SendMessage("AttachAction", seq);
|
gameObject.SendMessage("AttachAction", seq);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user