该项目的目的是同时测试和演示来自 Unity DOTS 技术堆栈的多个新包。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

60 行
1.7 KiB

using System;
using Unity.Animation;
using Unity.Entities;
[Serializable]
public struct BoneReference
{
public static BoneReference Default => new BoneReference() { BoneIndex = -1};
public Unity.Animation.Hybrid.RigComponent RigAsset;
public int BoneIndex;
}
public struct RuntimeBoneReference : IEquatable<RuntimeBoneReference>
{
public static RuntimeBoneReference Default => new RuntimeBoneReference() { BoneIndex = -1};
public BlobAssetReference<RigDefinition> ReferenceRig;
public int BoneIndex;
public bool Equals(RuntimeBoneReference other)
{
return other.BoneIndex == BoneIndex &&
other.ReferenceRig.Value.GetHashCode() == ReferenceRig.Value.GetHashCode();
}
}
[Serializable]
public class BoneReferenceAuthoring
{
public RigDefinitionAsset RigAsset;
public String BoneName;
#if UNITY_EDITOR
// public BoneReference GetBoneReference()
// {
// var skeleton = RigAsset.GetComponent<Skeleton>();
// GameDebug.Assert(skeleton != null, "Rig definition has no skeleton component. It is required");
//
// var boneRef = new BoneReference();
// var assetPath = AssetDatabase.GetAssetPath(RigAsset.gameObject);
// var assetGUID = AssetDatabase.AssetPathToGUID(assetPath);
// boneRef.RigAsset = new WeakAssetReference(assetGUID);
// boneRef.BoneIndex = -1;
//
// for(int i=0;i<skeleton.Bones.Length;i++)
// {
// if(skeleton.Bones[i].name == BoneName)
// {
// boneRef.BoneIndex = i;
// break;
// }
// }
//
// if(boneRef.BoneIndex == -1)
// GameDebug.LogError("Failed to map bone reference to valid bone");
//
// return boneRef;
// }
#endif
}