new actions:
ActionFadeIn.cs ActionFadeOut.cs ActionFadeTo.cs
This commit is contained in:
@@ -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
src/ActionsInterval/ActionFadeIn.cs
Normal file
22
src/ActionsInterval/ActionFadeIn.cs
Normal file
@@ -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
src/ActionsInterval/ActionFadeOut.cs
Normal file
22
src/ActionsInterval/ActionFadeOut.cs
Normal file
@@ -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
src/ActionsInterval/ActionFadeTo.cs
Normal file
34
src/ActionsInterval/ActionFadeTo.cs
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user