Add Play Scene Tool

This commit is contained in:
admin committed 2026-06-29 12:17:25 +02:00
1 parent fd869c9cf8
commit db10eef525
7 files changed
+473

No files matched your search

+45
View File
@@ -0,0 +1,45 @@
#if UNITY_EDITOR
using UnityEditor;
#endif
using UnityEngine;
namespace Chameleon
{
[ExecuteAlways]
[AddComponentMenu("Tools/Chameleon/Default Parent (Editor)")]
public class DefaultParentForEditor : MonoBehaviour
{
#if UNITY_EDITOR
static DefaultParentForEditor selection;
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
static void Init() => selection = null;
void Update()
{
if (Application.isPlaying)
return;
var activeGameObject = Selection.activeGameObject;
if (activeGameObject != gameObject)
return;
if (!activeGameObject.TryGetComponent(out DefaultParentForEditor defaultParent))
return;
if (selection && selection != defaultParent)
{
selection = null;
EditorUtility.ClearDefaultParentObject();
}
if (!selection)
{
selection = this;
EditorUtility.SetDefaultParentObject(gameObject);
}
}
#endif
}
}