44 lines
1.3 KiB
C#
44 lines
1.3 KiB
C#
using UnityEditor;
|
|
using UnityEngine;
|
|
|
|
public class UIHandleMain : UIHandle
|
|
{
|
|
public static UIHandleMain CreateAsChild(ObjectContainer owner)
|
|
{
|
|
var handle = CreateAsChild<UIHandleMain>(owner.transform);
|
|
handle.Init(owner).SetColor(Color.yellow).SetScale(1.5f);
|
|
return handle;
|
|
}
|
|
|
|
public override UIHandle Init(ObjectContainer owner)
|
|
{
|
|
base.Init(owner);
|
|
|
|
Popup.AddButton("Reset All", TransformResetAll);
|
|
Popup.AddButton("Reset Position", TransformResetPosition);
|
|
Popup.AddButton("Reset Rotation", TransformResetRotation);
|
|
Popup.AddButton("Reset Scale", TransformResetScale);
|
|
Popup.AddButton("Reset Children", ResetBones);
|
|
Popup.AddButton("Delete", () => Destroy(Owner));
|
|
|
|
return this;
|
|
}
|
|
|
|
public void ResetBones()
|
|
{
|
|
using (var context = new KeyframeToggleContext(Owner, false))
|
|
{
|
|
foreach (var bone in Owner.GetComponentsInChildren<UIHandle>())
|
|
{
|
|
bone.TransformResetAll();
|
|
}
|
|
}
|
|
Owner.SetKeyframe();
|
|
}
|
|
|
|
protected override bool ShouldBeHidden()
|
|
{
|
|
return _forceDisplayOff || !HandleManager.Instance.EnabledHandles.Contains(SerializableBone.BoneTags.Root);
|
|
}
|
|
}
|