Add ultimate xr

This commit is contained in:
2024-08-06 21:58:35 +02:00
parent 864033bf10
commit 7165bacd9d
3952 changed files with 2162037 additions and 35 deletions

View File

@@ -0,0 +1,44 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="BehaviourExt.cs" company="VRMADA">
// Copyright (c) VRMADA, All rights reserved.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------
using UltimateXR.Core;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace UltimateXR.Extensions.Unity
{
/// <summary>
/// <see cref="Component" /> extensions.
/// </summary>
public static class BehaviourExt
{
#region Public Methods
/// <summary>
/// Controls the enabled state, using serialized properties when called from the Unity Editor to support Undo
/// correctly.
/// </summary>
/// <param name="self">The behaviour to enable or disable</param>
/// <param name="enabled">Whether to enable the behaviour or disable it</param>
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
}
}