diff --git a/Assets/Fungus/Sprite/Scripts/Commands/ShowSprite.cs b/Assets/Fungus/Sprite/Scripts/Commands/ShowSprite.cs index f0c42980..68472dd0 100644 --- a/Assets/Fungus/Sprite/Scripts/Commands/ShowSprite.cs +++ b/Assets/Fungus/Sprite/Scripts/Commands/ShowSprite.cs @@ -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(); 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); + } + } } } \ No newline at end of file diff --git a/Assets/UpdatePropTest.unity b/Assets/UpdatePropTest.unity index a936e51d..b8ed0a43 100644 --- a/Assets/UpdatePropTest.unity +++ b/Assets/UpdatePropTest.unity @@ -313,6 +313,8 @@ GameObject: - 114: {fileID: 979963257} - 114: {fileID: 979963258} - 114: {fileID: 979963259} + - 114: {fileID: 979963261} + - 114: {fileID: 979963260} m_Layer: 0 m_Name: Flowchart m_TagString: Untagged @@ -346,7 +348,7 @@ MonoBehaviour: height: 859 selectedBlock: {fileID: 979963241} selectedCommands: - - {fileID: 979963259} + - {fileID: 979963260} variables: - {fileID: 979963244} - {fileID: 979963252} @@ -420,6 +422,8 @@ MonoBehaviour: - {fileID: 979963257} - {fileID: 979963258} - {fileID: 979963259} + - {fileID: 979963261} + - {fileID: 979963260} --- !u!114 &979963242 MonoBehaviour: m_ObjectHideFlags: 2 @@ -765,7 +769,48 @@ MonoBehaviour: languageCodeOLD: _languageCode: stringRef: {fileID: 0} - stringVal: ES + stringVal: +--- !u!114 &979963260 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 979963238} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 10cd462c89cb047158ccfb8a8df3f60a, type: 3} + m_Name: + m_EditorClassIdentifier: + itemId: 17 + errorMessage: + indentLevel: 0 + spriteRenderer: {fileID: 0} + visible: 0 + affectChildren: 1 +--- !u!114 &979963261 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 979963238} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: accc065c3e9a6457496f075b1bd49adc, type: 3} + m_Name: + m_EditorClassIdentifier: + itemId: 16 + errorMessage: + indentLevel: 0 + durationOLD: 0 + targetColorOLD: {r: 0, g: 0, b: 0, a: 0} + spriteRenderer: {fileID: 0} + _duration: + floatRef: {fileID: 0} + floatVal: 5 + _targetColor: + colorRef: {fileID: 0} + colorVal: {r: 0.7205882, g: 0.10067042, b: 0.10067042, a: 1} + waitUntilFinished: 1 --- !u!1 &1197120973 GameObject: m_ObjectHideFlags: 0