浏览代码

UI changes

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

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


using System.Linq;
using UnityEditor;
using UnityEngine.Perception.GroundTruth;
using UnityEngine.Windows;
namespace UnityEngine.Perception.Content
{

"RightUpperLeg",
"RightLowerLeg",
"RightFoot",
};
public static string[] NeededBones =
{
};
/// <summary>

{
var head = FindBodyPart("head", selection.transform);
if (savePath == string.Empty)
if (savePath == string.Empty || !Directory.Exists(savePath))
{
Debug.Log("Save file path didn't exist, defaulting to Assets folder in project!");
}
var filePath = savePath + selection.name + ".prefab";

return model;
}
static Transform FindBodyPart(string name, Transform root)
public static Transform FindBodyPart(string name, Transform root)
{
var children = new List<Transform>();
root.GetComponentsInChildren(children);

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


static string[] toolbarNames = null;
CharacterTooling m_contentTests = new CharacterTooling();
Object keypointTemplate;
UnityEngine.Object keypointTemplate;
bool checkJoints = false;
bool vaildCharacter = false;
string savePath = "Assets/";
string status = "Unknown";

if(selection != null)
{
var head = FindBodyPart("head", selection.transform);
var leftEye = FindBodyPart("leftEye", selection.transform);
var rightEye = FindBodyPart("rightEye", selection.transform);
if (head != null || leftEye != null || rightEye != null)
{
status = "Character ready to add joints";
vaildCharacter = true;
checkJoints = m_contentTests.ValidateNoseAndEars(selection);
}
else
{
status = "Missing either the head/left or right eye joint transforms!";
vaildCharacter = false;
}
}
}
void OnInspectorUpdate()

{
if (selection != null && selection.GetType() == typeof(GameObject))
{
EditorGUILayout.TextField("Selected Asset : ", selection.name);
EditorGUILayout.TextField("Selected Character : ", selection.name);
savePath = EditorGUILayout.TextField("Prefab Save Location : ", savePath);
GUILayout.Label("Keypoint Template : ", EditorStyles.whiteLargeLabel);
keypointTemplate = EditorGUILayout.ObjectField(keypointTemplate, typeof(KeypointTemplate), true, GUILayout.MaxWidth(500));

case 0:
GUILayout.Label("Character Tools", EditorStyles.whiteLargeLabel);
var checkForJoints = m_contentTests.ValidateNoseAndEars(selection);
if (checkForJoints)
status = "Joints already exist";
if (checkJoints)
{
status = "Joints already exist";
if (GUILayout.Button("Create Nose and Ears", GUILayout.Width(160)))
}
else if (!checkJoints && vaildCharacter)
if (!checkForJoints)
status = "Joints don't exist";
if (GUILayout.Button("Create Nose and Ears", GUILayout.Width(160)))
{
if (savePath == "Assets/")
apiResult = m_contentTests.CharacterCreateNose(selection, out newModel, keypointTemplate, drawFaceRays);

status = "Ear and Nose joints created";
else if (!modelValidate)
status = "Failed to create the Ear and Nose joints";
}
else if(checkForJoints)
{
status = "Joints have already been created on this Asset";
}
}

break;
}
}
else
{
GUILayout.Label("The selected assets is invalid, please select a different Game Object.", EditorStyles.boldLabel);
}
}
}
正在加载...
取消
保存