I am attempting to generate bounding box colliders at run-time rather than using the in-game skeleton utility generator.
Here's the code I am using:
public static BoundingBoxFollower CreateBoundingBoxFollower(GameObject g, string BoundingBoxName, SkeletonAnimation skeletonAnim = null, string Prefix = "[BoundingBox] ")
{
// [ABrazie]: This code should be kept sync'd with the code in SkeletonUtilityBone.cs
if (skeletonAnim == null)
skeletonAnim = g.GetComponentInChildren<SkeletonAnimation>();
var skeleton = skeletonAnim.Skeleton;
int slotCount = skeleton.Slots.Count;
Skin skin = skeleton.Skin;
if (skeleton.Skin == null)
skin = skeleton.Data.DefaultSkin;
Slot slot = null;
// Removed the check for a bounding box as it wasn't necessary here
//BoundingBoxAttachment box = null;
var currentSkinName = skin.Name;
for (int i = 0; i < slotCount; i++)
{
if (skeleton.Slots.Items[i].Data.Name == BoundingBoxName)
{
slot = skeleton.Slots.Items[i];
break;
}
}
if (slot == null)
{
Debug.LogErrorFormat("Unable to find a hitbox slot of name {0} in skeleton {1} (Skin: {2})", BoundingBoxName, skeletonAnim.Skeleton.Data.Name, currentSkinName);
return null;
}
var hitboxName = Prefix + slot.Data.Name;
var child = g.transform.Search(hitboxName);
if (child == null)
{
child = new GameObject(hitboxName).transform;
child.SetParent(skeletonAnim.transform, false);
child.gameObject.layer = g.gameObject.layer;
}
var renderer = skeletonAnim.GetComponent<SkeletonRenderer>();
var bbf = child.gameObject.GetOrAddComponent<BoundingBoxFollower>();
bbf.slotName = slot.Data.Name;
bbf.isTrigger = true;
bbf.skeletonRenderer = renderer;
//bbf.HandleReset (null);
var boneFollower = child.gameObject.GetOrAddComponent<BoneFollower>();
boneFollower.boneName = slot.Data.BoneData.Name;
boneFollower.skeletonRenderer = renderer;
boneFollower.Initialize();
return bbf;
}
This worked fine before the 3.5 update, with the colliders appearing in the correct place and orientation.
Now, they are being created with an extra offset and rotation that doesn't seem to be necessary.
Here's an image:
The properly centered one is generated by SkeletonUtility, the 'floating' one is created by the above code. What step am I missing?

If I reset the transforms on the object, it appears in the correct location and scale:

After zero'ing out, it's in the right place.
