@tools making scene dirty

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By rakkarage

Is there something like this (DrivenRectTransformTracker) from unity for godot.
For when editor ‘tools’ change variables that are not meant to be serialized?

I have a script that orients a texture rect based on orientation and dimensions of screen…
If I make it a @tool so it runs in editor too, it constantly dirties the scene…

not a huge deal since i can easily discard those changes or make it not a tool

Probably not… just wondering. Maybe a better way to do it? Thanks

Here is how i was using it

using UnityEngine;
using UnityEngine.UI;
namespace Test
{
	[ExecuteInEditMode]
	[RequireComponent(typeof(Image))]
	public class Background : MonoBehaviour
	{
		Transform _t;
		DrivenRectTransformTracker _driven;
		Image _image;
		void Awake()
		{
			_t = transform;
			_driven = new DrivenRectTransformTracker();
			_driven.Clear();
			_driven.Add(this, _t as RectTransform,
				DrivenTransformProperties.Scale | DrivenTransformProperties.Rotation);
			_image = GetComponent<Image>();
		}
		void OnEnable()
		{
			Orientation.OnChanged += OrientationChanged;
			OrientationChanged();
		}
		void OnDisable()
		{
			Orientation.OnChanged -= OrientationChanged;
			_driven.Clear();
		}
		void OrientationChanged()
		{
			_driven.Clear();
			_driven.Add(this, _t as RectTransform,
				DrivenTransformProperties.Scale | DrivenTransformProperties.Rotation);
			if (Screen.width > Screen.height)
			{
				_t.localScale = new Vector3(Screen.height / _image.preferredWidth, Screen.width / _image.preferredHeight, 1);
				_t.localRotation = Quaternion.Euler(0.0f, 0.0f, 90.0f);
			}
			else
			{
				_t.localScale = new Vector3(Screen.width / _image.preferredWidth, Screen.height / _image.preferredHeight, 1);
				_t.localRotation = Quaternion.identity;
			}
		}
	}
}