//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
//**************** Copyright (c) 2016 Marko Pintera (marko.pintera@gmail.com). All rights reserved. **********************//
using System.Runtime.CompilerServices;
namespace BansheeEngine
{
/** @addtogroup GUI_Engine
* @{
*/
public partial struct GUIContent
{
///
/// Returns image content (if any).
///
public SpriteTexture GetImage(GUIElementState state = GUIElementState.Normal)
{
switch (state)
{
case GUIElementState.Normal:
return images.normal;
case GUIElementState.Hover:
return images.hover;
case GUIElementState.Active:
return images.active;
case GUIElementState.Focused:
return images.focused;
case GUIElementState.NormalOn:
return images.normalOn;
case GUIElementState.HoverOn:
return images.hoverOn;
case GUIElementState.ActiveOn:
return images.activeOn;
case GUIElementState.FocusedOn:
return images.focusedOn;
default:
return images.normal;
}
}
///
/// Implicitly converts a localized string into a GUI content containing only text.
///
/// Localized string to initialize the GUI content with.
/// GUI content containing only a string.
public static implicit operator GUIContent(LocString text)
{
return new GUIContent(text);
}
///
/// Implicitly converts a string into a GUI content containing only text.
///
/// String to initialize the GUI content with.
/// GUI content containing only a string.
public static implicit operator GUIContent(string text)
{
return new GUIContent(new LocString(text));
}
}
public partial struct GUIContentImages
{
///
/// Creates a new object where content images for on and off states are different.
///
/// Image to assign to all off states.
/// Image to assign to all on states.
public GUIContentImages(SpriteTexture imageOff, SpriteTexture imageOn)
{
normal = imageOff;
hover = imageOff;
active = imageOff;
focused = imageOff;
normalOn = imageOn;
hoverOn = imageOn;
activeOn = imageOn;
focusedOn = imageOn;
}
///
/// Implicitly converts a sprite texture into a GUI content images object.
///
/// Image to instantiate the GUI content images with.
/// GUI content images with all states set to the provided image.
public static implicit operator GUIContentImages(SpriteTexture image)
{
return new GUIContentImages(image);
}
}
/** @} */
}