您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

41 行
1.0 KiB

using UnityEditor;
using UnityEngine;
namespace Unity.DemoTeam.DigitalHuman
{
[CustomEditor(typeof(PrefabTransformHierarchy))]
public class PrefabTransformHierarchyEditor : Editor
{
public override void OnInspectorGUI()
{
var root = target as PrefabTransformHierarchy;
if (root != null)
{
if (GUILayout.Button("Revert transform hierarchy"))
{
if (Application.isPlaying)
{
root.LoadDefaults();
}
else
{
var transforms = root.GetComponentsInChildren<Transform>(includeInactive: true);
for (int i = 0; i != transforms.Length; i++)
{
EditorUtility.DisplayProgressBar("Reverting transforms ...", (i + 1) + " / " + transforms.Length, (float)i / transforms.Length);
var transform = transforms[i];
if (transform != null)
{
PrefabUtility.RevertObjectOverride(transforms[i], InteractionMode.UserAction);
}
}
}
EditorUtility.ClearProgressBar();
EditorUtility.SetDirty(root);
}
}
}
}
}