@@ -35,9 +35,9 @@ Interval actions | |||||
- [x] ScaleBy | - [x] ScaleBy | ||||
- [x] TintBy *if you want to manipulate alpha, your material must support transparency* | - [x] TintBy *if you want to manipulate alpha, your material must support transparency* | ||||
- [x] TintTo *if you want to manipulate alpha, your material must support transparency* | - [x] TintTo *if you want to manipulate alpha, your material must support transparency* | ||||
- [ ] FadeOut *if you want to manipulate alpha, your material must support transparency* | |||||
- [ ] FadeIn *if you want to manipulate alpha, your material must support transparency* | |||||
- [ ] FadeTo *if you want to manipulate alpha, your material must support transparency* | |||||
- [x] FadeOut *if you want to manipulate alpha, your material must support transparency* | |||||
- [x] FadeIn *if you want to manipulate alpha, your material must support transparency* | |||||
- [x] FadeTo *if you want to manipulate alpha, your material must support transparency* | |||||
- [x] FadeBy *if you want to manipulate alpha, your material must support transparency* | - [x] FadeBy *if you want to manipulate alpha, your material must support transparency* | ||||
- [ ] JumpTo | - [ ] JumpTo | ||||
- [ ] JumpBy | - [ ] JumpBy | ||||
@@ -22,11 +22,6 @@ class ActionFadeBy : ActionInterval | |||||
return new ActionFadeBy(-delta, duration); | return new ActionFadeBy(-delta, duration); | ||||
} | } | ||||
public override void start() | |||||
{ | |||||
base.start(); | |||||
} | |||||
public override void stepInterval(float dt) | public override void stepInterval(float dt) | ||||
{ | { | ||||
float d = dt / duration; | float d = dt / duration; | ||||
@@ -0,0 +1,22 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using UnityEngine; | |||||
class ActionFadeIn : ActionFadeTo | |||||
{ | |||||
public ActionFadeIn(float tgtDuration) | |||||
: base(1, tgtDuration) | |||||
{ | |||||
} | |||||
public override Action clone() | |||||
{ | |||||
return new ActionFadeIn(duration); | |||||
} | |||||
public override Action reverse() | |||||
{ | |||||
return new ActionFadeIn(duration); | |||||
} | |||||
} |
@@ -0,0 +1,22 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using UnityEngine; | |||||
class ActionFadeOut : ActionFadeTo | |||||
{ | |||||
public ActionFadeOut(float tgtDuration) | |||||
: base(0, tgtDuration) | |||||
{ | |||||
} | |||||
public override Action clone() | |||||
{ | |||||
return new ActionFadeOut(duration); | |||||
} | |||||
public override Action reverse() | |||||
{ | |||||
return new ActionFadeOut(duration); | |||||
} | |||||
} |
@@ -0,0 +1,34 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using UnityEngine; | |||||
class ActionFadeTo : ActionInterval | |||||
{ | |||||
public float value; | |||||
public float delta; | |||||
public ActionFadeTo(float tgtValue, float tgtDuration) | |||||
: base(tgtDuration) | |||||
{ | |||||
value = tgtValue; | |||||
} | |||||
public override Action clone() | |||||
{ | |||||
return new ActionFadeTo(value, duration); | |||||
} | |||||
public override void start() | |||||
{ | |||||
base.start(); | |||||
delta = value - target.gameObject.renderer.material.color.a; | |||||
} | |||||
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; | |||||
} | |||||
} |
@@ -7,16 +7,15 @@ public class SampleActions : MonoBehaviour | |||||
{ | { | ||||
Action seq = new ActionRepeat (new ActionSequence(new Action[] | Action seq = new ActionRepeat (new ActionSequence(new Action[] | ||||
{ | { | ||||
new ActionFadeIn(2), | |||||
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 ActionTintBy(new Vector4(-50, 50, -150), 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(), | ||||
@@ -30,7 +29,8 @@ 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 ActionTintTo(new Vector4(67, 105, 181, 255),3) | |||||
new ActionFadeOut(2), | |||||
new ActionSetTint(new Vector4(67, 105, 181)) | |||||
}), 5); | }), 5); | ||||
gameObject.SendMessage("AttachAction", seq); | gameObject.SendMessage("AttachAction", seq); | ||||
} | } | ||||