浏览代码

fixing the bone validation

/validation-tool
Wesley Mareovich Smith 4 年前
当前提交
cd067c21
共有 2 个文件被更改,包括 45 次插入9 次删除
  1. 46
      com.unity.perception/Editor/Character/CharacterToolingLibrary.cs
  2. 8
      com.unity.perception/Editor/Character/CharacterToolingUI.cs

46
com.unity.perception/Editor/Character/CharacterToolingLibrary.cs


return model;
}
/// <summary>
/// Finds that name of the bone Transform that matches the target string
/// </summary>
/// <param name="name">Target name of the bone that we need to find</param>
/// <param name="root">Target selection transform</param>
/// <returns>Will return the target Human bone as a Transform, or returns null</returns>
public static Transform FindBodyPart(string name, Transform root)
{
var children = new List<Transform>();

return null;
}
/// <summary>
/// Finds that Human Bone in the Avatar of the animator of the character
/// </summary>
/// <param name="selection">Target Character that we need to find a part on</param>
/// <param name="humanBone">Target Human Body Bone</param>
/// <returns>Will return the target Human bone as a Transform, or returns null</returns>
var targetBone = animator.GetBoneTransform(humanBone);
if (animator != null)
{
var targetBone = animator.GetBoneTransform(humanBone);
if (targetBone != null)
return targetBone;
else
return selection.transform;
if (targetBone != null)
return targetBone;
}
return null;
}
/// <summary>
/// Will ensure the target game object's avatar has the target Human Bone
/// </summary>
/// <param name="selection">Target game object</param>
/// <param name="humanBone">Target human bone we are sreaching for in the avatar of the selected game object</param>
/// <returns>Return true if the bone was found, or false if the bone is missing</returns>
public static bool ValidateBodyPart(GameObject selection, HumanBodyBones humanBone)
{
var animator = selection.GetComponentInChildren<Animator>();
if (animator != null)
{
var targetBone = animator.GetBoneTransform(humanBone);
if (targetBone != null)
return true;
}
return false;
}
/// <summary>

8
com.unity.perception/Editor/Character/CharacterToolingUI.cs


if(m_Selection != null)
{
var head = CharacterValidation.FindBodyPart(m_Selection, HumanBodyBones.Head);
var leftEye = CharacterValidation.FindBodyPart(m_Selection, HumanBodyBones.LeftEye);
var rightEye = CharacterValidation.FindBodyPart(m_Selection, HumanBodyBones.RightEye);
var head = CharacterValidation.ValidateBodyPart(m_Selection, HumanBodyBones.Head);
var leftEye = CharacterValidation.ValidateBodyPart(m_Selection, HumanBodyBones.LeftEye);
var rightEye = CharacterValidation.ValidateBodyPart(m_Selection, HumanBodyBones.RightEye);
if (head != m_Selection.transform || leftEye != m_Selection.transform || rightEye != m_Selection.transform)
if (head && leftEye && rightEye )
{
m_Status = "Character ready to add joints";
m_VaildCharacter = true;

正在加载...
取消
保存