Heh, I actually deleted this and took another approach in the end as it was for a custom translation gizmo that was going to have scaling colliders, which DOTs physics doesn’t support in a nice way. I just wrote an IMGUI style gizmo instead of jumping through the various DOTs hoops.
Here’s the code anyway, though I’m not sure how helpful it will be. There was no embedded prefabs, only the root object was a prefab. The SetParent is in the previous linked thread.
public class TranslationGizmoAuthoring : MonoBehaviour, IConvertGameObjectToEntity
{
public GameObject x_axis;
public GameObject y_axis;
public GameObject z_axis;
public GameObject xz_grab_plane;
public GameObject xy_grab_plane;
public GameObject zy_grab_plane;
public void Convert (Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
{
// Children
Entity x_axis_c = conversionSystem.GetPrimaryEntity (x_axis);
Entity y_axis_c = conversionSystem.GetPrimaryEntity (y_axis);
Entity z_axis_c = conversionSystem.GetPrimaryEntity (z_axis);
Entity xz_grab_plane_c = conversionSystem.GetPrimaryEntity (xz_grab_plane);
Entity xy_grab_plane_c = conversionSystem.GetPrimaryEntity (xy_grab_plane);
Entity zy_grab_plane_c = conversionSystem.GetPrimaryEntity (zy_grab_plane);
dstManager.AddComponentData (entity, new TranslationGizmoParent
{
x_axis = x_axis_c,
y_axis = y_axis_c,
z_axis = z_axis_c,
xz_grab_plane = xz_grab_plane_c,
xy_grab_plane = xy_grab_plane_c,
zy_grab_plane = zy_grab_plane_c,
});
dstManager.AddComponentData (entity, new Unity.Transforms.Scale ());
var buffer = dstManager.AddBuffer<LinkedEntityGroup> (entity);
buffer.Add (entity);
buffer.Add (x_axis_c);
buffer.Add (y_axis_c);
buffer.Add (z_axis_c);
buffer.Add (xz_grab_plane_c);
buffer.Add (xy_grab_plane_c);
buffer.Add (zy_grab_plane_c);
TransformExtensions.SetParent (dstManager, entity, x_axis_c, x_axis.transform.localPosition, x_axis.transform.localRotation, x_axis.transform.localScale.x);
TransformExtensions.SetParent (dstManager, entity, y_axis_c, y_axis.transform.localPosition, y_axis.transform.localRotation, y_axis.transform.localScale.x);
TransformExtensions.SetParent (dstManager, entity, z_axis_c, z_axis.transform.localPosition, z_axis.transform.localRotation, z_axis.transform.localScale.x);
TransformExtensions.SetParent (dstManager, entity, xz_grab_plane_c, xz_grab_plane.transform.localPosition, xz_grab_plane.transform.localRotation, xz_grab_plane.transform.localScale.x);
TransformExtensions.SetParent (dstManager, entity, xy_grab_plane_c, xy_grab_plane.transform.localPosition, xy_grab_plane.transform.localRotation, xy_grab_plane.transform.localScale.x);
TransformExtensions.SetParent (dstManager, entity, zy_grab_plane_c, zy_grab_plane.transform.localPosition, zy_grab_plane.transform.localRotation, zy_grab_plane.transform.localScale.x);
}
}