33 lines
1.2 KiB
C#
33 lines
1.2 KiB
C#
using UnityEngine;
|
|
|
|
namespace Utils
|
|
{
|
|
/// <summary>
|
|
/// Utility methods for working with SpriteRenderers.
|
|
/// </summary>
|
|
public static class AppleHillsUtils
|
|
{
|
|
/// <summary>
|
|
/// Copies all relevant visual properties from one SpriteRenderer to another.
|
|
/// </summary>
|
|
/// <param name="from">The source SpriteRenderer.</param>
|
|
/// <param name="to">The target SpriteRenderer.</param>
|
|
public static void CopySpriteRendererProperties(SpriteRenderer from, SpriteRenderer to)
|
|
{
|
|
if (from == null || to == null) return;
|
|
to.sprite = from.sprite;
|
|
to.color = from.color;
|
|
to.flipX = from.flipX;
|
|
to.flipY = from.flipY;
|
|
to.sharedMaterial = from.sharedMaterial; // Use sharedMaterial instead of material to avoid instantiation in edit mode
|
|
to.drawMode = from.drawMode;
|
|
to.size = from.size;
|
|
to.maskInteraction = from.maskInteraction;
|
|
to.sortingLayerID = from.sortingLayerID;
|
|
to.sortingOrder = from.sortingOrder;
|
|
to.enabled = true;
|
|
to.transform.localScale = from.transform.localScale;
|
|
}
|
|
}
|
|
}
|