using System; using System.Runtime.CompilerServices; using BansheeEngine; namespace BansheeEditor { public sealed class GUIResourceField : GUIElement { public delegate void OnChangedDelegate(Resource newValue); public event OnChangedDelegate OnChanged; public Resource Value { get { Resource value; Internal_GetValue(mCachedPtr, out value); return value; } set { Internal_SetValue(mCachedPtr, value); } } public GUIResourceField(Type type, GUIContent title, int titleWidth = 100, string style = "", params GUIOption[] options) { Internal_CreateInstance(this, type, title, titleWidth, style, options, true); } public GUIResourceField(Type type, string style = "", params GUIOption[] options) { Internal_CreateInstance(this, type, null, 0, style, options, false); } public void SetTint(Color color) { Internal_SetTint(mCachedPtr, color); } private void DoOnChanged(Resource newValue) { if (OnChanged != null) OnChanged(newValue); } [MethodImpl(MethodImplOptions.InternalCall)] private static extern void Internal_CreateInstance(GUIResourceField instance, Type type, GUIContent title, int titleWidth, string style, GUIOption[] options, bool withTitle); [MethodImpl(MethodImplOptions.InternalCall)] private static extern void Internal_GetValue(IntPtr nativeInstance, out Resource value); [MethodImpl(MethodImplOptions.InternalCall)] private static extern void Internal_SetValue(IntPtr nativeInstance, Resource value); [MethodImpl(MethodImplOptions.InternalCall)] private static extern void Internal_SetTint(IntPtr nativeInstance, Color color); } }