From d4fe850bd20de6795f8cdcb69dbf5a239fb80b96 Mon Sep 17 00:00:00 2001 From: Crous <150693998+CCrous@users.noreply.github.com> Date: Tue, 22 Apr 2025 01:50:08 +0800 Subject: [PATCH] add unity editor undo --- Advanced MER tools/AutoScaler.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Advanced MER tools/AutoScaler.cs b/Advanced MER tools/AutoScaler.cs index c46c209..764aed0 100644 --- a/Advanced MER tools/AutoScaler.cs +++ b/Advanced MER tools/AutoScaler.cs @@ -1,7 +1,10 @@ -using System.Collections; +using System.Collections; using System.Collections.Generic; using System.Threading.Tasks; using UnityEngine; +#if UNITY_EDITOR +using UnityEditor; +#endif public class AutoScaler : MonoBehaviour { @@ -16,11 +19,16 @@ private void OnDrawGizmos() Vector3 v2 = game.eulerAngles; Vector3 v3 = game.lossyScale; pairs.Add(game, new Values(IsEmpty(game.gameObject) && ResetPos ? Vector3.zero : new Vector3(v1.x, v1.y, v1.z), - IsEmpty(game.gameObject) && ResetRot ? Vector3.zero : new Vector3(v2.x, v2.y, v2.z), + IsEmpty(game.gameObject) && ResetRot ? Vector3.zero : new Vector3(v2.x, v2.y, v2.z), IsEmpty(game.gameObject) && ResetScl ? Vector3.one : new Vector3(v3.x, v3.y, v3.z))); } List list = new List { }; list.AddRange(this.transform.GetComponentsInChildren()); + +#if UNITY_EDITOR + Undo.RecordObjects(list.ConvertAll(t => (Object)t).ToArray(), "Auto Scale Adjustments"); +#endif + list.ForEach(x => { Values values = pairs[x];