|
|
|
@ -1,4 +1,5 @@
|
|
|
|
|
using UnityEngine; |
|
|
|
|
using UnityEngine.Serialization; |
|
|
|
|
using System; |
|
|
|
|
using System.Collections; |
|
|
|
|
|
|
|
|
@ -8,13 +9,17 @@ namespace Fungus
|
|
|
|
|
"Show Sprite", |
|
|
|
|
"Makes a sprite visible / invisible by setting the color alpha.")] |
|
|
|
|
[AddComponentMenu("")] |
|
|
|
|
public class ShowSprite : Command |
|
|
|
|
public class ShowSprite : Command, ISerializationCallbackReceiver |
|
|
|
|
{ |
|
|
|
|
#region Obsolete Properties |
|
|
|
|
[HideInInspector] [FormerlySerializedAs("visible")] public bool visibleOLD; |
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
[Tooltip("Sprite object to be made visible / invisible")] |
|
|
|
|
public SpriteRenderer spriteRenderer; |
|
|
|
|
|
|
|
|
|
[Tooltip("Make the sprite visible or invisible")] |
|
|
|
|
public bool visible = true; |
|
|
|
|
public BooleanData _visible = new BooleanData(false); |
|
|
|
|
|
|
|
|
|
[Tooltip("Affect the visibility of child sprites")] |
|
|
|
|
public bool affectChildren = true; |
|
|
|
@ -28,12 +33,12 @@ namespace Fungus
|
|
|
|
|
SpriteRenderer[] children = spriteRenderer.gameObject.GetComponentsInChildren<SpriteRenderer>(); |
|
|
|
|
foreach (SpriteRenderer sr in children) |
|
|
|
|
{ |
|
|
|
|
SetSpriteAlpha(sr, visible); |
|
|
|
|
SetSpriteAlpha(sr, _visible.Value); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
SetSpriteAlpha(spriteRenderer, visible); |
|
|
|
|
SetSpriteAlpha(spriteRenderer, _visible.Value); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -54,13 +59,30 @@ namespace Fungus
|
|
|
|
|
return "Error: No sprite renderer selected"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return spriteRenderer.name + " to " + (visible ? "visible" : "invisible"); |
|
|
|
|
return spriteRenderer.name + " to " + (_visible.Value ? "visible" : "invisible"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public override Color GetButtonColor() |
|
|
|
|
{ |
|
|
|
|
return new Color32(221, 184, 169, 255); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// |
|
|
|
|
// ISerializationCallbackReceiver implementation |
|
|
|
|
// |
|
|
|
|
|
|
|
|
|
public virtual void OnBeforeSerialize() |
|
|
|
|
{} |
|
|
|
|
|
|
|
|
|
public virtual void OnAfterDeserialize() |
|
|
|
|
{ |
|
|
|
|
if (visibleOLD != default(bool)) |
|
|
|
|
{ |
|
|
|
|
_visible.Value = visibleOLD; |
|
|
|
|
visibleOLD = default(bool); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |