Browse Source

Edited property names and descriptions on Set Sprite and Set UI Image commands

master
Chris Gregan 6 years ago
parent
commit
c8526d55da
  1. 26
      Assets/Fungus/Scripts/Commands/SetSprite.cs
  2. 32
      Assets/Fungus/Scripts/Commands/SetUIImage.cs

26
Assets/Fungus/Scripts/Commands/SetSprite.cs

@ -13,24 +13,24 @@ namespace Fungus
/// </summary> /// </summary>
[CommandInfo("Sprite", [CommandInfo("Sprite",
"Set Sprite", "Set Sprite",
"Changes the sprite of a SpriteRenderer.")] "Changes the sprite property of a list of Sprite Renderers.")]
[AddComponentMenu("")] [AddComponentMenu("")]
public class SetSprite : Command public class SetSprite : Command
{ {
[Tooltip("List of sprites to set the sprite property on")] [Tooltip("List of sprites to set the sprite property on")]
[SerializeField] protected List<SpriteRenderer> targetSprites = new List<SpriteRenderer>(); [SerializeField] protected List<SpriteRenderer> spriteRenderers = new List<SpriteRenderer>();
[Tooltip("The sprite set on the target sprites")] [Tooltip("The sprite set on the target sprite renderers")]
[SerializeField] protected Sprite spriteRendererSprite; [SerializeField] protected Sprite sprite;
#region Public members #region Public members
public override void OnEnter() public override void OnEnter()
{ {
for (int i = 0; i < targetSprites.Count; i++) for (int i = 0; i < spriteRenderers.Count; i++)
{ {
var spriteRenderer = targetSprites[i]; var spriteRenderer = spriteRenderers[i];
spriteRenderer.sprite = spriteRendererSprite; spriteRenderer.sprite = sprite;
} }
Continue(); Continue();
@ -39,9 +39,9 @@ namespace Fungus
public override string GetSummary() public override string GetSummary()
{ {
string summary = ""; string summary = "";
for (int i = 0; i < targetSprites.Count; i++) for (int i = 0; i < spriteRenderers.Count; i++)
{ {
var spriteRenderer = targetSprites[i]; var spriteRenderer = spriteRenderers[i];
if (spriteRenderer == null) if (spriteRenderer == null)
{ {
continue; continue;
@ -55,10 +55,10 @@ namespace Fungus
if (summary.Length == 0) if (summary.Length == 0)
{ {
return "Error: No cursor sprite selected"; return "Error: No sprite selected";
} }
return summary + " = " + spriteRendererSprite; return summary + " = " + sprite;
} }
public override Color GetButtonColor() public override Color GetButtonColor()
@ -68,7 +68,7 @@ namespace Fungus
public override bool IsReorderableArray(string propertyName) public override bool IsReorderableArray(string propertyName)
{ {
if (propertyName == "targetSprites") if (propertyName == "spriteRenderers")
{ {
return true; return true;
} }
@ -79,7 +79,7 @@ namespace Fungus
public override void OnCommandAdded(Block parentBlock) public override void OnCommandAdded(Block parentBlock)
{ {
// Add a default empty entry // Add a default empty entry
targetSprites.Add(null); spriteRenderers.Add(null);
} }
#endregion #endregion

32
Assets/Fungus/Scripts/Commands/SetUIImage.cs

@ -8,28 +8,28 @@ using UnityEngine.UI;
namespace Fungus namespace Fungus
{ {
/// <summary> /// <summary>
/// Changes the Image on a UI-element. /// Changes the Image property on a UI element.
/// </summary> /// </summary>
[CommandInfo("UI", [CommandInfo("UI",
"Set UI-Image", "Set UI Image",
"Changes the Image of a UI-Element.")] "Changes the Image property of a list of UI Images.")]
[AddComponentMenu("")] [AddComponentMenu("")]
public class SetUIImage : Command public class SetUIImage : Command
{ {
[Tooltip("List of UI-objects to set the image property on")] [Tooltip("List of UI Images to set the source image property on")]
[SerializeField] protected List<Image> targetImages = new List<Image>(); [SerializeField] protected List<Image> images = new List<Image>();
[Tooltip("The sprite set on the target Image")] [Tooltip("The sprite set on the source image property")]
[SerializeField] protected Sprite imageSprite; [SerializeField] protected Sprite sprite;
#region Public members #region Public members
public override void OnEnter() public override void OnEnter()
{ {
for (int i = 0; i < targetImages.Count; i++) for (int i = 0; i < images.Count; i++)
{ {
var targetImage = targetImages[i]; var image = images[i];
targetImage.sprite = imageSprite; image.sprite = sprite;
} }
Continue(); Continue();
@ -38,9 +38,9 @@ namespace Fungus
public override string GetSummary() public override string GetSummary()
{ {
string summary = ""; string summary = "";
for (int i = 0; i < targetImages.Count; i++) for (int i = 0; i < images.Count; i++)
{ {
var targetImage = targetImages[i]; var targetImage = images[i];
if (targetImage == null) if (targetImage == null)
{ {
continue; continue;
@ -54,10 +54,10 @@ namespace Fungus
if (summary.Length == 0) if (summary.Length == 0)
{ {
return "Error: No cursor sprite selected"; return "Error: No sprite selected";
} }
return summary + " = " + imageSprite; return summary + " = " + sprite;
} }
public override Color GetButtonColor() public override Color GetButtonColor()
@ -67,7 +67,7 @@ namespace Fungus
public override bool IsReorderableArray(string propertyName) public override bool IsReorderableArray(string propertyName)
{ {
if (propertyName == "targetImages") if (propertyName == "images")
{ {
return true; return true;
} }
@ -78,7 +78,7 @@ namespace Fungus
public override void OnCommandAdded(Block parentBlock) public override void OnCommandAdded(Block parentBlock)
{ {
// Add a default empty entry // Add a default empty entry
targetImages.Add(null); images.Add(null);
} }
#endregion #endregion

Loading…
Cancel
Save