Selaa lähdekoodia

new actions:

ActionFadeIn.cs
ActionFadeOut.cs
ActionFadeTo.cs
master
6 muutettua tiedostoa jossa 85 lisäystä ja 12 poistoa
  1. +3
    -3
      README.md
  2. +0
    -5
      src/ActionsInterval/ActionFadeBy.cs
  3. +22
    -0
      src/ActionsInterval/ActionFadeIn.cs
  4. +22
    -0
      src/ActionsInterval/ActionFadeOut.cs
  5. +34
    -0
      src/ActionsInterval/ActionFadeTo.cs
  6. +4
    -4
      src/Examples/SampleActions.cs

+ 3
- 3
README.md Näytä tiedosto

@@ -35,9 +35,9 @@ Interval actions
- [x] ScaleBy
- [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*
- [ ] 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*
- [ ] JumpTo
- [ ] JumpBy


+ 0
- 5
src/ActionsInterval/ActionFadeBy.cs Näytä tiedosto

@@ -22,11 +22,6 @@ class ActionFadeBy : ActionInterval
return new ActionFadeBy(-delta, duration);
}

public override void start()
{
base.start();
}

public override void stepInterval(float dt)
{
float d = dt / duration;


+ 22
- 0
src/ActionsInterval/ActionFadeIn.cs Näytä tiedosto

@@ -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);
}
}

+ 22
- 0
src/ActionsInterval/ActionFadeOut.cs Näytä tiedosto

@@ -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);
}
}

+ 34
- 0
src/ActionsInterval/ActionFadeTo.cs Näytä tiedosto

@@ -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;
}
}

+ 4
- 4
src/Examples/SampleActions.cs Näytä tiedosto

@@ -7,16 +7,15 @@ public class SampleActions : MonoBehaviour
{
Action seq = new ActionRepeat (new ActionSequence(new Action[]
{
new ActionFadeIn(2),
new ActionParallel(new Action[] {
new ActionMoveBy(new Vector3(10, 0, 0), 1),
new ActionMoveBy(new Vector3(0, 10, 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(0.5F, 0.5F, 2), 1),
new ActionFadeBy(-1F, 2),
new ActionFadeBy(1F, 2),
new ActionDelay(1),
new ActionRepeat(new ActionSequence(new Action[] {
new ActionHide(),
@@ -30,7 +29,8 @@ public class SampleActions : MonoBehaviour
new ActionMoveTo(new Vector3(0, 0, 10), 1),
new ActionScaleTo(new Vector3(2, 2, 2), 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);
gameObject.SendMessage("AttachAction", seq);
}