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.
77 lines
1.6 KiB
77 lines
1.6 KiB
9 years ago
|
using UnityEngine;
|
||
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
|
||
|
namespace Fungus
|
||
|
{
|
||
|
[CommandInfo("Sprite",
|
||
|
"Set Sprite Order",
|
||
|
"Controls the render order of sprites by setting the Order In Layer property of a list of sprites.")]
|
||
|
[AddComponentMenu("")]
|
||
|
public class SetSpriteOrder : Command
|
||
|
{
|
||
|
[Tooltip("List of sprites to set the order in layer property on")]
|
||
|
public List<SpriteRenderer> targetSprites = new List<SpriteRenderer>();
|
||
|
|
||
|
[Tooltip("The order in layer value to set on the target sprites")]
|
||
|
public IntegerData orderInLayer;
|
||
|
|
||
|
public override void OnEnter()
|
||
|
{
|
||
|
foreach (SpriteRenderer spriteRenderer in targetSprites)
|
||
|
{
|
||
|
spriteRenderer.sortingOrder = orderInLayer;
|
||
|
}
|
||
|
|
||
|
Continue();
|
||
|
}
|
||
|
|
||
|
public override string GetSummary()
|
||
|
{
|
||
|
string summary = "";
|
||
|
foreach (SpriteRenderer spriteRenderer in targetSprites)
|
||
|
{
|
||
|
if (spriteRenderer == null)
|
||
|
{
|
||
|
continue;
|
||
|
}
|
||
|
|
||
|
if (summary.Length > 0)
|
||
|
{
|
||
|
summary += ", ";
|
||
|
}
|
||
|
|
||
|
summary += spriteRenderer.name;
|
||
|
}
|
||
|
|
||
|
if (summary.Length == 0)
|
||
|
{
|
||
|
return "Error: No cursor sprite selected";
|
||
|
}
|
||
|
|
||
|
return summary + " = " + orderInLayer.Value;
|
||
|
}
|
||
|
|
||
|
public override Color GetButtonColor()
|
||
|
{
|
||
|
return new Color32(235, 191, 217, 255);
|
||
|
}
|
||
|
|
||
|
public override bool IsReorderableArray(string propertyName)
|
||
|
{
|
||
|
if (propertyName == "targetSprites")
|
||
|
{
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
public override void OnCommandAdded(Block parentBlock)
|
||
|
{
|
||
|
// Add a default empty entry
|
||
|
targetSprites.Add(null);
|
||
|
}
|
||
|
}
|
||
|
}
|