您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
52 行
1.3 KiB
52 行
1.3 KiB
using UnityEditor;
|
|
using UnityEngine;
|
|
|
|
namespace Unity.DemoTeam.DigitalHuman
|
|
{
|
|
[CustomEditor(typeof(SnappersHeadImporter)), CanEditMultipleObjects]
|
|
public class SnappersHeadImporterEditor : Editor
|
|
{
|
|
const string ASSETS_STRING = @"The following files will be written:
|
|
|
|
{0}_SnappersBlendShapes.cs
|
|
{0}_SnappersControllers.cs
|
|
{0}_SnappersHead.asset
|
|
{0}_SnappersHead.cs
|
|
{0}_SnappersHeadImpl.cs
|
|
|
|
(and overwritten if they already exist)";
|
|
|
|
public override void OnInspectorGUI()
|
|
{
|
|
base.OnInspectorGUI();
|
|
|
|
EditorGUILayout.Space();
|
|
|
|
var singleTarget = (targets.Length == 1);
|
|
if (singleTarget)
|
|
{
|
|
EditorGUILayout.HelpBox(string.Format(ASSETS_STRING, (target as SnappersHeadImporter).csClassPrefix), MessageType.Info);
|
|
}
|
|
else
|
|
{
|
|
EditorGUILayout.HelpBox(string.Format(ASSETS_STRING, "[Multiple Prefixes]"), MessageType.Warning);
|
|
}
|
|
|
|
if (GUILayout.Button(singleTarget ? "Generate" : "Generate all selected"))
|
|
{
|
|
for (int i = 0; i != targets.Length; i++)
|
|
{
|
|
if (EditorUtility.DisplayCancelableProgressBar("Processing...", target.name, i / (targets.Length)) == false)
|
|
{
|
|
var generator = (SnappersHeadImporter)target;
|
|
if (generator != null)
|
|
{
|
|
generator.Generate();
|
|
}
|
|
}
|
|
}
|
|
EditorUtility.ClearProgressBar();
|
|
}
|
|
}
|
|
}
|
|
}
|