// =====================================================================
// Copyright 2013-2017 Fluffy Underware
// All rights reserved
//
// http://www.fluffyunderware.com
// =====================================================================
using System;
using UnityEngine;
using UnityEditor;
using System.Reflection;
using System.Collections.Generic;
using FluffyUnderware.DevTools.Extensions;
using System.Collections;
using Object = UnityEngine.Object;
namespace FluffyUnderware.DevToolsEditor
{
public static class DTEditorUtility
{
///
/// Does Unity use the new editor's UI?
///
public const bool UsesNewEditorUI
#if UNITY_2019_3_OR_NEWER //new UI
= true;
#else
= false;
#endif
public static Camera ActiveCamera
{
get
{
return (SceneView.currentDrawingSceneView) ? SceneView.currentDrawingSceneView.camera : Camera.current;
}
}
public static bool DragDropTypeMatch(System.Type type)
{
foreach (Object go in DragAndDrop.objectReferences)
{
if (go is GameObject)
{
if (type.IsSubclassOf(typeof(Component)) == false)
return false;
if (((GameObject)go).GetComponent(type) == null)
return false;
}
else if (go.GetType() != type)
return false;
}
return true;
}
public static bool DragDropTypeMatch() where T : Object
{
return DragDropTypeMatch(typeof(T));
}
public static Object[] DragDropGetObjectsOfType(System.Type type)
{
if (type.IsArrayOrList())
return new Object[0];
List