23 lines
599 B
C#
23 lines
599 B
C#
using System.Linq;
|
|
|
|
namespace SWB.Base;
|
|
|
|
public class ModelUtil
|
|
{
|
|
public static void ParentToBone( GameObject gameObject, SkinnedModelRenderer target, string bone )
|
|
{
|
|
var targetBone = target.Model.Bones.AllBones.FirstOrDefault( b => b.Name == bone );
|
|
if ( targetBone is null )
|
|
{
|
|
Log.Error( $"Could not find bone '{bone}' on {target}" );
|
|
return;
|
|
}
|
|
|
|
var holdBoneGo = target.GetBoneObject( targetBone );
|
|
Log.Info(holdBoneGo);
|
|
gameObject.SetParent( holdBoneGo );
|
|
gameObject.WorldPosition = holdBoneGo.WorldPosition;
|
|
gameObject.WorldRotation = holdBoneGo.WorldRotation;
|
|
}
|
|
}
|