You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.1 KiB
56 lines
1.1 KiB
10 years ago
|
using UnityEngine;
|
||
|
using System;
|
||
|
using System.Collections;
|
||
|
|
||
10 years ago
|
namespace Fungus
|
||
10 years ago
|
{
|
||
10 years ago
|
[CommandInfo("Sprite",
|
||
|
"Fade Sprite",
|
||
10 years ago
|
"Fades a sprite to a target color over a period of time.")]
|
||
10 years ago
|
public class FadeSprite : Command
|
||
10 years ago
|
{
|
||
|
public SpriteRenderer spriteRenderer;
|
||
10 years ago
|
public float duration = 1f;
|
||
10 years ago
|
public Color targetColor = Color.white;
|
||
|
public bool waitUntilFinished = true;
|
||
|
|
||
|
public override void OnEnter()
|
||
|
{
|
||
10 years ago
|
CameraController cameraController = CameraController.GetInstance();
|
||
10 years ago
|
|
||
|
if (waitUntilFinished)
|
||
|
{
|
||
10 years ago
|
cameraController.waiting = true;
|
||
10 years ago
|
}
|
||
|
|
||
|
SpriteFader.FadeSprite(spriteRenderer, targetColor, duration, Vector2.zero, delegate {
|
||
|
if (waitUntilFinished)
|
||
|
{
|
||
10 years ago
|
cameraController.waiting = false;
|
||
10 years ago
|
Continue();
|
||
|
}
|
||
|
});
|
||
|
|
||
|
if (!waitUntilFinished)
|
||
|
{
|
||
|
Continue();
|
||
|
}
|
||
|
}
|
||
10 years ago
|
|
||
|
public override string GetSummary()
|
||
|
{
|
||
|
if (spriteRenderer == null)
|
||
|
{
|
||
|
return "Error: No sprite renderer selected";
|
||
|
}
|
||
|
|
||
|
return spriteRenderer.name + " to " + targetColor.ToString();
|
||
|
}
|
||
10 years ago
|
|
||
|
public override Color GetButtonColor()
|
||
|
{
|
||
|
return new Color32(221, 184, 169, 255);
|
||
|
}
|
||
10 years ago
|
}
|
||
|
|
||
|
}
|