// --------------------------------------------------------------------------------------------------------------------
//
// Copyright (c) VRMADA, All rights reserved.
//
// --------------------------------------------------------------------------------------------------------------------
using UnityEditor;
using UnityEngine;
namespace UltimateXR.Editor
{
public static partial class UxrEditorUtils
{
#region Public Methods
///
/// Gets or adds a component. If the component is added, it's done using Undo.AddComponent<>.
///
/// Target GameObject
/// Type of component to get or add
/// The component
public static T GetOrAddComponent(GameObject gameObject) where T : Component
{
T component = gameObject.GetComponent();
if (component == null)
{
component = Undo.AddComponent(gameObject);
}
return component;
}
#endregion
}
}