Bläddra i källkod

Refactor: GUITextureField now accepts both sprite and normal texture
- And some other cleanup in GUIResourceField

BearishSun 6 år sedan
förälder
incheckning
8ab791f7f0

+ 2 - 0
Source/EditorCore/CMakeSources.cmake

@@ -68,6 +68,7 @@ set(BS_BANSHEEEDITOR_SRC_GUI
 	"GUI/BsGUIColorDistributionField.cpp"
 	"GUI/BsGUIColorDistributionField.cpp"
 	"GUI/BsGUIColorGradientField.cpp"
 	"GUI/BsGUIColorGradientField.cpp"
 	"GUI/BsGUITimeline.cpp"
 	"GUI/BsGUITimeline.cpp"
+	"GUI/BsGUIFieldOptions.cpp"
 )
 )
 
 
 set(BS_BANSHEEEDITOR_INC_LIBRARY
 set(BS_BANSHEEEDITOR_INC_LIBRARY
@@ -111,6 +112,7 @@ set(BS_BANSHEEEDITOR_INC_GUI
 	"GUI/BsGUIColorGradientField.h"
 	"GUI/BsGUIColorGradientField.h"
 	"GUI/BsGUITimeline.h"
 	"GUI/BsGUITimeline.h"
 	"GUI/BsGUIGraphTicks.h"
 	"GUI/BsGUIGraphTicks.h"
+	"GUI/BsGUIFieldOptions.h"
 )
 )
 
 
 set(BS_BANSHEEEDITOR_INC_UNDOREDO
 set(BS_BANSHEEEDITOR_INC_UNDOREDO

+ 1 - 0
Source/EditorCore/GUI/BsGUIFieldOptions.cpp

@@ -0,0 +1 @@
+#include "GUI/BsGUIFieldOptions.h"

+ 154 - 0
Source/EditorCore/GUI/BsGUIFieldOptions.h

@@ -0,0 +1,154 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsEditorPrerequisites.h"
+#include "GUI/BsGUIOptions.h"
+#include "GUI/BsGUIContent.h"
+
+namespace bs
+{
+	/** @addtogroup GUI-Editor
+	*  @{
+	*/
+
+	/** Provides common options for initializing a GUI element used for editor fields. */
+	struct BS_ED_EXPORT GUIFieldOptions
+	{
+		/**
+		 * Constructor for field options with a label.
+		 *
+		 * @param[in]	labelContent	Content to display in the editor field label.
+		 * @param[in]	labelWidth		Width of the label in pixels.
+		 * @param[in]	options			Options that allow you to control how is the element positioned and sized. This will
+		 *								override any similar options set by style.
+		 * @param[in]	style			Optional style to use for the element. Style will be retrieved from GUISkin of the
+		 *								GUIWidget the element is used on. If not specified default style is used.
+		 */
+		GUIFieldOptions(const GUIContent& labelContent, UINT32 labelWidth, const GUIOptions& options,
+			const String& style = StringUtil::BLANK)
+			:labelContent(labelContent), labelWidth(labelWidth), options(options), style(style)
+		{ }
+
+		/**
+		 * Constructor for field options with a label.
+		 *
+		 * @param[in]	labelContent	Content to display in the editor field label.
+		 * @param[in]	options			Options that allow you to control how is the element positioned and sized. This will
+		 *								override any similar options set by style.
+		 * @param[in]	style			Optional style to use for the element. Style will be retrieved from GUISkin of the
+		 *								GUIWidget the element is used on. If not specified default style is used.
+		 */
+		GUIFieldOptions(const GUIContent& labelContent, const GUIOptions& options,
+			const String& style = StringUtil::BLANK)
+			:labelContent(labelContent), options(options), style(style)
+		{ }
+
+
+		/**
+		 * Constructor for field options with a label.
+		 *
+		 * @param[in]	labelText		Text to display in the editor field label.
+		 * @param[in]	labelWidth		Width of the label in pixels.
+		 * @param[in]	options			Options that allow you to control how is the element positioned and sized. This will
+		 *								override any similar options set by style.
+		 * @param[in]	style			Optional style to use for the element. Style will be retrieved from GUISkin of the
+		 *								GUIWidget the element is used on. If not specified default style is used.
+		 */
+		GUIFieldOptions(const HString& labelText, UINT32 labelWidth, const GUIOptions& options,
+			const String& style = StringUtil::BLANK)
+			:labelContent(labelText), labelWidth(labelWidth), options(options), style(style)
+		{ }
+
+
+		/**
+		 * Constructor for field options with a label.
+		 *
+		 * @param[in]	labelText		Text to display in the editor field label.
+		 * @param[in]	options			Options that allow you to control how is the element positioned and sized. This will
+		 *								override any similar options set by style.
+		 * @param[in]	style			Optional style to use for the element. Style will be retrieved from GUISkin of the
+		 *								GUIWidget the element is used on. If not specified default style is used.
+		 */
+		GUIFieldOptions(const HString& labelText, const GUIOptions& options,
+			const String& style = StringUtil::BLANK)
+			:labelContent(labelText), options(options), style(style)
+		{ }
+
+
+		/**
+		 * Constructor for field options without a label.
+		 *
+		 * @param[in]	options			Options that allow you to control how is the element positioned and sized. This will
+		 *								override any similar options set by style.
+		 * @param[in]	style			Optional style to use for the element. Style will be retrieved from GUISkin of the
+		 *								GUIWidget the element is used on. If not specified default style is used.
+		 */
+		GUIFieldOptions(const GUIOptions& options, const String& style = StringUtil::BLANK)
+			:labelWidth(0), options(options), style(style)
+		{ }
+
+		/**
+		 * Constructor.
+		 *
+		 * @param[in]	labelContent	Content to display in the editor field label.
+		 * @param[in]	labelWidth		Width of the label in pixels.
+		 * @param[in]	style			Optional style to use for the element. Style will be retrieved from GUISkin of the
+		 *								GUIWidget the element is used on. If not specified default style is used.
+		 */
+		GUIFieldOptions(const GUIContent& labelContent, UINT32 labelWidth, const String& style = StringUtil::BLANK)
+			:labelContent(labelContent), labelWidth(labelWidth), style(style)
+		{ }
+
+		/**
+		 * Constructor for field options with a label.
+		 *
+		 * @param[in]	labelContent	Content to display in the editor field label.
+		 * @param[in]	style			Optional style to use for the element. Style will be retrieved from GUISkin of the
+		 *								GUIWidget the element is used on. If not specified default style is used.
+		 */
+		GUIFieldOptions(const GUIContent& labelContent, const String& style = StringUtil::BLANK)
+			:labelContent(labelContent), style(style)
+		{ }
+
+		/**
+		 * Constructor for field options with a label.
+		 *
+		 * @param[in]	labelText		Text to display in the editor field label.
+		 * @param[in]	labelWidth		Width of the label in pixels.
+		 * @param[in]	style			Optional style to use for the element. Style will be retrieved from GUISkin of the
+		 *								GUIWidget the element is used on. If not specified default style is used.
+		 */
+		GUIFieldOptions(const HString& labelText, UINT32 labelWidth, const String& style = StringUtil::BLANK)
+			:labelContent(labelText), labelWidth(labelWidth), style(style)
+		{ }
+
+		/**
+		 * Constructor for field options with a label.
+		 *
+		 * @param[in]	labelText		Text to display in the editor field label.
+		 * @param[in]	style			Optional style to use for the element. Style will be retrieved from GUISkin of the
+		 *								GUIWidget the element is used on. If not specified default style is used.
+		 */
+		GUIFieldOptions(const HString& labelText, const String& style = StringUtil::BLANK)
+			:labelContent(labelText), style(style)
+		{ }
+
+		/**
+		 * Constructor for field options without a label.
+		 *
+		 * @param[in]	style			Optional style to use for the element. Style will be retrieved from GUISkin of the
+		 *								GUIWidget the element is used on. If not specified default style is used.
+		 */
+		GUIFieldOptions(const String& style = StringUtil::BLANK)
+			:labelWidth(0), style(style)
+		{ }
+
+		GUIContent labelContent;
+		UINT32 labelWidth = 100;
+		GUIOptions options;
+		String style;
+	};
+
+	/** @} */
+}

+ 144 - 22
Source/EditorManaged/GUI/GUITextureField.cs

@@ -11,13 +11,13 @@ namespace BansheeEditor
      */
      */
 
 
     /// <summary>
     /// <summary>
-    /// Editor GUI element that displays a reference to a <see cref="Texture"/> and an optional label. Textures can
-    /// be dragged and dropped onto the field to update the reference. This is similar to <see cref="GUIResourceField"/>
-    /// but the will display the texture contents and not only the name.
+    /// Editor GUI element that displays a reference to a <see cref="Texture"/> or <see cref="SpriteTexture"/> and an
+    /// optional label. Textures can be dragged and dropped onto the field to update the reference. This is similar
+    /// to <see cref="GUIResourceField"/> but the will display the texture contents and not only the name.
     /// </summary>
     /// </summary>
     public sealed class GUITextureField : GUIElement
     public sealed class GUITextureField : GUIElement
     {
     {
-        public delegate void OnChangedDelegate(RRef<Texture> newValue);
+        public delegate void OnChangedDelegate(RRef<Resource> newValue);
 
 
         /// <summary>
         /// <summary>
         /// Triggered when the value in the field changes.
         /// Triggered when the value in the field changes.
@@ -25,14 +25,14 @@ namespace BansheeEditor
         public event OnChangedDelegate OnChanged;
         public event OnChangedDelegate OnChanged;
 
 
         /// <summary>
         /// <summary>
-        /// <see cref="Texture"/> referenced by the field. This will load the texture if it is not already loaded. Use
-        /// <see cref="ValueRef"/> if you don't require a loaded resource.
+        /// Resource referenced by the field, which could be either a normal or a sprite texture. This will load the
+        /// resource if it is not already loaded. Use <see cref="ValueRef"/> if you don't require a loaded resource.
         /// </summary>
         /// </summary>
-        public Texture Value
+        public Resource Value
         {
         {
             get
             get
             {
             {
-                Texture value;
+                Resource value;
                 Internal_GetValue(mCachedPtr, out value);
                 Internal_GetValue(mCachedPtr, out value);
                 return value;
                 return value;
             }
             }
@@ -41,13 +41,13 @@ namespace BansheeEditor
         }
         }
 
 
         /// <summary>
         /// <summary>
-        /// Reference to the <see cref="Texture"/> referenced by the field.
+        /// Handle to the resource referenced by the field, which could be either a normal or a sprite texture.
         /// </summary>
         /// </summary>
-        public RRef<Texture> ValueRef
+        public RRef<Resource> ValueRef
         {
         {
             get
             get
             {
             {
-                RRef<Texture> value;
+                RRef<Resource> value;
                 Internal_GetValueRef(mCachedPtr, out value);
                 Internal_GetValueRef(mCachedPtr, out value);
                 return value;
                 return value;
             }
             }
@@ -56,7 +56,73 @@ namespace BansheeEditor
         }
         }
 
 
         /// <summary>
         /// <summary>
-        /// Creates a new texture field element with a label.
+        /// <see cref="Texture"/> referenced by the field. This will load the resource if it is not already loaded. Use
+        /// <see cref="TextureRef"/> if you don't require a loaded resource. Returns null if the field contains a
+        /// <see cref="SpriteTexture"/> instead.
+        /// </summary>
+        public Texture Texture
+        {
+            get
+            {
+                Texture value;
+                Internal_GetTexture(mCachedPtr, out value);
+                return value;
+            }
+
+            set { Internal_SetTexture(mCachedPtr, value); }
+        }
+
+        /// <summary>
+        /// Handle to the <see cref="Texture"/> referenced by the field. Returns null if the field contains a
+        /// <see cref="SpriteTexture"/> instead.
+        /// </summary>
+        public RRef<Texture> TextureRef
+        {
+            get
+            {
+                RRef<Texture> value;
+                Internal_GetTextureRef(mCachedPtr, out value);
+                return value;
+            }
+
+            set { Internal_SetTextureRef(mCachedPtr, value); }
+        }
+
+        /// <summary>
+        /// <see cref="SpriteTexture"/> referenced by the field. This will load the resource if it is not already loaded.
+        /// Use <see cref="SpriteTextureRef"/> if you don't require a loaded resource. Returns null if the field contains a
+        /// <see cref="Texture"/> instead.
+        /// </summary>
+        public SpriteTexture SpriteTexture
+        {
+            get
+            {
+                SpriteTexture value;
+                Internal_GetSpriteTexture(mCachedPtr, out value);
+                return value;
+            }
+
+            set { Internal_SetSpriteTexture(mCachedPtr, value); }
+        }
+
+        /// <summary>
+        /// Handle to the <see cref="SpriteTexture"/> referenced by the field. Returns null if the field contains a
+        /// <see cref="Texture"/> instead.
+        /// </summary>
+        public RRef<SpriteTexture> SpriteTextureRef
+        {
+            get
+            {
+                RRef<SpriteTexture> value;
+                Internal_GetSpriteTextureRef(mCachedPtr, out value);
+                return value;
+            }
+
+            set { Internal_SetSpriteTextureRef(mCachedPtr, value); }
+        }
+
+        /// <summary>
+        /// Creates a new texture field element with a label. The field will accept textures but not sprite textures.
         /// </summary>
         /// </summary>
         /// <param name="title">Content to display on the label.</param>
         /// <param name="title">Content to display on the label.</param>
         /// <param name="titleWidth">Width of the title label in pixels.</param>
         /// <param name="titleWidth">Width of the title label in pixels.</param>
@@ -67,11 +133,11 @@ namespace BansheeEditor
         ///                       override any similar options set by style.</param>
         ///                       override any similar options set by style.</param>
         public GUITextureField(GUIContent title, int titleWidth = 100, string style = "", params GUIOption[] options)
         public GUITextureField(GUIContent title, int titleWidth = 100, string style = "", params GUIOption[] options)
         {
         {
-            Internal_CreateInstance(this, ref title, titleWidth, style, options, true);
+            Internal_CreateInstance(this, GUITextureFieldType.Texture, ref title, titleWidth, style, options, true);
         }
         }
 
 
         /// <summary>
         /// <summary>
-        /// Creates a new texture field element without a label.
+        /// Creates a new texture field element without a label. The field will accept textures but not sprite textures.
         /// </summary>
         /// </summary>
         /// <param name="style">Optional style to use for the element. Style controls the look of the element, as well as 
         /// <param name="style">Optional style to use for the element. Style controls the look of the element, as well as 
         ///                     default layout options. Style will be retrieved from the active GUISkin. If not specified 
         ///                     default layout options. Style will be retrieved from the active GUISkin. If not specified 
@@ -81,7 +147,39 @@ namespace BansheeEditor
         public GUITextureField(string style = "", params GUIOption[] options)
         public GUITextureField(string style = "", params GUIOption[] options)
         {
         {
             GUIContent emptyContent = new GUIContent();
             GUIContent emptyContent = new GUIContent();
-            Internal_CreateInstance(this, ref emptyContent, 0, style, options, false);
+            Internal_CreateInstance(this, GUITextureFieldType.Texture, ref emptyContent, 0, style, options, false);
+        }
+
+        /// <summary>
+        /// Creates a new texture field element with a label.
+        /// </summary>
+        /// <param name="type">Determines the type of textures should the field accept.</param>
+        /// <param name="title">Content to display on the label.</param>
+        /// <param name="titleWidth">Width of the title label in pixels.</param>
+        /// <param name="style">Optional style to use for the element. Style controls the look of the element, as well as 
+        ///                     default layout options. Style will be retrieved from the active GUISkin. If not specified 
+        ///                     default element style is used.</param>
+        /// <param name="options">Options that allow you to control how is the element  positioned and sized. This will 
+        ///                       override any similar options set by style.</param>
+        public GUITextureField(GUITextureFieldType type, GUIContent title, 
+            int titleWidth = 100, string style = "", params GUIOption[] options)
+        {
+            Internal_CreateInstance(this, type, ref title, titleWidth, style, options, true);
+        }
+
+        /// <summary>
+        /// Creates a new texture field element without a label.
+        /// </summary>
+        /// <param name="type">Determines the type of textures should the field accept.</param>
+        /// <param name="style">Optional style to use for the element. Style controls the look of the element, as well as 
+        ///                     default layout options. Style will be retrieved from the active GUISkin. If not specified 
+        ///                     default element style is used.</param>
+        /// <param name="options">Options that allow you to control how is the element  positioned and sized. This will 
+        ///                       override any similar options set by style.</param>
+        public GUITextureField(GUITextureFieldType type, string style = "", params GUIOption[] options)
+        {
+            GUIContent emptyContent = new GUIContent();
+            Internal_CreateInstance(this, type, ref emptyContent, 0, style, options, false);
         }
         }
 
 
         /// <summary>
         /// <summary>
@@ -97,27 +195,51 @@ namespace BansheeEditor
         /// Triggered by the runtime when the value of the field changes.
         /// Triggered by the runtime when the value of the field changes.
         /// </summary>
         /// </summary>
         /// <param name="newValue">New resource referenced by the field.</param>
         /// <param name="newValue">New resource referenced by the field.</param>
-        private void Internal_DoOnChanged(RRef<Texture> newValue)
+        private void Internal_DoOnChanged(RRef<Resource> newValue)
         {
         {
             if (OnChanged != null)
             if (OnChanged != null)
                 OnChanged(newValue);
                 OnChanged(newValue);
         }
         }
 
 
         [MethodImpl(MethodImplOptions.InternalCall)]
         [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_CreateInstance(GUITextureField instance, ref GUIContent title, int titleWidth,
-            string style, GUIOption[] options, bool withTitle);
+        private static extern void Internal_CreateInstance(GUITextureField instance, GUITextureFieldType type,
+            ref GUIContent title, int titleWidth, string style, GUIOption[] options, bool withTitle);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_GetSpriteTexture(IntPtr nativeInstance, out SpriteTexture value);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_SetSpriteTexture(IntPtr nativeInstance, SpriteTexture value);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_GetSpriteTextureRef(IntPtr nativeInstance, out RRef<SpriteTexture> value);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_SetSpriteTextureRef(IntPtr nativeInstance, RRef<SpriteTexture> value);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_GetTexture(IntPtr nativeInstance, out Texture value);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_SetTexture(IntPtr nativeInstance, Texture value);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_GetTextureRef(IntPtr nativeInstance, out RRef<Texture> value);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_SetTextureRef(IntPtr nativeInstance, RRef<Texture> value);
 
 
         [MethodImpl(MethodImplOptions.InternalCall)]
         [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_GetValue(IntPtr nativeInstance, out Texture value);
+        private static extern void Internal_GetValue(IntPtr nativeInstance, out Resource value);
 
 
         [MethodImpl(MethodImplOptions.InternalCall)]
         [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_SetValue(IntPtr nativeInstance, Texture value);
+        private static extern void Internal_SetValue(IntPtr nativeInstance, Resource value);
 
 
         [MethodImpl(MethodImplOptions.InternalCall)]
         [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_GetValueRef(IntPtr nativeInstance, out RRef<Texture> value);
+        private static extern void Internal_GetValueRef(IntPtr nativeInstance, out RRef<Resource> value);
 
 
         [MethodImpl(MethodImplOptions.InternalCall)]
         [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_SetValueRef(IntPtr nativeInstance, RRef<Texture> value);
+        private static extern void Internal_SetValueRef(IntPtr nativeInstance, RRef<Resource> value);
 
 
         [MethodImpl(MethodImplOptions.InternalCall)]
         [MethodImpl(MethodImplOptions.InternalCall)]
         private static extern void Internal_SetTint(IntPtr nativeInstance, ref Color color);
         private static extern void Internal_SetTint(IntPtr nativeInstance, ref Color color);

+ 23 - 0
Source/EditorManaged/Generated/GUITextureFieldType.generated.cs

@@ -0,0 +1,23 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//************** Copyright (c) 2016-2019 Marko Pintera ([email protected]). All rights reserved. *******************//
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using BansheeEngine;
+
+namespace BansheeEditor
+{
+	/** @addtogroup GUI-Editor
+	 *  @{
+	 */
+
+	/// <summary>Type that control what type of texture does a GUITexture field accept.</summary>
+	public enum GUITextureFieldType
+	{
+		Texture = 1,
+		SpriteTexture = 2,
+		TextureOrSpriteTexture = 3
+	}
+
+	/** @} */
+}

+ 17 - 6
Source/EditorManaged/Inspectors/MaterialInspector.cs

@@ -599,9 +599,13 @@ namespace BansheeEditor
                 case ShaderParameterType.TextureCube:
                 case ShaderParameterType.TextureCube:
                     guiElem.OnChanged += (x) =>
                     guiElem.OnChanged += (x) =>
                     {
                     {
-                        Texture texture = Resources.Load<Texture>(x.UUID);
+                        Resource resource = x.Value;
+
+                        if(resource is Texture tex)
+                            material.SetTexture(shaderParam.name, tex);
+                        else if(resource is SpriteTexture spriteTex)
+                            material.SetSpriteTexture(shaderParam.name, spriteTex);
 
 
-                        material.SetTexture(shaderParam.name, texture);
                         EditorApplication.SetDirty(material);
                         EditorApplication.SetDirty(material);
                     };
                     };
                     break;
                     break;
@@ -613,17 +617,24 @@ namespace BansheeEditor
         /// <inheritdoc/>
         /// <inheritdoc/>
         internal override void Refresh(Material material)
         internal override void Refresh(Material material)
         {
         {
-            Texture value = null;
             switch (shaderParam.type)
             switch (shaderParam.type)
             {
             {
                 case ShaderParameterType.Texture2D:
                 case ShaderParameterType.Texture2D:
                 case ShaderParameterType.Texture3D:
                 case ShaderParameterType.Texture3D:
                 case ShaderParameterType.TextureCube:
                 case ShaderParameterType.TextureCube:
-                    value = material.GetTexture(shaderParam.name).Value;
+                    RRef<SpriteTexture> spriteTex = material.GetSpriteTexture(shaderParam.name);
+
+                    if (spriteTex != null)
+                        guiElem.SpriteTextureRef = spriteTex;
+                    else
+                    {
+                        RRef<Texture> texture = material.GetTexture(shaderParam.name);
+                        guiElem.TextureRef = texture;
+                    }
+
+
                     break;
                     break;
             }
             }
-
-            guiElem.Value = value;
         }
         }
 
 
         /// <inheritdoc/>
         /// <inheritdoc/>

+ 2 - 2
Source/EditorManaged/Inspectors/ReflectionProbeInspector.cs

@@ -47,7 +47,7 @@ namespace BansheeEditor
 
 
                 customTextureField.OnChanged += x =>
                 customTextureField.OnChanged += x =>
                 {
                 {
-                    probe.CustomTexture = Resources.Load<Texture>(x.UUID);
+                    probe.CustomTexture = x.As<Texture>();
                     MarkAsModified();
                     MarkAsModified();
                     ConfirmModify();
                     ConfirmModify();
                 };
                 };
@@ -79,7 +79,7 @@ namespace BansheeEditor
             probeTypeField.Value = (ulong)probeType;
             probeTypeField.Value = (ulong)probeType;
             radiusField.Value = probe.Radius;
             radiusField.Value = probe.Radius;
             extentsField.Value = probe.Extents;
             extentsField.Value = probe.Extents;
-            customTextureField.ValueRef = probe.CustomTexture;
+            customTextureField.TextureRef = probe.CustomTexture;
 
 
             InspectableState oldState = modifyState;
             InspectableState oldState = modifyState;
             if (modifyState.HasFlag(InspectableState.Modified))
             if (modifyState.HasFlag(InspectableState.Modified))

+ 2 - 2
Source/EditorManaged/Inspectors/SpriteTextureInspector.cs

@@ -30,7 +30,7 @@ namespace BansheeEditor
 
 
             textureField.OnChanged += (x) =>
             textureField.OnChanged += (x) =>
             {
             {
-                spriteTexture.Texture = x;
+                spriteTexture.Texture = x.As<Texture>();
                 EditorApplication.SetDirty(spriteTexture);
                 EditorApplication.SetDirty(spriteTexture);
             };
             };
 
 
@@ -58,7 +58,7 @@ namespace BansheeEditor
             if (spriteTexture == null)
             if (spriteTexture == null)
                 return InspectableState.NotModified;
                 return InspectableState.NotModified;
 
 
-            textureField.ValueRef = spriteTexture.Texture;
+            textureField.TextureRef = spriteTexture.Texture;
             offsetField.Value = spriteTexture.Offset;
             offsetField.Value = spriteTexture.Offset;
             scaleField.Value = spriteTexture.Scale;
             scaleField.Value = spriteTexture.Scale;
 
 

+ 2 - 2
Source/EditorManaged/Windows/Build/BuildWindow.cs

@@ -225,10 +225,10 @@ namespace BansheeEditor
                     layout.AddElement(iconField);
                     layout.AddElement(iconField);
 
 
                     titleField.Value = winPlatformInfo.TitleText;
                     titleField.Value = winPlatformInfo.TitleText;
-                    iconField.ValueRef = winPlatformInfo.Icon;
+                    iconField.TextureRef = winPlatformInfo.Icon;
 
 
                     titleField.OnChanged += x => winPlatformInfo.TitleText = x;
                     titleField.OnChanged += x => winPlatformInfo.TitleText = x;
-                    iconField.OnChanged += x => winPlatformInfo.Icon = x;
+                    iconField.OnChanged += x => winPlatformInfo.Icon = x.As<Texture>();
                 }
                 }
                     break;
                     break;
             }
             }

+ 5 - 102
Source/EditorScript/BsGUIResourceField.cpp

@@ -56,112 +56,15 @@ namespace bs
 		mDropButton->onClick.connect(std::bind(&GUIResourceField::onDropButtonClicked, this));
 		mDropButton->onClick.connect(std::bind(&GUIResourceField::onDropButtonClicked, this));
 	}
 	}
 
 
-	GUIResourceField* GUIResourceField::create(const String& typeNamespace, const String& type, const GUIContent& labelContent, UINT32 labelWidth, const GUIOptions& options,
-		const String& style)
+	GUIResourceField* GUIResourceField::create(const String& typeNamespace, const String& type, 
+		const GUIFieldOptions& options)
 	{
 	{
-		const String* curStyle = &style;
+		const String* curStyle = &options.style;
 		if (*curStyle == StringUtil::BLANK)
 		if (*curStyle == StringUtil::BLANK)
 			curStyle = &BuiltinEditorResources::ObjectFieldStyleName;
 			curStyle = &BuiltinEditorResources::ObjectFieldStyleName;
 
 
-		return bs_new<GUIResourceField>(PrivatelyConstruct(), typeNamespace, type, labelContent, labelWidth, *curStyle,
-			GUIDimensions::create(options), true);
-	}
-
-	GUIResourceField* GUIResourceField::create(const String& typeNamespace, const String& type, const GUIContent& labelContent, const GUIOptions& options,
-		const String& style)
-	{
-		const String* curStyle = &style;
-		if (*curStyle == StringUtil::BLANK)
-			curStyle = &BuiltinEditorResources::ObjectFieldStyleName;
-
-		return bs_new<GUIResourceField>(PrivatelyConstruct(), typeNamespace, type, labelContent, DEFAULT_LABEL_WIDTH, *curStyle,
-			GUIDimensions::create(options), true);
-	}
-
-	GUIResourceField* GUIResourceField::create(const String& typeNamespace, const String& type, const HString& labelText, UINT32 labelWidth, const GUIOptions& options,
-		const String& style)
-	{
-		const String* curStyle = &style;
-		if (*curStyle == StringUtil::BLANK)
-			curStyle = &BuiltinEditorResources::ObjectFieldStyleName;
-
-		return bs_new<GUIResourceField>(PrivatelyConstruct(), typeNamespace, type, GUIContent(labelText), labelWidth, *curStyle,
-			GUIDimensions::create(options), true);
-	}
-
-	GUIResourceField* GUIResourceField::create(const String& typeNamespace, const String& type, const HString& labelText, const GUIOptions& options,
-		const String& style)
-	{
-		const String* curStyle = &style;
-		if (*curStyle == StringUtil::BLANK)
-			curStyle = &BuiltinEditorResources::ObjectFieldStyleName;
-
-		return bs_new<GUIResourceField>(PrivatelyConstruct(), typeNamespace, type, GUIContent(labelText), DEFAULT_LABEL_WIDTH, *curStyle,
-			GUIDimensions::create(options), true);
-	}
-
-	GUIResourceField* GUIResourceField::create(const String& typeNamespace, const String& type, const GUIOptions& options, const String& style)
-	{
-		const String* curStyle = &style;
-		if (*curStyle == StringUtil::BLANK)
-			curStyle = &BuiltinEditorResources::ObjectFieldStyleName;
-
-		return bs_new<GUIResourceField>(PrivatelyConstruct(), typeNamespace, type, GUIContent(), 0, *curStyle,
-			GUIDimensions::create(options), false);
-	}
-
-	GUIResourceField* GUIResourceField::create(const String& typeNamespace, const String& type, const GUIContent& labelContent, UINT32 labelWidth,
-		const String& style)
-	{
-		const String* curStyle = &style;
-		if (*curStyle == StringUtil::BLANK)
-			curStyle = &BuiltinEditorResources::ObjectFieldStyleName;
-
-		return bs_new<GUIResourceField>(PrivatelyConstruct(), typeNamespace, type, labelContent, labelWidth, *curStyle,
-			GUIDimensions::create(), true);
-	}
-
-	GUIResourceField* GUIResourceField::create(const String& typeNamespace, const String& type, const GUIContent& labelContent,
-		const String& style)
-	{
-		const String* curStyle = &style;
-		if (*curStyle == StringUtil::BLANK)
-			curStyle = &BuiltinEditorResources::ObjectFieldStyleName;
-
-		return bs_new<GUIResourceField>(PrivatelyConstruct(), typeNamespace, type, labelContent, DEFAULT_LABEL_WIDTH, *curStyle,
-			GUIDimensions::create(), true);
-	}
-
-	GUIResourceField* GUIResourceField::create(const String& typeNamespace, const String& type, const HString& labelText, UINT32 labelWidth,
-		const String& style)
-	{
-		const String* curStyle = &style;
-		if (*curStyle == StringUtil::BLANK)
-			curStyle = &BuiltinEditorResources::ObjectFieldStyleName;
-
-		return bs_new<GUIResourceField>(PrivatelyConstruct(), typeNamespace, type, GUIContent(labelText), labelWidth, *curStyle,
-			GUIDimensions::create(), true);
-	}
-
-	GUIResourceField* GUIResourceField::create(const String& typeNamespace, const String& type, const HString& labelText,
-		const String& style)
-	{
-		const String* curStyle = &style;
-		if (*curStyle == StringUtil::BLANK)
-			curStyle = &BuiltinEditorResources::ObjectFieldStyleName;
-
-		return bs_new<GUIResourceField>(PrivatelyConstruct(), typeNamespace, type, GUIContent(labelText), DEFAULT_LABEL_WIDTH, *curStyle,
-			GUIDimensions::create(), true);
-	}
-
-	GUIResourceField* GUIResourceField::create(const String& typeNamespace, const String& type, const String& style)
-	{
-		const String* curStyle = &style;
-		if (*curStyle == StringUtil::BLANK)
-			curStyle = &BuiltinEditorResources::ObjectFieldStyleName;
-
-		return bs_new<GUIResourceField>(PrivatelyConstruct(), typeNamespace, type, GUIContent(), 0, *curStyle,
-			GUIDimensions::create(), false);
+		return bs_new<GUIResourceField>(PrivatelyConstruct(), typeNamespace, type, options.labelContent, 
+			options.labelWidth, *curStyle, GUIDimensions::create(options.options), true);
 	}
 	}
 
 
 	HResource GUIResourceField::getValue() const
 	HResource GUIResourceField::getValue() const

+ 8 - 127
Source/EditorScript/BsGUIResourceField.h

@@ -4,6 +4,7 @@
 
 
 #include "BsScriptEditorPrerequisites.h"
 #include "BsScriptEditorPrerequisites.h"
 #include "GUI/BsGUIElementContainer.h"
 #include "GUI/BsGUIElementContainer.h"
+#include "GUI/BsGUIFieldOptions.h"
 
 
 namespace bs
 namespace bs
 {
 {
@@ -24,137 +25,17 @@ namespace bs
 		static const String& getGUITypeName();
 		static const String& getGUITypeName();
 
 
 		/**
 		/**
-		 * Creates a new resource GUI editor field with a label.
+		 * Creates a new resource GUI editor field.
 		 *
 		 *
 		 * @param[in]	typeNamespace	Namespace of the type this field accepts. 
 		 * @param[in]	typeNamespace	Namespace of the type this field accepts. 
 		 * @param[in]	type			Type name of the type this field accepts. Must derive from Resource.
 		 * @param[in]	type			Type name of the type this field accepts. Must derive from Resource.
-		 * @param[in]	labelContent	Content to display in the editor field label.
-		 * @param[in]	labelWidth		Width of the label in pixels.
-		 * @param[in]	options			Options that allow you to control how is the element positioned and sized. This will
-		 *								override any similar options set by style.
-		 * @param[in]	style			Optional style to use for the element. Style will be retrieved from GUISkin of the
-		 *								GUIWidget the element is used on. If not specified default style is used.
+		 * @param[in]	options			Options controlling the label, style and layout of the field.
 		 */
 		 */
-		static GUIResourceField* create(const String& typeNamespace, const String& type, const GUIContent& labelContent, UINT32 labelWidth, const GUIOptions& options,
-			const String& style = StringUtil::BLANK);
+		static GUIResourceField* create(const String& typeNamespace, const String& type, const GUIFieldOptions& options); 
 
 
-		/**
-		 * Creates a new resource GUI editor field with a label.
-		 *
-		 * @param[in]	typeNamespace	Namespace of the type this field accepts. 
-		 * @param[in]	type			Type name of the type this field accepts. Must derive from Resource.
-		 * @param[in]	labelContent	Content to display in the editor field label.
-		 * @param[in]	options			Options that allow you to control how is the element positioned and sized. This will
-		 *								override any similar options set by style.
-		 * @param[in]	style			Optional style to use for the element. Style will be retrieved from GUISkin of the
-		 *								GUIWidget the element is used on. If not specified default style is used.
-		 */
-		static GUIResourceField* create(const String& typeNamespace, const String& type, const GUIContent& labelContent, const GUIOptions& options,
-			const String& style = StringUtil::BLANK);
-
-		/**
-		 * Creates a new resource GUI editor field with a label.
-		 *
-		 * @param[in]	typeNamespace	Namespace of the type this field accepts. 
-		 * @param[in]	type			Type name of the type this field accepts. Must derive from Resource.
-		 * @param[in]	labelText		Text to display in the editor field label.
-		 * @param[in]	labelWidth		Width of the label in pixels.
-		 * @param[in]	options			Options that allow you to control how is the element positioned and sized. This will
-		 *								override any similar options set by style.
-		 * @param[in]	style			Optional style to use for the element. Style will be retrieved from GUISkin of the
-		 *								GUIWidget the element is used on. If not specified default style is used.
-		 */
-		static GUIResourceField* create(const String& typeNamespace, const String& type, const HString& labelText, UINT32 labelWidth, const GUIOptions& options,
-			const String& style = StringUtil::BLANK);
-
-		/**
-		 * Creates a new resource GUI editor field with a label.
-		 *
-		 * @param[in]	typeNamespace	Namespace of the type this field accepts. 
-		 * @param[in]	type			Type name of the type this field accepts. Must derive from Resource.
-		 * @param[in]	labelText		Text to display in the editor field label.
-		 * @param[in]	options			Options that allow you to control how is the element positioned and sized. This will
-		 *								override any similar options set by style.
-		 * @param[in]	style			Optional style to use for the element. Style will be retrieved from GUISkin of the
-		 *								GUIWidget the element is used on. If not specified default style is used.
-		 */
-		static GUIResourceField* create(const String& typeNamespace, const String& type, const HString& labelText, const GUIOptions& options,
-			const String& style = StringUtil::BLANK);
-
-		/**
-		 * Creates a new resource GUI editor field without a label.
-		 *
-		 * @param[in]	typeNamespace	Namespace of the type this field accepts. 
-		 * @param[in]	type			Type name of the type this field accepts. Must derive from Resource.
-		 * @param[in]	options			Options that allow you to control how is the element positioned and sized. This will
-		 *								override any similar options set by style.
-		 * @param[in]	style			Optional style to use for the element. Style will be retrieved from GUISkin of the
-		 *								GUIWidget the element is used on. If not specified default style is used.
-		 */
-		static GUIResourceField* create(const String& typeNamespace, const String& type, const GUIOptions& options, const String& style = StringUtil::BLANK);
-
-		/**
-		 * Creates a new resource GUI editor field with a label.
-		 *
-		 * @param[in]	typeNamespace	Namespace of the type this field accepts. 
-		 * @param[in]	type			Type name of the type this field accepts. Must derive from Resource.
-		 * @param[in]	labelContent	Content to display in the editor field label.
-		 * @param[in]	labelWidth		Width of the label in pixels.
-		 * @param[in]	style			Optional style to use for the element. Style will be retrieved from GUISkin of the
-		 *								GUIWidget the element is used on. If not specified default style is used.
-		 */
-		static GUIResourceField* create(const String& typeNamespace, const String& type, const GUIContent& labelContent, UINT32 labelWidth,
-			const String& style = StringUtil::BLANK);
-
-		/**
-		 * Creates a new resource GUI editor field with a label.
-		 *
-		 * @param[in]	typeNamespace	Namespace of the type this field accepts. 
-		 * @param[in]	type			Type name of the type this field accepts. Must derive from Resource.
-		 * @param[in]	labelContent	Content to display in the editor field label.
-		 * @param[in]	style			Optional style to use for the element. Style will be retrieved from GUISkin of the
-		 *								GUIWidget the element is used on. If not specified default style is used.
-		 */
-		static GUIResourceField* create(const String& typeNamespace, const String& type, const GUIContent& labelContent,
-			const String& style = StringUtil::BLANK);
-
-		/**
-		 * Creates a new resource GUI editor field with a label.
-		 *
-		 * @param[in]	typeNamespace	Namespace of the type this field accepts. 
-		 * @param[in]	type			Type name of the type this field accepts. Must derive from Resource.
-		 * @param[in]	labelText		Text to display in the editor field label.
-		 * @param[in]	labelWidth		Width of the label in pixels.
-		 * @param[in]	style			Optional style to use for the element. Style will be retrieved from GUISkin of the
-		 *								GUIWidget the element is used on. If not specified default style is used.
-		 */
-		static GUIResourceField* create(const String& typeNamespace, const String& type, const HString& labelText, UINT32 labelWidth,
-			const String& style = StringUtil::BLANK);
-
-		/**
-		 * Creates a new resource GUI editor field with a label.
-		 *
-		 * @param[in]	typeNamespace	Namespace of the type this field accepts. 
-		 * @param[in]	type			Type name of the type this field accepts. Must derive from Resource.
-		 * @param[in]	labelText		Text to display in the editor field label.
-		 * @param[in]	style			Optional style to use for the element. Style will be retrieved from GUISkin of the
-		 *								GUIWidget the element is used on. If not specified default style is used.
-		 */
-		static GUIResourceField* create(const String& typeNamespace, const String& type, const HString& labelText,
-			const String& style = StringUtil::BLANK);
-
-		/**
-		 * Creates a new resource GUI editor field without a label.
-		 *
-		 * @param[in]	typeNamespace	Namespace of the type this field accepts. 
-		 * @param[in]	type			Type name of the type this field accepts. Must derive from Resource.
-		 * @param[in]	style			Optional style to use for the element. Style will be retrieved from GUISkin of the
-		 *								GUIWidget the element is used on. If not specified default style is used.
-		 */
-		static GUIResourceField* create(const String& typeNamespace, const String& type, const String& style = StringUtil::BLANK);
-
-		GUIResourceField(const PrivatelyConstruct& dummy, const String& typeNamespace, const String& type, const GUIContent& labelContent,
-			UINT32 labelWidth, const String& style, const GUIDimensions& dimensions, bool withLabel);
+		GUIResourceField(const PrivatelyConstruct& dummy, const String& typeNamespace, const String& type, 
+			const GUIContent& labelContent, UINT32 labelWidth, const String& style, const GUIDimensions& dimensions, 
+			bool withLabel);
 
 
 		/**	Returns the resource referenced by the field, if any. */
 		/**	Returns the resource referenced by the field, if any. */
 		HResource getValue() const;
 		HResource getValue() const;
@@ -222,4 +103,4 @@ namespace bs
 	};
 	};
 
 
 	/** @} */
 	/** @} */
-}
+}

+ 66 - 99
Source/EditorScript/BsGUITextureField.cpp

@@ -8,13 +8,15 @@
 #include "GUI/BsGUIButton.h"
 #include "GUI/BsGUIButton.h"
 #include "GUI/BsGUIPanel.h"
 #include "GUI/BsGUIPanel.h"
 #include "Resources/BsResources.h"
 #include "Resources/BsResources.h"
+#include "Image/BsTexture.h"
+#include "Image/BsSpriteTexture.h"
 #include "Library/BsProjectLibrary.h"
 #include "Library/BsProjectLibrary.h"
 #include "Utility/BsBuiltinEditorResources.h"
 #include "Utility/BsBuiltinEditorResources.h"
 #include "GUI/BsGUIResourceTreeView.h"
 #include "GUI/BsGUIResourceTreeView.h"
 #include "GUI/BsGUISpace.h"
 #include "GUI/BsGUISpace.h"
 #include "Library/BsProjectResourceMeta.h"
 #include "Library/BsProjectResourceMeta.h"
-#include "Image/BsSpriteTexture.h"
 #include "Scene/BsSelection.h"
 #include "Scene/BsSelection.h"
+#include "Reflection/BsRTTIType.h"
 
 
 using namespace std::placeholders;
 using namespace std::placeholders;
 
 
@@ -22,8 +24,8 @@ namespace bs
 {
 {
 	const UINT32 GUITextureField::DEFAULT_LABEL_WIDTH = 100;
 	const UINT32 GUITextureField::DEFAULT_LABEL_WIDTH = 100;
 
 
-	GUITextureField::GUITextureField(const PrivatelyConstruct& dummy, const GUIContent& labelContent, UINT32 labelWidth,
-		const String& style, const GUIDimensions& dimensions, bool withLabel)
+	GUITextureField::GUITextureField(const PrivatelyConstruct& dummy, GUITextureFieldType, const GUIContent& labelContent, 
+		UINT32 labelWidth, const String& style, const GUIDimensions& dimensions, bool withLabel) 
 		:GUIElementContainer(dimensions, style), mLabel(nullptr), mDropButton(nullptr), mClearButton(nullptr)
 		:GUIElementContainer(dimensions, style), mLabel(nullptr), mDropButton(nullptr), mClearButton(nullptr)
 	{
 	{
 		mLayout = GUILayoutX::create();
 		mLayout = GUILayoutX::create();
@@ -31,12 +33,15 @@ namespace bs
 
 
 		if (withLabel)
 		if (withLabel)
 		{
 		{
-			mLabel = GUILabel::create(labelContent, GUIOptions(GUIOption::fixedWidth(labelWidth)), getSubStyleName(BuiltinEditorResources::TextureFieldLabelStyleName));
+			mLabel = GUILabel::create(labelContent, GUIOptions(GUIOption::fixedWidth(labelWidth)), 
+				getSubStyleName(BuiltinEditorResources::TextureFieldLabelStyleName));
 			mLayout->addElement(mLabel);
 			mLayout->addElement(mLabel);
 		}
 		}
 
 
-		mDropButton = GUIDropButton::create((UINT32)DragAndDropType::Resources, getSubStyleName(BuiltinEditorResources::TextureFieldDropStyleName));
-		mClearButton = GUIButton::create(HString(""), getSubStyleName(BuiltinEditorResources::TextureFieldClearBtnStyleName));
+		mDropButton = GUIDropButton::create((UINT32)DragAndDropType::Resources, 
+			getSubStyleName(BuiltinEditorResources::TextureFieldDropStyleName));
+		mClearButton = GUIButton::create(HString(""), 
+			getSubStyleName(BuiltinEditorResources::TextureFieldClearBtnStyleName));
 		mClearButton->onClick.connect(std::bind(&GUITextureField::onClearButtonClicked, this));
 		mClearButton->onClick.connect(std::bind(&GUITextureField::onClearButtonClicked, this));
 
 
 		GUIElementOptions clearBtnOptions = mClearButton->getOptionFlags();
 		GUIElementOptions clearBtnOptions = mClearButton->getOptionFlags();
@@ -62,124 +67,80 @@ namespace bs
 		mDropButton->onClick.connect(std::bind(&GUITextureField::onDropButtonClicked, this));
 		mDropButton->onClick.connect(std::bind(&GUITextureField::onDropButtonClicked, this));
 	}
 	}
 
 
-	GUITextureField::~GUITextureField()
-	{
-
-	}
-
-	GUITextureField* GUITextureField::create(const GUIContent& labelContent, UINT32 labelWidth, const GUIOptions& options,
-		const String& style)
-	{
-		const String* curStyle = &style;
-		if (*curStyle == StringUtil::BLANK)
-			curStyle = &BuiltinEditorResources::TextureFieldStyleName;
-
-		return bs_new<GUITextureField>(PrivatelyConstruct(), labelContent, labelWidth, *curStyle,
-			GUIDimensions::create(options), true);
-	}
-
-	GUITextureField* GUITextureField::create(const GUIContent& labelContent, const GUIOptions& options,
-		const String& style)
-	{
-		const String* curStyle = &style;
-		if (*curStyle == StringUtil::BLANK)
-			curStyle = &BuiltinEditorResources::TextureFieldStyleName;
-
-		return bs_new<GUITextureField>(PrivatelyConstruct(), labelContent, DEFAULT_LABEL_WIDTH, *curStyle,
-			GUIDimensions::create(options), true);
-	}
-
-	GUITextureField* GUITextureField::create(const HString& labelText, UINT32 labelWidth, const GUIOptions& options,
-		const String& style)
-	{
-		const String* curStyle = &style;
-		if (*curStyle == StringUtil::BLANK)
-			curStyle = &BuiltinEditorResources::TextureFieldStyleName;
-
-		return bs_new<GUITextureField>(PrivatelyConstruct(), GUIContent(labelText), labelWidth, *curStyle,
-			GUIDimensions::create(options), true);
-	}
-
-	GUITextureField* GUITextureField::create( const HString& labelText, const GUIOptions& options,
-		const String& style)
-	{
-		const String* curStyle = &style;
-		if (*curStyle == StringUtil::BLANK)
-			curStyle = &BuiltinEditorResources::TextureFieldStyleName;
-
-		return bs_new<GUITextureField>(PrivatelyConstruct(), GUIContent(labelText), DEFAULT_LABEL_WIDTH, *curStyle,
-			GUIDimensions::create(options), true);
-	}
-
-	GUITextureField* GUITextureField::create(const GUIOptions& options, const String& style)
+	GUITextureField* GUITextureField::create(GUITextureFieldType type, const GUIFieldOptions& options)
 	{
 	{
-		const String* curStyle = &style;
+		const String* curStyle = &options.style;
 		if (*curStyle == StringUtil::BLANK)
 		if (*curStyle == StringUtil::BLANK)
 			curStyle = &BuiltinEditorResources::TextureFieldStyleName;
 			curStyle = &BuiltinEditorResources::TextureFieldStyleName;
 
 
-		return bs_new<GUITextureField>(PrivatelyConstruct(), GUIContent(), 0, *curStyle,
-			GUIDimensions::create(options), false);
+		return bs_new<GUITextureField>(PrivatelyConstruct(), type, options.labelContent, 
+			options.labelWidth, *curStyle, GUIDimensions::create(options.options), options.labelWidth > 0);
 	}
 	}
 
 
-	GUITextureField* GUITextureField::create(const GUIContent& labelContent, UINT32 labelWidth,
-		const String& style)
+	GUITextureField* GUITextureField::create(const GUIFieldOptions& options)
 	{
 	{
-		const String* curStyle = &style;
+		const String* curStyle = &options.style;
 		if (*curStyle == StringUtil::BLANK)
 		if (*curStyle == StringUtil::BLANK)
 			curStyle = &BuiltinEditorResources::TextureFieldStyleName;
 			curStyle = &BuiltinEditorResources::TextureFieldStyleName;
 
 
-		return bs_new<GUITextureField>(PrivatelyConstruct(), labelContent, labelWidth, *curStyle,
-			GUIDimensions::create(), true);
+		return bs_new<GUITextureField>(PrivatelyConstruct(), GUITextureFieldType::Texture, options.labelContent, 
+			options.labelWidth, *curStyle, GUIDimensions::create(options.options), options.labelWidth > 0);
 	}
 	}
 
 
-	GUITextureField* GUITextureField::create(const GUIContent& labelContent, const String& style)
+	HTexture GUITextureField::getTexture() const
 	{
 	{
-		const String* curStyle = &style;
-		if (*curStyle == StringUtil::BLANK)
-			curStyle = &BuiltinEditorResources::TextureFieldStyleName;
+		HResource resource = gResources()._getResourceHandle(mUUID);
+		if(resource.isLoaded(false))
+		{
+			if (rtti_is_of_type<Texture>(resource.get()))
+				return static_resource_cast<Texture>(resource);
+		}
 
 
-		return bs_new<GUITextureField>(PrivatelyConstruct(), labelContent, DEFAULT_LABEL_WIDTH, *curStyle,
-			GUIDimensions::create(), true);
+		return HTexture();
 	}
 	}
 
 
-	GUITextureField* GUITextureField::create(const HString& labelText, UINT32 labelWidth, const String& style)
+	void GUITextureField::setTexture(const HTexture& value)
 	{
 	{
-		const String* curStyle = &style;
-		if (*curStyle == StringUtil::BLANK)
-			curStyle = &BuiltinEditorResources::TextureFieldStyleName;
-
-		return bs_new<GUITextureField>(PrivatelyConstruct(), GUIContent(labelText), labelWidth, *curStyle,
-			GUIDimensions::create(), true);
+		if (value)
+			setUUID(value.getUUID(), false);
+		else
+			setUUID(UUID::EMPTY, false);
 	}
 	}
 
 
-	GUITextureField* GUITextureField::create(const HString& labelText, const String& style)
+	HSpriteTexture GUITextureField::getSpriteTexture() const
 	{
 	{
-		const String* curStyle = &style;
-		if (*curStyle == StringUtil::BLANK)
-			curStyle = &BuiltinEditorResources::TextureFieldStyleName;
+		HResource resource = gResources()._getResourceHandle(mUUID);
+		if(resource.isLoaded(false))
+		{
+			if (rtti_is_of_type<SpriteTexture>(resource.get()))
+				return static_resource_cast<SpriteTexture>(resource);
+		}
 
 
-		return bs_new<GUITextureField>(PrivatelyConstruct(), GUIContent(labelText), DEFAULT_LABEL_WIDTH, *curStyle,
-			GUIDimensions::create(), true);
+		return HSpriteTexture();
 	}
 	}
 
 
-	GUITextureField* GUITextureField::create(const String& style)
+	void GUITextureField::setSpriteTexture(const HSpriteTexture& value)
 	{
 	{
-		const String* curStyle = &style;
-		if (*curStyle == StringUtil::BLANK)
-			curStyle = &BuiltinEditorResources::TextureFieldStyleName;
-
-		return bs_new<GUITextureField>(PrivatelyConstruct(), GUIContent(), 0, *curStyle, GUIDimensions::create(), false);
+		if (value)
+			setUUID(value.getUUID(), false);
+		else
+			setUUID(UUID::EMPTY, false);
 	}
 	}
 
 
-	HTexture GUITextureField::getValue() const
+	HResource GUITextureField::getValue() const
 	{
 	{
-		return static_resource_cast<Texture>(Resources::instance()._getResourceHandle(mUUID));
+		return gResources()._getResourceHandle(mUUID);
 	}
 	}
 
 
-	void GUITextureField::setValue(const HTexture& value)
+	void GUITextureField::setValue(const HResource& value)
 	{
 	{
 		if (value)
 		if (value)
-			setUUID(value.getUUID(), false);
+		{
+			if (rtti_is_of_type<SpriteTexture>(value.get()) || rtti_is_of_type<Texture>(value.get()))
+				setUUID(value.getUUID(), false);
+			else
+				setUUID(UUID::EMPTY, false);
+		}
 		else
 		else
 			setUUID(UUID::EMPTY, false);
 			setUUID(UUID::EMPTY, false);
 	}
 	}
@@ -191,25 +152,31 @@ namespace bs
 
 
 		mUUID = uuid;
 		mUUID = uuid;
 
 
-		HTexture previewIcon;
+		HSpriteTexture previewIcon;
 
 
 		Path filePath = gProjectLibrary().uuidToPath(mUUID);
 		Path filePath = gProjectLibrary().uuidToPath(mUUID);
 		if (!filePath.isEmpty())
 		if (!filePath.isEmpty())
 		{
 		{
 			SPtr<ProjectResourceMeta> meta = gProjectLibrary().findResourceMeta(filePath);
 			SPtr<ProjectResourceMeta> meta = gProjectLibrary().findResourceMeta(filePath);
 			if(meta)
 			if(meta)
-				previewIcon = meta->getPreviewIcons().icon128;
+				previewIcon = SpriteTexture::create(meta->getPreviewIcons().icon128);
 			else
 			else
 			{
 			{
 				// Not ideal. No cached texture so fall back on loading the original asset
 				// Not ideal. No cached texture so fall back on loading the original asset
-				previewIcon = gResources().load<Texture>(filePath);
+				HResource resource = gResources().load(filePath);
+				if(resource.isLoaded(false))
+				{
+					if (rtti_is_of_type<SpriteTexture>(resource.get()))
+						previewIcon = static_resource_cast<SpriteTexture>(resource);
+					else if (rtti_is_of_type<Texture>(resource.get()))
+						previewIcon = SpriteTexture::create(static_resource_cast<Texture>(resource));
+				}
 			}
 			}
 		}
 		}
 		
 		
 		if (previewIcon != nullptr)
 		if (previewIcon != nullptr)
 		{
 		{
-			HSpriteTexture sprite = SpriteTexture::create(previewIcon);
-			mDropButton->setContent(GUIContent(sprite));
+			mDropButton->setContent(GUIContent(previewIcon));
 			mClearButton->setVisible(true);
 			mClearButton->setVisible(true);
 		}
 		}
 		else
 		else
@@ -219,7 +186,7 @@ namespace bs
 		}
 		}
 
 
 		if (triggerEvent)
 		if (triggerEvent)
-			onValueChanged(static_resource_cast<Texture>(gResources()._getResourceHandle(mUUID)));
+			onValueChanged(gResources()._getResourceHandle(mUUID));
 	}
 	}
 
 
 	void GUITextureField::setTint(const Color& color)
 	void GUITextureField::setTint(const Color& color)

+ 49 - 116
Source/EditorScript/BsGUITextureField.h

@@ -4,6 +4,7 @@
 
 
 #include "BsScriptEditorPrerequisites.h"
 #include "BsScriptEditorPrerequisites.h"
 #include "GUI/BsGUIElementContainer.h"
 #include "GUI/BsGUIElementContainer.h"
+#include "GUI/BsGUIFieldOptions.h"
 
 
 namespace bs
 namespace bs
 {
 {
@@ -11,159 +12,91 @@ namespace bs
 	 *  @{
 	 *  @{
 	 */
 	 */
 
 
+	/** Type that control what type of texture does a GUITexture field accept. */
+	enum class BS_SCRIPT_EXPORT(ed:true,m:GUI-Editor) GUITextureFieldType
+	{
+		Texture = 1,
+		SpriteTexture = 2,
+		TextureOrSpriteTexture = 3,
+	};
+
 	/**
 	/**
-	 * GUI object that displays a field in which a Texture can be dragged and dropped. The field accepts a Texture of a
-	 * specific type and displays an optional label. If texture is referenced its image is displayed in the field.
+	 * GUI object that displays a field in which a Texture or a SpriteTexture can be dragged and dropped. It also displays
+	 * an optional label field. When a texture is referenced its image is displayed in the field.
 	 */
 	 */
 	class BS_SCR_BED_EXPORT GUITextureField : public GUIElementContainer
 	class BS_SCR_BED_EXPORT GUITextureField : public GUIElementContainer
 	{
 	{
 		struct PrivatelyConstruct {};
 		struct PrivatelyConstruct {};
 
 
 	public:
 	public:
+		GUITextureField(const PrivatelyConstruct& dummy, GUITextureFieldType type, const GUIContent& labelContent,
+			UINT32 labelWidth, const String& style, const GUIDimensions& dimensions, bool withLabel);
+
 		/** Returns type name of the GUI element used for finding GUI element styles. */
 		/** Returns type name of the GUI element used for finding GUI element styles. */
 		static const String& getGUITypeName();
 		static const String& getGUITypeName();
 
 
 		/**
 		/**
-		 * Creates a new texture GUI editor field with a label.
-		 *
-		 * @param[in]	labelContent	Content to display in the editor field label.
-		 * @param[in]	labelWidth		Width of the label in pixels.
-		 * @param[in]	options			Options that allow you to control how is the element positioned and sized. This will
-		 *								override any similar options set by style.
-		 * @param[in]	style			Optional style to use for the element. Style will be retrieved from GUISkin of the
-		 *								GUIWidget the element is used on. If not specified default style is used.
-		 */
-		static GUITextureField* create(const GUIContent& labelContent, UINT32 labelWidth, const GUIOptions& options,
-			const String& style = StringUtil::BLANK);
-
-		/**
-		 * Creates a new texture GUI editor field with a label.
+		 * Creates a new texture GUI editor field.
 		 *
 		 *
-		 * @param[in]	labelContent	Content to display in the editor field label.
-		 * @param[in]	options			Options that allow you to control how is the element positioned and sized. This will
-		 *								override any similar options set by style.
-		 * @param[in]	style			Optional style to use for the element. Style will be retrieved from GUISkin of the
-		 *								GUIWidget the element is used on. If not specified default style is used.
+		 * @param[in]	type			Determines the type of texture the field should accept.
+		 * @param[in]	options			Options controlling the label, style and layout of the field.
 		 */
 		 */
-		static GUITextureField* create(const GUIContent& labelContent, const GUIOptions& options,
-			const String& style = StringUtil::BLANK);
+		static GUITextureField* create(GUITextureFieldType type, const GUIFieldOptions& options = GUIFieldOptions());
 
 
 		/**
 		/**
-		 * Creates a new texture GUI editor field with a label.
+		 * Creates a new texture GUI editor field that accepts a Texture.
 		 *
 		 *
-		 * @param[in]	labelText		Text to display in the editor field label.
-		 * @param[in]	labelWidth		Width of the label in pixels.
-		 * @param[in]	options			Options that allow you to control how is the element positioned and sized. This will
-		 *								override any similar options set by style.
-		 * @param[in]	style			Optional style to use for the element. Style will be retrieved from GUISkin of the
-		 *								GUIWidget the element is used on. If not specified default style is used.
+		 * @param[in]	options			Options controlling the label, style and layout of the field.
 		 */
 		 */
-		static GUITextureField* create(const HString& labelText, UINT32 labelWidth, const GUIOptions& options,
-			const String& style = StringUtil::BLANK);
+		static GUITextureField* create(const GUIFieldOptions& options = GUIFieldOptions());
 
 
-		/**
-		 * Creates a new texture GUI editor field with a label.
-		 *
-		 * @param[in]	labelText		Text to display in the editor field label.
-		 * @param[in]	options			Options that allow you to control how is the element positioned and sized. This will
-		 *								override any similar options set by style.
-		 * @param[in]	style			Optional style to use for the element. Style will be retrieved from GUISkin of the
-		 *								GUIWidget the element is used on. If not specified default style is used.
-		 */
-		static GUITextureField* create(const HString& labelText, const GUIOptions& options,
-			const String& style = StringUtil::BLANK);
-
-		/**
-		 * Creates a new texture GUI editor field without a label.
-		 *
-		 * @param[in]	options			Options that allow you to control how is the element positioned and sized. This will
-		 *								override any similar options set by style.
-		 * @param[in]	style			Optional style to use for the element. Style will be retrieved from GUISkin of the
-		 *								GUIWidget the element is used on. If not specified default style is used.
-		 */
-		static GUITextureField* create(const GUIOptions& options, const String& style = StringUtil::BLANK);
-
-		/**
-		 * Creates a new texture GUI editor field with a label.
-		 *
-		 * @param[in]	labelContent	Content to display in the editor field label.
-		 * @param[in]	labelWidth		Width of the label in pixels.
-		 * @param[in]	style			Optional style to use for the element. Style will be retrieved from GUISkin of the
-		 *								GUIWidget the element is used on. If not specified default style is used.
-		 */
-		static GUITextureField* create(const GUIContent& labelContent, UINT32 labelWidth,
-			const String& style = StringUtil::BLANK);
-
-		/**
-		 * Creates a new texture GUI editor field with a label.
-		 *
-		 * @param[in]	labelContent	Content to display in the editor field label.
-		 * @param[in]	style			Optional style to use for the element. Style will be retrieved from GUISkin of the
-		 *								GUIWidget the element is used on. If not specified default style is used.
-		 */
-		static GUITextureField* create(const GUIContent& labelContent,
-			const String& style = StringUtil::BLANK);
-
-		/**
-		 * Creates a new texture GUI editor field with a label.
-		 *
-		 * @param[in]	labelText		Text to display in the editor field label.
-		 * @param[in]	labelWidth		Width of the label in pixels.
-		 * @param[in]	style			Optional style to use for the element. Style will be retrieved from GUISkin of the
-		 *								GUIWidget the element is used on. If not specified default style is used.
+		/** 
+		 * Returns the texture referenced by the field, if any. Returns null if no texture is assigned, or if sprite 
+		 * texture is assigned.
 		 */
 		 */
-		static GUITextureField* create(const HString& labelText, UINT32 labelWidth,
-			const String& style = StringUtil::BLANK);
+		HTexture getTexture() const;
 
 
-		/**
-		 * Creates a new texture GUI editor field with a label.
-		 *
-		 * @param[in]	labelText		Text to display in the editor field label.
-		 * @param[in]	style			Optional style to use for the element. Style will be retrieved from GUISkin of the
-		 *								GUIWidget the element is used on. If not specified default style is used.
-		 */
-		static GUITextureField* create(const HString& labelText,
-			const String& style = StringUtil::BLANK);
+		/**	Sets the texture referenced by the field. */
+		void setTexture(const HTexture& value);
 
 
-		/**
-		 * Creates a new texture GUI editor field without a label.
-		 *
-		 * @param[in]	style			Optional style to use for the element. Style will be retrieved from GUISkin of the
-		 *								GUIWidget the element is used on. If not specified default style is used.
+		/** 
+		 * Returns the sprite texture referenced by the field, if any. Returns null if no sprite texture is assigned, or
+		 * if non-sprite texture is assigned.
 		 */
 		 */
-		static GUITextureField* create(const String& style = StringUtil::BLANK);
+		HSpriteTexture getSpriteTexture() const;
 
 
-		GUITextureField(const PrivatelyConstruct& dummy, const GUIContent& labelContent,
-			UINT32 labelWidth, const String& style, const GUIDimensions& dimensions, bool withLabel);
+		/**	Sets the sprite texture referenced by the field. */
+		void setSpriteTexture(const HSpriteTexture& value);
 
 
-		/** 
-		 * Returns the texture referenced by the field, if any. Note that this will not load the texture in case it's not
-		 * already loaded. 
-		 */
-		HTexture getValue() const;
+		/** Returns the normal or sprite texture referenced by the field, as a generic resource handle. */
+		HResource getValue() const;
 
 
-		/**	Sets the texture referenced by the field. */
-		void setValue(const HTexture& value);
+		/**	Sets the resource referenced by the field. */
+		void setValue(const HResource& value);
 
 
-		/**	Returns the texture referenced by the field. Returns empty string with no texture is referenced. */
+		/**	Returns the UUID of the resource referenced by the field. */
 		UUID getUUID() const { return mUUID; }
 		UUID getUUID() const { return mUUID; }
 
 
 		/** @copydoc GUIElement::setTint */
 		/** @copydoc GUIElement::setTint */
 		void setTint(const Color& color) override;
 		void setTint(const Color& color) override;
 
 
+		/** 
+		 * @name Internal
+		 * @{
+		 */
+
 		/** @copydoc GUIElement::_updateLayoutInternal */
 		/** @copydoc GUIElement::_updateLayoutInternal */
 		void _updateLayoutInternal(const GUILayoutData& data) override;
 		void _updateLayoutInternal(const GUILayoutData& data) override;
 
 
 		/** @copydoc GUIElement::_getOptimalSize */
 		/** @copydoc GUIElement::_getOptimalSize */
 		Vector2I _getOptimalSize() const override;
 		Vector2I _getOptimalSize() const override;
 
 
-		/**
-		 * Triggered whenever the referenced texture changes. Provides a weak handle to the resource, or empty handle if no
-		 * texture is referenced.
-		 */
-		Event<void(const HTexture&)> onValueChanged;
+		/** @} */
+
+		/** Triggered whenever the referenced texture changes. */
+		Event<void(const HResource&)> onValueChanged;
 	private:
 	private:
-		virtual ~GUITextureField();
+		virtual ~GUITextureField() = default;
 
 
 		/** @copydoc GUIElement::styleUpdated */
 		/** @copydoc GUIElement::styleUpdated */
 		void styleUpdated() override;
 		void styleUpdated() override;
@@ -197,4 +130,4 @@ namespace bs
 	};
 	};
 
 
 	/** @} */
 	/** @} */
-}
+}

+ 3 - 2
Source/EditorScript/Wrappers/GUI/BsScriptGUIResourceField.cpp

@@ -61,11 +61,12 @@ namespace bs
 		if (withTitle)
 		if (withTitle)
 		{
 		{
 			GUIContent nativeContent = ScriptGUIContent::fromInterop(*title);
 			GUIContent nativeContent = ScriptGUIContent::fromInterop(*title);
-			guiResourceField = GUIResourceField::create(typeNamespace, typeName, nativeContent, titleWidth, options, styleName);
+			guiResourceField = GUIResourceField::create(typeNamespace, typeName, 
+				GUIFieldOptions(nativeContent, titleWidth, options, styleName));
 		}
 		}
 		else
 		else
 		{
 		{
-			guiResourceField = GUIResourceField::create(typeNamespace, typeName, options, styleName);
+			guiResourceField = GUIResourceField::create(typeNamespace, typeName, GUIFieldOptions(options, styleName));
 		}
 		}
 
 
 		auto nativeInstance = new (bs_alloc<ScriptGUIResourceField>()) ScriptGUIResourceField(instance, guiResourceField);
 		auto nativeInstance = new (bs_alloc<ScriptGUIResourceField>()) ScriptGUIResourceField(instance, guiResourceField);

+ 129 - 14
Source/EditorScript/Wrappers/GUI/BsScriptGUITextureField.cpp

@@ -15,6 +15,7 @@
 #include "Generated/BsScriptGUIContent.generated.h"
 #include "Generated/BsScriptGUIContent.generated.h"
 #include "Generated/BsScriptTexture.generated.h"
 #include "Generated/BsScriptTexture.generated.h"
 #include "Wrappers/BsScriptRRefBase.h"
 #include "Wrappers/BsScriptRRefBase.h"
+#include "BsScriptSpriteTexture.generated.h"
 
 
 using namespace std::placeholders;
 using namespace std::placeholders;
 
 
@@ -31,6 +32,14 @@ namespace bs
 	void ScriptGUITextureField::initRuntimeData()
 	void ScriptGUITextureField::initRuntimeData()
 	{
 	{
 		metaData.scriptClass->addInternalCall("Internal_CreateInstance", (void*)&ScriptGUITextureField::internal_createInstance);
 		metaData.scriptClass->addInternalCall("Internal_CreateInstance", (void*)&ScriptGUITextureField::internal_createInstance);
+		metaData.scriptClass->addInternalCall("Internal_GetTexture", (void*)&ScriptGUITextureField::internal_getTexture);
+		metaData.scriptClass->addInternalCall("Internal_SetTexture", (void*)&ScriptGUITextureField::internal_setTexture);
+		metaData.scriptClass->addInternalCall("Internal_GetTextureRef", (void*)&ScriptGUITextureField::internal_getTextureRef);
+		metaData.scriptClass->addInternalCall("Internal_SetTextureRef", (void*)&ScriptGUITextureField::internal_setTextureRef);
+		metaData.scriptClass->addInternalCall("Internal_GetSpriteTexture", (void*)&ScriptGUITextureField::internal_getSpriteTexture);
+		metaData.scriptClass->addInternalCall("Internal_SetSpriteTexture", (void*)&ScriptGUITextureField::internal_setSpriteTexture);
+		metaData.scriptClass->addInternalCall("Internal_GetSpriteTextureRef", (void*)&ScriptGUITextureField::internal_getSpriteTextureRef);
+		metaData.scriptClass->addInternalCall("Internal_SetSpriteTextureRef", (void*)&ScriptGUITextureField::internal_setSpriteTextureRef);
 		metaData.scriptClass->addInternalCall("Internal_GetValue", (void*)&ScriptGUITextureField::internal_getValue);
 		metaData.scriptClass->addInternalCall("Internal_GetValue", (void*)&ScriptGUITextureField::internal_getValue);
 		metaData.scriptClass->addInternalCall("Internal_SetValue", (void*)&ScriptGUITextureField::internal_setValue);
 		metaData.scriptClass->addInternalCall("Internal_SetValue", (void*)&ScriptGUITextureField::internal_setValue);
 		metaData.scriptClass->addInternalCall("Internal_GetValueRef", (void*)&ScriptGUITextureField::internal_getValueRef);
 		metaData.scriptClass->addInternalCall("Internal_GetValueRef", (void*)&ScriptGUITextureField::internal_getValueRef);
@@ -40,8 +49,8 @@ namespace bs
 		onChangedThunk = (OnChangedThunkDef)metaData.scriptClass->getMethod("Internal_DoOnChanged", 1)->getThunk();
 		onChangedThunk = (OnChangedThunkDef)metaData.scriptClass->getMethod("Internal_DoOnChanged", 1)->getThunk();
 	}
 	}
 
 
-	void ScriptGUITextureField::internal_createInstance(MonoObject* instance, __GUIContentInterop* title, UINT32 titleWidth,
-		MonoString* style, MonoArray* guiOptions, bool withTitle)
+	void ScriptGUITextureField::internal_createInstance(MonoObject* instance, GUITextureFieldType type, 
+		__GUIContentInterop* title, UINT32 titleWidth, MonoString* style, MonoArray* guiOptions, bool withTitle)
 	{
 	{
 		GUIOptions options;
 		GUIOptions options;
 
 
@@ -56,22 +65,22 @@ namespace bs
 		if (withTitle)
 		if (withTitle)
 		{
 		{
 			GUIContent nativeContent = ScriptGUIContent::fromInterop(*title);
 			GUIContent nativeContent = ScriptGUIContent::fromInterop(*title);
-			guiTextureField = GUITextureField::create(nativeContent, titleWidth, options, styleName);
+			guiTextureField = GUITextureField::create(type, GUIFieldOptions(nativeContent, titleWidth, options, styleName));
 		}
 		}
 		else
 		else
 		{
 		{
-			guiTextureField = GUITextureField::create(options, styleName);
+			guiTextureField = GUITextureField::create(type, GUIFieldOptions(options, styleName));
 		}
 		}
 
 
 		auto nativeInstance = new (bs_alloc<ScriptGUITextureField>()) ScriptGUITextureField(instance, guiTextureField);
 		auto nativeInstance = new (bs_alloc<ScriptGUITextureField>()) ScriptGUITextureField(instance, guiTextureField);
 		guiTextureField->onValueChanged.connect(std::bind(&ScriptGUITextureField::onChanged, nativeInstance, _1));
 		guiTextureField->onValueChanged.connect(std::bind(&ScriptGUITextureField::onChanged, nativeInstance, _1));
 	}
 	}
 
 
-	void ScriptGUITextureField::internal_getValue(ScriptGUITextureField* nativeInstance, MonoObject** output)
+	void ScriptGUITextureField::internal_getTexture(ScriptGUITextureField* nativeInstance, MonoObject** output)
 	{
 	{
 		GUITextureField* textureField = static_cast<GUITextureField*>(nativeInstance->getGUIElement());
 		GUITextureField* textureField = static_cast<GUITextureField*>(nativeInstance->getGUIElement());
 
 
-		HTexture resource = textureField->getValue();
+		HTexture resource = textureField->getTexture();
 		if(resource)
 		if(resource)
 		{
 		{
 			const ResourceLoadFlags loadFlags = ResourceLoadFlag::Default | ResourceLoadFlag::KeepSourceData;
 			const ResourceLoadFlags loadFlags = ResourceLoadFlag::Default | ResourceLoadFlag::KeepSourceData;
@@ -81,16 +90,122 @@ namespace bs
 		MonoUtil::referenceCopy(output, nativeToManagedResource(resource));
 		MonoUtil::referenceCopy(output, nativeToManagedResource(resource));
 	}
 	}
 
 
+	void ScriptGUITextureField::internal_setTexture(ScriptGUITextureField* nativeInstance, MonoObject* value)
+	{
+		GUITextureField* textureField = static_cast<GUITextureField*>(nativeInstance->getGUIElement());
+
+		if (value == nullptr)
+			textureField->setTexture(HTexture());
+		else
+		{
+			ScriptTexture* scriptResource = ScriptTexture::toNative(value);
+			textureField->setTexture(scriptResource->getHandle());
+		}
+	}
+
+	void ScriptGUITextureField::internal_getTextureRef(ScriptGUITextureField* nativeInstance, MonoObject** output)
+	{
+		GUITextureField* textureField = static_cast<GUITextureField*>(nativeInstance->getGUIElement());
+
+		HTexture resource = textureField->getTexture();
+		ScriptRRefBase* scriptRRef = ScriptResourceManager::instance().getScriptRRef(resource);
+
+		if(scriptRRef)
+			MonoUtil::referenceCopy(output, scriptRRef->getManagedInstance());
+		else
+			MonoUtil::referenceCopy(output, nullptr);
+	}
+
+	void ScriptGUITextureField::internal_setTextureRef(ScriptGUITextureField* nativeInstance, MonoObject* value)
+	{
+		GUITextureField* textureField = static_cast<GUITextureField*>(nativeInstance->getGUIElement());
+
+		if (value == nullptr)
+			textureField->setTexture(HTexture());
+		else
+		{
+			ScriptRRefBase* scriptRRef = ScriptRRefBase::toNative(value);
+			textureField->setTexture(static_resource_cast<Texture>(scriptRRef->getHandle()));
+		}
+	}
+
+	void ScriptGUITextureField::internal_getSpriteTexture(ScriptGUITextureField* nativeInstance, MonoObject** output)
+	{
+		GUITextureField* textureField = static_cast<GUITextureField*>(nativeInstance->getGUIElement());
+
+		HSpriteTexture resource = textureField->getSpriteTexture();
+		if(resource)
+		{
+			const ResourceLoadFlags loadFlags = ResourceLoadFlag::Default | ResourceLoadFlag::KeepSourceData;
+			resource = static_resource_cast<SpriteTexture>(
+				Resources::instance().loadFromUUID(resource.getUUID(), false, loadFlags));
+		}
+
+		MonoUtil::referenceCopy(output, nativeToManagedResource(resource));
+	}
+
+	void ScriptGUITextureField::internal_setSpriteTexture(ScriptGUITextureField* nativeInstance, MonoObject* value)
+	{
+		GUITextureField* textureField = static_cast<GUITextureField*>(nativeInstance->getGUIElement());
+
+		if (value == nullptr)
+			textureField->setSpriteTexture(HSpriteTexture());
+		else
+		{
+			ScriptSpriteTexture* scriptResource = ScriptSpriteTexture::toNative(value);
+			textureField->setSpriteTexture(scriptResource->getHandle());
+		}
+	}
+
+	void ScriptGUITextureField::internal_getSpriteTextureRef(ScriptGUITextureField* nativeInstance, MonoObject** output)
+	{
+		GUITextureField* textureField = static_cast<GUITextureField*>(nativeInstance->getGUIElement());
+
+		HSpriteTexture resource = textureField->getSpriteTexture();
+		ScriptRRefBase* scriptRRef = ScriptResourceManager::instance().getScriptRRef(resource);
+
+		if(scriptRRef)
+			MonoUtil::referenceCopy(output, scriptRRef->getManagedInstance());
+		else
+			MonoUtil::referenceCopy(output, nullptr);
+	}
+
+	void ScriptGUITextureField::internal_setSpriteTextureRef(ScriptGUITextureField* nativeInstance, MonoObject* value)
+	{
+		GUITextureField* textureField = static_cast<GUITextureField*>(nativeInstance->getGUIElement());
+
+		if (value == nullptr)
+			textureField->setSpriteTexture(HSpriteTexture());
+		else
+		{
+			ScriptRRefBase* scriptRRef = ScriptRRefBase::toNative(value);
+			textureField->setSpriteTexture(static_resource_cast<SpriteTexture>(scriptRRef->getHandle()));
+		}
+	}
+	void ScriptGUITextureField::internal_getValue(ScriptGUITextureField* nativeInstance, MonoObject** output)
+	{
+		GUITextureField* textureField = static_cast<GUITextureField*>(nativeInstance->getGUIElement());
+
+		HResource resource = textureField->getValue();
+		if(resource)
+		{
+			const ResourceLoadFlags loadFlags = ResourceLoadFlag::Default | ResourceLoadFlag::KeepSourceData;
+			resource = Resources::instance().loadFromUUID(resource.getUUID(), false, loadFlags);
+		}
+
+		MonoUtil::referenceCopy(output, nativeToManagedResource(resource));
+	}
+
 	void ScriptGUITextureField::internal_setValue(ScriptGUITextureField* nativeInstance, MonoObject* value)
 	void ScriptGUITextureField::internal_setValue(ScriptGUITextureField* nativeInstance, MonoObject* value)
 	{
 	{
 		GUITextureField* textureField = static_cast<GUITextureField*>(nativeInstance->getGUIElement());
 		GUITextureField* textureField = static_cast<GUITextureField*>(nativeInstance->getGUIElement());
 
 
 		if (value == nullptr)
 		if (value == nullptr)
-			textureField->setValue(HTexture());
+			textureField->setValue(HResource());
 		else
 		else
 		{
 		{
-			ScriptTexture* scriptTexture = ScriptTexture::toNative(value);
-			textureField->setValue(static_resource_cast<Texture>(scriptTexture->getGenericHandle()));
+			ScriptResource* scriptResource = ScriptResource::toNative(value);
+			textureField->setValue(scriptResource->getGenericHandle());
 		}
 		}
 	}
 	}
 
 
@@ -98,7 +213,7 @@ namespace bs
 	{
 	{
 		GUITextureField* textureField = static_cast<GUITextureField*>(nativeInstance->getGUIElement());
 		GUITextureField* textureField = static_cast<GUITextureField*>(nativeInstance->getGUIElement());
 
 
-		HTexture resource = textureField->getValue();
+		HResource resource = textureField->getValue();
 		ScriptRRefBase* scriptRRef = ScriptResourceManager::instance().getScriptRRef(resource);
 		ScriptRRefBase* scriptRRef = ScriptResourceManager::instance().getScriptRRef(resource);
 
 
 		if(scriptRRef)
 		if(scriptRRef)
@@ -112,11 +227,11 @@ namespace bs
 		GUITextureField* textureField = static_cast<GUITextureField*>(nativeInstance->getGUIElement());
 		GUITextureField* textureField = static_cast<GUITextureField*>(nativeInstance->getGUIElement());
 
 
 		if (value == nullptr)
 		if (value == nullptr)
-			textureField->setValue(HTexture());
+			textureField->setValue(HResource());
 		else
 		else
 		{
 		{
 			ScriptRRefBase* scriptRRef = ScriptRRefBase::toNative(value);
 			ScriptRRefBase* scriptRRef = ScriptRRefBase::toNative(value);
-			textureField->setValue(static_resource_cast<Texture>(scriptRRef->getHandle()));
+			textureField->setValue(scriptRRef->getHandle());
 		}
 		}
 	}
 	}
 
 
@@ -126,7 +241,7 @@ namespace bs
 		textureField->setTint(*color);
 		textureField->setTint(*color);
 	}
 	}
 
 
-	void ScriptGUITextureField::onChanged(const HTexture& newHandle)
+	void ScriptGUITextureField::onChanged(const HResource& newHandle)
 	{
 	{
 		ScriptRRefBase* scriptRRef = ScriptResourceManager::instance().getScriptRRef(newHandle);
 		ScriptRRefBase* scriptRRef = ScriptResourceManager::instance().getScriptRRef(newHandle);
 
 
@@ -137,7 +252,7 @@ namespace bs
 		MonoUtil::invokeThunk(onChangedThunk, getManagedInstance(), managedObj);
 		MonoUtil::invokeThunk(onChangedThunk, getManagedInstance(), managedObj);
 	}
 	}
 
 
-	MonoObject* ScriptGUITextureField::nativeToManagedResource(const HTexture& instance)
+	MonoObject* ScriptGUITextureField::nativeToManagedResource(const HResource& instance)
 	{
 	{
 		if (instance == nullptr)
 		if (instance == nullptr)
 			return nullptr;
 			return nullptr;

+ 16 - 7
Source/EditorScript/Wrappers/GUI/BsScriptGUITextureField.h

@@ -4,6 +4,7 @@
 
 
 #include "BsScriptEditorPrerequisites.h"
 #include "BsScriptEditorPrerequisites.h"
 #include "Wrappers/GUI/BsScriptGUIElement.h"
 #include "Wrappers/GUI/BsScriptGUIElement.h"
+#include "BsGUITextureField.h"
 
 
 namespace bs
 namespace bs
 {
 {
@@ -25,10 +26,10 @@ namespace bs
 		 *
 		 *
 		 * @param[in]	newHandle	Handle of the new texture.
 		 * @param[in]	newHandle	Handle of the new texture.
 		 */
 		 */
-		void onChanged(const HTexture& newHandle);
+		void onChanged(const HResource& newHandle);
 
 
-		/** Retrieves a managed instance of the specified native texture. Will return null if one doesn't exist. */
-		static MonoObject* nativeToManagedResource(const HTexture& instance);
+		/** Retrieves a managed instance of the specified native resource. Will return null if one doesn't exist. */
+		static MonoObject* nativeToManagedResource(const HResource& instance);
 
 
 		ScriptGUITextureField(MonoObject* instance, GUITextureField* textureField);
 		ScriptGUITextureField(MonoObject* instance, GUITextureField* textureField);
 
 
@@ -36,9 +37,17 @@ namespace bs
 		/* 								CLR HOOKS						   		*/
 		/* 								CLR HOOKS						   		*/
 		/************************************************************************/
 		/************************************************************************/
 
 
-		static void internal_createInstance(MonoObject* instance, __GUIContentInterop* title, UINT32 titleWidth,
-			MonoString* style, MonoArray* guiOptions, bool withTitle);
-
+		static void internal_createInstance(MonoObject* instance, GUITextureFieldType type, __GUIContentInterop* title, 
+			UINT32 titleWidth, MonoString* style, MonoArray* guiOptions, bool withTitle);
+
+		static void internal_getTexture(ScriptGUITextureField* nativeInstance, MonoObject** output);
+		static void internal_setTexture(ScriptGUITextureField* nativeInstance, MonoObject* value);
+		static void internal_getTextureRef(ScriptGUITextureField* nativeInstance, MonoObject** output);
+		static void internal_setTextureRef(ScriptGUITextureField* nativeInstance, MonoObject* value);
+		static void internal_getSpriteTexture(ScriptGUITextureField* nativeInstance, MonoObject** output);
+		static void internal_setSpriteTexture(ScriptGUITextureField* nativeInstance, MonoObject* value);
+		static void internal_getSpriteTextureRef(ScriptGUITextureField* nativeInstance, MonoObject** output);
+		static void internal_setSpriteTextureRef(ScriptGUITextureField* nativeInstance, MonoObject* value);
 		static void internal_getValue(ScriptGUITextureField* nativeInstance, MonoObject** output);
 		static void internal_getValue(ScriptGUITextureField* nativeInstance, MonoObject** output);
 		static void internal_setValue(ScriptGUITextureField* nativeInstance, MonoObject* value);
 		static void internal_setValue(ScriptGUITextureField* nativeInstance, MonoObject* value);
 		static void internal_getValueRef(ScriptGUITextureField* nativeInstance, MonoObject** output);
 		static void internal_getValueRef(ScriptGUITextureField* nativeInstance, MonoObject** output);
@@ -51,4 +60,4 @@ namespace bs
 	};
 	};
 
 
 	/** @} */
 	/** @} */
-}
+}

+ 1 - 1
Source/bsf

@@ -1 +1 @@
-Subproject commit 718f666fc21cce229ef820fe6aa10326a7c6fefb
+Subproject commit 3f50acd5ad97cb09ba307fabb14e0507c42a428c