You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
CrowdControl/Assets/3rd/Plugins/Smart-Inspector/Runtime/SmartInspector.Selection.cs

46 lines
1.3 KiB
C#

3 months ago
using System.Linq;
using UnityEngine;
namespace AV.Inspector.Runtime
{
public static partial class SmartInspector
{
public static EditorSelection Selection { get; } = new EditorSelection();
public class EditorSelection
{
public void Set(params GameObject[] gameObjects)
{
SetGameObjects(gameObjects);
}
public void Set(params Component[] components)
{
SetGameObjects(components);
}
public void Set<T>(params T[] components) where T : Component
{
SetGameObjects(components);
}
public void SetGameObjects(params GameObject[] gameObjects)
{
#if UNITY_EDITOR
UnityEditor.Selection.objects = gameObjects;
#endif
}
public void SetGameObjects(params Component[] components)
{
#if UNITY_EDITOR
UnityEditor.Selection.objects = components.Select(x => (Object)x.gameObject).ToArray();
#endif
}
public void SetObjects(params Object[] objects)
{
#if UNITY_EDITOR
UnityEditor.Selection.objects = objects;
#endif
}
}
}
}