67 lines
1.5 KiB
C#
67 lines
1.5 KiB
C#
|
|
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}";
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|