//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
//**************** Copyright (c) 2016 Marko Pintera (marko.pintera@gmail.com). All rights reserved. **********************//
using System;
using System.Runtime.CompilerServices;
using bs;
namespace bs.Editor
{
/** @addtogroup Inspector
* @{
*/
///
/// Contains utility methods relating to inspector window.
///
public class InspectorUtility
{
///
/// Creates an inspector capable of displaying GUI elements for an object of the provided type.
///
/// Type of the object that will be displayed in the inspector.
/// Custom user defined inspector if it exists for the provided type, or the generic inspector.
public static Inspector GetInspector(Type type)
{
Inspector customInspector = Internal_GetCustomInspector(type);
if (customInspector != null)
return customInspector;
return new GenericInspector();
}
///
/// Gets an implementation for the specified type. This only searches custom user
/// defined implementations, not the built-in ones.
///
/// Type of the object to find an for.
/// Implementation of capable of display contents of the provided type,
/// or null if one wasn't found.
public static Type GetCustomInspectable(Type type)
{
Type customInspectable = Internal_GetCustomInspectable(type);
if (customInspectable != null)
return customInspectable;
return null;
}
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern Inspector Internal_GetCustomInspector(Type type);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern Type Internal_GetCustomInspectable(Type type);
}
///
/// States an inspectable object can be in. Higher states override lower states.
///
[Flags]
public enum InspectableState
{
/// Object was not modified this frame.
NotModified,
/// Object is currently being modified.
ModifyInProgress = 1,
/// Object was modified and modifications were confirmed.
Modified = 3
}
/** @} */
}