// MIT License - Copyright (c) 2024 wallstop // Full license text: https://github.com/wallstop/unity-helpers/blob/main/LICENSE namespace WallstopStudios.UnityHelpers.Utils { using UnityEngine; /// /// Exposes a configurable offset from the attached transform that can also be consumed by /// sprites that expect a logical center point separate from the transform origin. /// [DisallowMultipleComponent] public sealed class CenterPointOffset : MonoBehaviour { /// /// Offset applied relative to the local scale for computing . /// public Vector2 offset = Vector2.zero; /// /// When enabled, indicates associated sprite logic should use the computed offset center. /// public bool spriteUsesOffset = true; /// /// Gets the world-space center derived from the transform position and . /// public Vector2 CenterPoint { get { Transform localTransform = transform; Vector2 scaledOffset = offset * localTransform.localScale; return (Vector2)localTransform.position + scaledOffset; } } } }