For what it's worth, here's what I puzzled out for C# with the current API.
//
---
private float[] m_boundVerts; // re-used buffer for gathering vertex, can make static if not using mutliple threads
private Bounds getBounds( Vector3 translation )
{
Bounds bounds = new Bounds( translation, Vector3.zero );
if (m_skeleton != null)
{
float xMin = float.MaxValue;
float xMax = float.MinValue;
float yMin = float.MaxValue;
float yMax = float.MinValue;
// create vert workspace if needed, this is to avoid creating garbage since even a
// fixed size array is on the heap
if (m_boundVerts == null)
{
m_boundVerts = new float[ 8 ];
}
// go thorugh all slots
for (int i = 0; i < m_skeleton.Slots.Count; ++i)
{
Slot slot = m_skeleton.Slots[ i ];
Attachment attachment = slot.Attachment;
if (attachment != null)
{
RegionAttachment imageRegion = attachment as RegionAttachment;
if (imageRegion != null)
{
imageRegion.ComputeWorldVertices( translation.x, translation.y, slot.Bone, m_boundVerts );
for (int j = 0; j < m_boundVerts.Length; j += 2)
{
xMin = Mathf.Min( xMin, m_boundVerts[ j ] );
yMin = Mathf.Min( yMin, m_boundVerts[ j + 1 ] );
xMax = Mathf.Max( xMax, m_boundVerts[ j ] );
yMax = Mathf.Max( yMax, m_boundVerts[ j + 1 ] );
}
}
}
}
// adjust bounds
bounds.min = new Vector3( xMin, yMin, translation.z );
bounds.max = new Vector3( xMax, yMax, translation.z );
}
return bounds;
}
//
---
// IDrawable
// get local bounds
public Bounds DrawableLocalBounds()
{
return getBounds( Vector3.zero );
}
//
---
// IDrawable
// get world bounds
public Bounds DrawableWorldBounds()
{
return getBounds( this.transform.position );
}