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.
43 lines
862 B
43 lines
862 B
10 years ago
|
using UnityEngine;
|
||
|
using System;
|
||
|
using System.Collections;
|
||
|
|
||
10 years ago
|
namespace Fungus
|
||
10 years ago
|
{
|
||
|
[CommandInfo("Sprite",
|
||
|
"Show Sprite",
|
||
|
"Makes a sprite visible / invisible by setting the color alpha.")]
|
||
10 years ago
|
public class ShowSprite : Command
|
||
10 years ago
|
{
|
||
|
public SpriteRenderer spriteRenderer;
|
||
|
public bool visible = true;
|
||
|
|
||
|
public override void OnEnter()
|
||
|
{
|
||
|
if (spriteRenderer != null)
|
||
|
{
|
||
|
Color spriteColor = spriteRenderer.color;
|
||
|
spriteColor.a = visible ? 1f : 0f;
|
||
|
spriteRenderer.color = spriteColor;
|
||
|
}
|
||
|
|
||
|
Continue();
|
||
|
}
|
||
|
|
||
|
public override string GetSummary()
|
||
|
{
|
||
|
if (spriteRenderer == null)
|
||
|
{
|
||
|
return "Error: No sprite renderer selected";
|
||
|
}
|
||
|
|
||
|
return spriteRenderer.name + " to " + (visible ? "visible" : "invisible");
|
||
|
}
|
||
|
|
||
|
public override Color GetButtonColor()
|
||
|
{
|
||
|
return new Color32(221, 184, 169, 255);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|