// --------------------------------------------------------------------------------------------------------------------
//
// Copyright (c) VRMADA, All rights reserved.
//
// --------------------------------------------------------------------------------------------------------------------
using UltimateXR.Core;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace UltimateXR.Extensions.Unity
{
///
/// extensions.
///
public static class BehaviourExt
{
#region Public Methods
///
/// Controls the enabled state, using serialized properties when called from the Unity Editor to support Undo
/// correctly.
///
/// The behaviour to enable or disable
/// Whether to enable the behaviour or disable it
public static void SetEnabled(this Behaviour self, bool enabled)
{
#if UNITY_EDITOR
if (Application.isEditor && !Application.isPlaying)
{
SerializedObject so = new SerializedObject(self);
so.FindProperty(UxrConstants.Editor.PropertyBehaviourEnabled).boolValue = enabled;
so.ApplyModifiedProperties();
return;
}
#endif
self.enabled = enabled;
}
#endregion
}
}