Files
BABA_YAGA/Packages/app.rive.rive-unity/Runtime/Component.cs

67 lines
1.5 KiB
C#
Raw Permalink Normal View History

2026-05-19 17:39:03 +07:00
using UnityEngine;
using System;
using System.Runtime.InteropServices;
namespace Rive
{
/// <summary>
/// Represents a Component of a Rive Artboard.
/// </summary>
[Obsolete("Component is deprecated and will be removed in a future release. Please use Databinding instead.")]
public class Component
{
private readonly IntPtr m_nativeComponent;
internal IntPtr NativeComponent
{
get { return m_nativeComponent; }
}
internal Component(IntPtr nativeComponent)
{
m_nativeComponent = nativeComponent;
}
~Component()
{
unrefArtboardComponent(m_nativeComponent);
}
public AABB ComputeBounds()
{
return componentBounds(m_nativeComponent);
}
#region Native Methods
[DllImport(NativeLibrary.name)]
internal static extern void unrefArtboardComponent(IntPtr component);
[DllImport(NativeLibrary.name)]
internal static extern AABB componentBounds(IntPtr component);
#endregion
}
}
[StructLayout(LayoutKind.Sequential)]
public struct AABB
{
public float minX;
public float minY;
public float maxX;
public float maxY;
public AABB(float minX, float minY, float maxX, float maxY)
{
this.minX = minX;
this.minY = minY;
this.maxX = maxX;
this.maxY = maxY;
}
public override string ToString()
{
return $"minX: {minX}, minY: {minY}, maxX: {maxX}, maxY: {maxY}";
}
}