using System; using System.Runtime.CompilerServices; namespace BansheeEngine { /// /// Allows you to display a render texture in the GUI. Has the same functionality as GUITexture, but also forwards any /// input to underlying GUI elements being rendered on the provided render texture. /// public sealed class GUIRenderTexture : GUIElement { private RenderTexture2D renderTexture; /// /// Render texture that is displayed on the GUI element. /// public RenderTexture2D RenderTexture { get { return renderTexture; } set { IntPtr texturePtr = IntPtr.Zero; if (value != null) texturePtr = value.GetCachedPtr(); renderTexture = value; Internal_SetTexture(mCachedPtr, texturePtr); } } /// /// Creates a new render texture element. /// /// Render texture to display in the element. /// 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. /// /// Options that allow you to control how is the element positioned and sized. This will /// override any similar options set by style. /// public GUIRenderTexture(RenderTexture2D texture, string style, params GUIOption[] options) { IntPtr texturePtr = IntPtr.Zero; if (texture != null) texturePtr = texture.GetCachedPtr(); Internal_CreateInstance(this, texturePtr, style, options); } /// /// Creates a new render texture element. /// /// Render texture to display in the element. /// Options that allow you to control how is the element positioned and sized. This will /// override any similar options set by style. /// public GUIRenderTexture(RenderTexture2D texture, params GUIOption[] options) { IntPtr texturePtr = IntPtr.Zero; if (texture != null) texturePtr = texture.GetCachedPtr(); Internal_CreateInstance(this, texturePtr, "", options); } /// /// Colors the element with a specific tint. /// /// Tint to apply to the element. public void SetTint(Color color) { Internal_SetTint(mCachedPtr, color); } [MethodImpl(MethodImplOptions.InternalCall)] private static extern void Internal_CreateInstance(GUIRenderTexture instance, IntPtr texture, string style, GUIOption[] options); [MethodImpl(MethodImplOptions.InternalCall)] private static extern void Internal_SetTexture(IntPtr nativeInstance, IntPtr texture); [MethodImpl(MethodImplOptions.InternalCall)] private static extern void Internal_SetTint(IntPtr nativeInstance, Color color); } }