|
|
@ -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 |
|
|
|