Browse Source

Added RTTI for GUISkin and GUIElementStyle

Marko Pintera 10 years ago
parent
commit
55d20b27b9

+ 2 - 2
BansheeEditor/Include/BsBuiltinEditorResources.h

@@ -12,7 +12,7 @@ namespace BansheeEngine
 	public:
 		BuiltinEditorResources();
 
-		const GUISkin& getSkin() const { return mSkin; }
+		const HGUISkin& getSkin() const { return mSkin; }
 
 		/**
 		 * @brief	Creates a material used for docking drop overlay used by the editor.
@@ -121,7 +121,7 @@ namespace BansheeEngine
 		HShader mShaderHandleWire;
 		HShader mShaderSelection;
 
-		GUISkin mSkin;
+		HGUISkin mSkin;
 
 		static const Path DefaultSkinFolderRaw;
 		static const Path DefaultShaderFolderRaw;

+ 1 - 1
BansheeEditor/Include/BsGUIWindowFrameWidget.h

@@ -9,7 +9,7 @@ namespace BansheeEngine
 	class WindowFrameWidget : public GUIWidget
 	{
 	public:
-		WindowFrameWidget(const HSceneObject& parent, bool allowResize, Viewport* target, RenderWindow* ownerWindow, const GUISkin& skin);
+		WindowFrameWidget(const HSceneObject& parent, bool allowResize, Viewport* target, RenderWindow* ownerWindow, const HGUISkin& skin);
 		virtual ~WindowFrameWidget();
 
 	protected:

+ 80 - 78
BansheeEditor/Source/BsBuiltinEditorResources.cpp

@@ -223,6 +223,8 @@ namespace BansheeEngine
 		mShaderHandleWire = getShader(ShaderWireHandleFile);
 		mShaderSelection = getShader(ShaderSelectionFile);
 
+		mSkin = GUISkin::create();
+
 		Path fontPath = FileSystem::getWorkingDirectoryPath();
 		fontPath.append(DefaultSkinFolder);
 		fontPath.append(DefaultFontFilename + L".asset");
@@ -238,7 +240,7 @@ namespace BansheeEngine
 		labelStyle.height = 11;
 		labelStyle.minWidth = 10;
 
-		mSkin.setStyle(GUILabel::getGUITypeName(), labelStyle);
+		mSkin->setStyle(GUILabel::getGUITypeName(), labelStyle);
 
 		// Window frame
 		GUIElementStyle windowFrameStyle;
@@ -249,7 +251,7 @@ namespace BansheeEngine
 		windowFrameStyle.border.top = 1;
 		windowFrameStyle.border.bottom = 1;
 
-		mSkin.setStyle("WindowFrame", windowFrameStyle);
+		mSkin->setStyle("WindowFrame", windowFrameStyle);
 
 		// Button
 		GUIElementStyle buttonStyle;
@@ -273,7 +275,7 @@ namespace BansheeEngine
 		buttonStyle.textHorzAlign = THA_Center;
 		buttonStyle.textVertAlign = TVA_Center;
 
-		mSkin.setStyle(GUIButton::getGUITypeName(), buttonStyle);
+		mSkin->setStyle(GUIButton::getGUITypeName(), buttonStyle);
 
 		// Toggle
 		GUIElementStyle toggleStyle;
@@ -288,7 +290,7 @@ namespace BansheeEngine
 		toggleStyle.height = 15;
 		toggleStyle.width = 15;
 
-		mSkin.setStyle(GUIToggle::getGUITypeName(), toggleStyle);
+		mSkin->setStyle(GUIToggle::getGUITypeName(), toggleStyle);
 
 		// Color
 		GUIElementStyle colorStyle;
@@ -300,13 +302,13 @@ namespace BansheeEngine
 		colorStyle.height = 10;
 		colorStyle.minWidth = 10;
 
-		mSkin.setStyle(GUIColor::getGUITypeName(), colorStyle);
+		mSkin->setStyle(GUIColor::getGUITypeName(), colorStyle);
 
 		// Window background texture
 		GUIElementStyle windowBgStyle;
 		windowBgStyle.normal.texture = getGUITexture(WindowBackgroundTexture);
 
-		mSkin.setStyle("WindowBackground", windowBgStyle);
+		mSkin->setStyle("WindowBackground", windowBgStyle);
 
 		// Window title bar background
 		GUIElementStyle titleBarBgStyle;
@@ -314,7 +316,7 @@ namespace BansheeEngine
 		titleBarBgStyle.fixedHeight = true;
 		titleBarBgStyle.height = 13;
 
-		mSkin.setStyle("TitleBarBackground", titleBarBgStyle);
+		mSkin->setStyle("TitleBarBackground", titleBarBgStyle);
 
 		// Tabbed title bar tab button
 		GUIElementStyle tabbedBarButton;
@@ -333,7 +335,7 @@ namespace BansheeEngine
 		tabbedBarButton.textHorzAlign = THA_Center;
 		tabbedBarButton.textVertAlign = TVA_Center;
 
-		mSkin.setStyle("TabbedBarBtn", tabbedBarButton);
+		mSkin->setStyle("TabbedBarBtn", tabbedBarButton);
 
 		// Tabbed title bar drag/drop button
 		GUIElementStyle tabbedBarDropButton;
@@ -342,7 +344,7 @@ namespace BansheeEngine
 		tabbedBarDropButton.height = 13;
 		tabbedBarDropButton.width = 6;
 
-		mSkin.setStyle("TabbedBarDropArea", tabbedBarDropButton);
+		mSkin->setStyle("TabbedBarDropArea", tabbedBarDropButton);
 
 		// Window minimize button
 		GUIElementStyle winMinButtonStyle;
@@ -354,7 +356,7 @@ namespace BansheeEngine
 		winMinButtonStyle.height = 7;
 		winMinButtonStyle.width = 8;
 
-		mSkin.setStyle("WinMinimizeBtn", winMinButtonStyle);
+		mSkin->setStyle("WinMinimizeBtn", winMinButtonStyle);
 
 		// Window maximize button
 		GUIElementStyle winMaxButtonStyle;
@@ -366,7 +368,7 @@ namespace BansheeEngine
 		winMaxButtonStyle.height = 8;
 		winMaxButtonStyle.width = 8;
 
-		mSkin.setStyle("WinMaximizeBtn", winMaxButtonStyle);
+		mSkin->setStyle("WinMaximizeBtn", winMaxButtonStyle);
 
 		// Window close button
 		GUIElementStyle winCloseButtonStyle;
@@ -378,7 +380,7 @@ namespace BansheeEngine
 		winCloseButtonStyle.height = 7;
 		winCloseButtonStyle.width = 8;
 
-		mSkin.setStyle("WinCloseBtn", winCloseButtonStyle);
+		mSkin->setStyle("WinCloseBtn", winCloseButtonStyle);
 
 		// Input box
 		GUIElementStyle inputBoxStyle;
@@ -402,7 +404,7 @@ namespace BansheeEngine
 		inputBoxStyle.textHorzAlign = THA_Left;
 		inputBoxStyle.textVertAlign = TVA_Top;
 
-		mSkin.setStyle(GUIInputBox::getGUITypeName(), inputBoxStyle);
+		mSkin->setStyle(GUIInputBox::getGUITypeName(), inputBoxStyle);
 
 		/************************************************************************/
 		/* 								SCROLL BAR                      		*/
@@ -418,7 +420,7 @@ namespace BansheeEngine
 		scrollUpBtnStyle.height = 4;
 		scrollUpBtnStyle.width = 8;
 
-		mSkin.setStyle("ScrollUpBtn", scrollUpBtnStyle);
+		mSkin->setStyle("ScrollUpBtn", scrollUpBtnStyle);
 
 		// Down button
 		GUIElementStyle scrollDownBtnStyle;
@@ -430,7 +432,7 @@ namespace BansheeEngine
 		scrollDownBtnStyle.height = 4;
 		scrollDownBtnStyle.width = 8;
 
-		mSkin.setStyle("ScrollDownBtn", scrollDownBtnStyle);
+		mSkin->setStyle("ScrollDownBtn", scrollDownBtnStyle);
 
 		// Left button
 		GUIElementStyle scrollLeftBtnStyle;
@@ -442,7 +444,7 @@ namespace BansheeEngine
 		scrollLeftBtnStyle.height = 8;
 		scrollLeftBtnStyle.width = 4;
 
-		mSkin.setStyle("ScrollLeftBtn", scrollLeftBtnStyle);
+		mSkin->setStyle("ScrollLeftBtn", scrollLeftBtnStyle);
 
 		// Right button
 		GUIElementStyle scrollRightBtnStyle;
@@ -454,7 +456,7 @@ namespace BansheeEngine
 		scrollRightBtnStyle.height = 8;
 		scrollRightBtnStyle.width = 4;
 
-		mSkin.setStyle("ScrollRightBtn", scrollRightBtnStyle);
+		mSkin->setStyle("ScrollRightBtn", scrollRightBtnStyle);
 
 		// Horizontal handle
 		GUIElementStyle scrollBarHorzBtnStyle;
@@ -466,7 +468,7 @@ namespace BansheeEngine
 		scrollBarHorzBtnStyle.height = 6;
 		scrollBarHorzBtnStyle.width = 4;
 
-		mSkin.setStyle("ScrollBarHorzBtn", scrollBarHorzBtnStyle);
+		mSkin->setStyle("ScrollBarHorzBtn", scrollBarHorzBtnStyle);
 
 		// Vertical handle
 		GUIElementStyle scrollBarVertBtnStyle;
@@ -478,7 +480,7 @@ namespace BansheeEngine
 		scrollBarVertBtnStyle.height = 4;
 		scrollBarVertBtnStyle.width = 6;
 
-		mSkin.setStyle("ScrollBarVertBtn", scrollBarVertBtnStyle);
+		mSkin->setStyle("ScrollBarVertBtn", scrollBarVertBtnStyle);
 
 		HSpriteTexture scrollBarBgPtr = getGUITexture(ScrollBarBgTex);
 
@@ -492,7 +494,7 @@ namespace BansheeEngine
 		vertScrollBarStyle.minHeight = 16;
 		vertScrollBarStyle.width = 8;
 
-		mSkin.setStyle("ScrollBarVert", vertScrollBarStyle);
+		mSkin->setStyle("ScrollBarVert", vertScrollBarStyle);
 
 		// Horizontal scroll bar
 		GUIElementStyle horzScrollBarStyle;
@@ -504,7 +506,7 @@ namespace BansheeEngine
 		horzScrollBarStyle.minWidth = 16;
 		horzScrollBarStyle.height = 8;
 
-		mSkin.setStyle("ScrollBarHorz", horzScrollBarStyle);
+		mSkin->setStyle("ScrollBarHorz", horzScrollBarStyle);
 
 		/************************************************************************/
 		/* 								DROP DOWN BOX                      		*/
@@ -535,7 +537,7 @@ namespace BansheeEngine
 		dropDownListStyle.textHorzAlign = THA_Left;
 		dropDownListStyle.textVertAlign = TVA_Top;
 
-		mSkin.setStyle("ListBox", dropDownListStyle);
+		mSkin->setStyle("ListBox", dropDownListStyle);
 
 		// DropDown scroll up button arrow
 		HSpriteTexture dropDownBtnScrollUpArrow = getGUITexture(DropDownBoxBtnUpArrowTex);
@@ -553,9 +555,9 @@ namespace BansheeEngine
 		dropDownScrollUpBtnArrowStyle.border.top = 1;
 		dropDownScrollUpBtnArrowStyle.border.bottom = 1;
 
-		mSkin.setStyle("ListBoxScrollUpBtnArrow", dropDownScrollUpBtnArrowStyle);
-		mSkin.setStyle("MenuBarScrollUpBtnArrow", dropDownScrollUpBtnArrowStyle);
-		mSkin.setStyle("ContextMenuScrollUpBtnArrow", dropDownScrollUpBtnArrowStyle);
+		mSkin->setStyle("ListBoxScrollUpBtnArrow", dropDownScrollUpBtnArrowStyle);
+		mSkin->setStyle("MenuBarScrollUpBtnArrow", dropDownScrollUpBtnArrowStyle);
+		mSkin->setStyle("ContextMenuScrollUpBtnArrow", dropDownScrollUpBtnArrowStyle);
 
 		// DropDown scroll up button
 		GUIElementStyle dropDownScrollUpBtnStyle;
@@ -571,9 +573,9 @@ namespace BansheeEngine
 		dropDownScrollUpBtnStyle.border.top = 1;
 		dropDownScrollUpBtnStyle.border.bottom = 1;
 
-		mSkin.setStyle("ListBoxScrollUpBtn", dropDownScrollUpBtnStyle);
-		mSkin.setStyle("MenuBarScrollUpBtn", dropDownScrollUpBtnStyle);
-		mSkin.setStyle("ContextMenuScrollUpBtn", dropDownScrollUpBtnStyle);
+		mSkin->setStyle("ListBoxScrollUpBtn", dropDownScrollUpBtnStyle);
+		mSkin->setStyle("MenuBarScrollUpBtn", dropDownScrollUpBtnStyle);
+		mSkin->setStyle("ContextMenuScrollUpBtn", dropDownScrollUpBtnStyle);
 
 		// DropDown scroll down button arrow
 		GUIElementStyle dropDownScrollDownBtnArrowStyle;
@@ -589,9 +591,9 @@ namespace BansheeEngine
 		dropDownScrollDownBtnArrowStyle.border.top = 1;
 		dropDownScrollDownBtnArrowStyle.border.bottom = 1;
 
-		mSkin.setStyle("ListBoxScrollDownBtnArrow", dropDownScrollDownBtnArrowStyle);
-		mSkin.setStyle("MenuBarScrollDownBtnArrow", dropDownScrollDownBtnArrowStyle);
-		mSkin.setStyle("ContextMenuScrollDownBtnArrow", dropDownScrollDownBtnArrowStyle);
+		mSkin->setStyle("ListBoxScrollDownBtnArrow", dropDownScrollDownBtnArrowStyle);
+		mSkin->setStyle("MenuBarScrollDownBtnArrow", dropDownScrollDownBtnArrowStyle);
+		mSkin->setStyle("ContextMenuScrollDownBtnArrow", dropDownScrollDownBtnArrowStyle);
 
 		// DropDown scroll down button
 		GUIElementStyle dropDownScrollDownBtnStyle;
@@ -607,9 +609,9 @@ namespace BansheeEngine
 		dropDownScrollDownBtnStyle.border.top = 1;
 		dropDownScrollDownBtnStyle.border.bottom = 1;
 
-		mSkin.setStyle("ListBoxScrollDownBtn", dropDownScrollDownBtnStyle);
-		mSkin.setStyle("MenuBarScrollDownBtn", dropDownScrollDownBtnStyle);
-		mSkin.setStyle("ContextMenuScrollDownBtn", dropDownScrollDownBtnStyle);
+		mSkin->setStyle("ListBoxScrollDownBtn", dropDownScrollDownBtnStyle);
+		mSkin->setStyle("MenuBarScrollDownBtn", dropDownScrollDownBtnStyle);
+		mSkin->setStyle("ContextMenuScrollDownBtn", dropDownScrollDownBtnStyle);
 
 		// DropDown entry button
 		GUIElementStyle dropDownEntryBtnStyle;
@@ -632,7 +634,7 @@ namespace BansheeEngine
 		dropDownEntryBtnStyle.textHorzAlign = THA_Left;
 		dropDownEntryBtnStyle.textVertAlign = TVA_Top;
 
-		mSkin.setStyle(GUIDropDownContent::ENTRY_STYLE_TYPE, dropDownEntryBtnStyle);
+		mSkin->setStyle(GUIDropDownContent::ENTRY_STYLE_TYPE, dropDownEntryBtnStyle);
 
 		// DropDown entry button with expand
 		GUIElementStyle dropDownEntryExpBtnStyle;
@@ -655,7 +657,7 @@ namespace BansheeEngine
 		dropDownEntryExpBtnStyle.textHorzAlign = THA_Left;
 		dropDownEntryExpBtnStyle.textVertAlign = TVA_Top;
 
-		mSkin.setStyle(GUIDropDownContent::ENTRY_EXP_STYLE_TYPE, dropDownEntryExpBtnStyle);
+		mSkin->setStyle(GUIDropDownContent::ENTRY_EXP_STYLE_TYPE, dropDownEntryExpBtnStyle);
 
 		// Drop down separator
 		GUIElementStyle dropDownSeparatorStyle;
@@ -669,7 +671,7 @@ namespace BansheeEngine
 		dropDownSeparatorStyle.border.top = 1;
 		dropDownSeparatorStyle.border.bottom = 1;
 
-		mSkin.setStyle(GUIDropDownContent::SEPARATOR_STYLE_TYPE, dropDownSeparatorStyle);
+		mSkin->setStyle(GUIDropDownContent::SEPARATOR_STYLE_TYPE, dropDownSeparatorStyle);
 
 		// Drop down content
 		GUIElementStyle dropDownContentStyle;
@@ -679,9 +681,9 @@ namespace BansheeEngine
 		dropDownContentStyle.subStyles[GUIDropDownContent::ENTRY_EXP_STYLE_TYPE] = GUIDropDownContent::ENTRY_EXP_STYLE_TYPE;
 		dropDownContentStyle.subStyles[GUIDropDownContent::SEPARATOR_STYLE_TYPE] = GUIDropDownContent::SEPARATOR_STYLE_TYPE;
 
-		mSkin.setStyle("ListBoxContent", dropDownContentStyle);
-		mSkin.setStyle("MenuBarContent", dropDownContentStyle);
-		mSkin.setStyle("ContextMenuContent", dropDownContentStyle);
+		mSkin->setStyle("ListBoxContent", dropDownContentStyle);
+		mSkin->setStyle("MenuBarContent", dropDownContentStyle);
+		mSkin->setStyle("ContextMenuContent", dropDownContentStyle);
 
 		// DropDown box frame
 		GUIElementStyle dropDownBoxStyle;
@@ -699,9 +701,9 @@ namespace BansheeEngine
 		dropDownBoxStyle.margins.top = 1;
 		dropDownBoxStyle.margins.bottom = 1;
 
-		mSkin.setStyle("ListBoxFrame", dropDownBoxStyle);
-		mSkin.setStyle("MenuBarFrame", dropDownBoxStyle);
-		mSkin.setStyle("ContextMenuFrame", dropDownBoxStyle);
+		mSkin->setStyle("ListBoxFrame", dropDownBoxStyle);
+		mSkin->setStyle("MenuBarFrame", dropDownBoxStyle);
+		mSkin->setStyle("ContextMenuFrame", dropDownBoxStyle);
 
 		/************************************************************************/
 		/* 								MENU BAR	                     		*/
@@ -715,7 +717,7 @@ namespace BansheeEngine
 		menuBarBgStyle.height = 4;
 		menuBarBgStyle.width = 4;
 
-		mSkin.setStyle("MenuBarBg", menuBarBgStyle);
+		mSkin->setStyle("MenuBarBg", menuBarBgStyle);
 
 		// MenuBar Banshee logo
 		GUIElementStyle menuBarBansheeLogoStyle;
@@ -725,7 +727,7 @@ namespace BansheeEngine
 		menuBarBansheeLogoStyle.height = 7;
 		menuBarBansheeLogoStyle.width = 51;
 
-		mSkin.setStyle("MenuBarBansheeLogo", menuBarBansheeLogoStyle);
+		mSkin->setStyle("MenuBarBansheeLogo", menuBarBansheeLogoStyle);
 
 		// MenuBar button
 		GUIElementStyle menuBarBtnStyle;
@@ -748,7 +750,7 @@ namespace BansheeEngine
 		menuBarBtnStyle.textHorzAlign = THA_Left;
 		menuBarBtnStyle.textVertAlign = TVA_Top;
 
-		mSkin.setStyle("MenuBarBtn", menuBarBtnStyle);
+		mSkin->setStyle("MenuBarBtn", menuBarBtnStyle);
 
 		/************************************************************************/
 		/* 								DOCK SLIDER	                     		*/
@@ -761,7 +763,7 @@ namespace BansheeEngine
 		dockSliderBtnStyle.height = 2;
 		dockSliderBtnStyle.width = 2;
 
-		mSkin.setStyle("DockSliderBtn", dockSliderBtnStyle);
+		mSkin->setStyle("DockSliderBtn", dockSliderBtnStyle);
 
 		/************************************************************************/
 		/* 								TREE VIEW	                     		*/
@@ -784,7 +786,7 @@ namespace BansheeEngine
 		treeViewExpandButtonStyle.height = 16;
 		treeViewExpandButtonStyle.width = 16;
 
-		mSkin.setStyle("TreeViewFoldoutBtn", treeViewExpandButtonStyle);
+		mSkin->setStyle("TreeViewFoldoutBtn", treeViewExpandButtonStyle);
 
 		// Entry
 		GUIElementStyle treeViewEntryStyle;
@@ -795,7 +797,7 @@ namespace BansheeEngine
 		treeViewEntryStyle.height = 16;
 		treeViewEntryStyle.minWidth = 10;
 
-		mSkin.setStyle("TreeViewElementBtn", treeViewEntryStyle);
+		mSkin->setStyle("TreeViewElementBtn", treeViewEntryStyle);
 
 		// Selection background
 		GUIElementStyle treeViewSelBackgroundStyle;
@@ -805,7 +807,7 @@ namespace BansheeEngine
 		treeViewSelBackgroundStyle.height = 2;
 		treeViewSelBackgroundStyle.width = 2;
 
-		mSkin.setStyle("TreeViewSelectionBackground", treeViewSelBackgroundStyle);
+		mSkin->setStyle("TreeViewSelectionBackground", treeViewSelBackgroundStyle);
 
 		// Edit box
 		GUIElementStyle treeViewEditBox;
@@ -829,7 +831,7 @@ namespace BansheeEngine
 		treeViewEditBox.textHorzAlign = THA_Left;
 		treeViewEditBox.textVertAlign = TVA_Top;
 
-		mSkin.setStyle(GUITreeViewEditBox::getGUITypeName(), treeViewEditBox);
+		mSkin->setStyle(GUITreeViewEditBox::getGUITypeName(), treeViewEditBox);
 
 		// Element highlight
 		GUIElementStyle treeViewElementHighlight;
@@ -839,7 +841,7 @@ namespace BansheeEngine
 		treeViewElementHighlight.border.top = 1;
 		treeViewElementHighlight.border.bottom = 1;
 
-		mSkin.setStyle("TreeViewElementHighlight", treeViewElementHighlight);
+		mSkin->setStyle("TreeViewElementHighlight", treeViewElementHighlight);
 
 		// Element separator highlight
 		GUIElementStyle treeViewElementSepHighlight;
@@ -849,7 +851,7 @@ namespace BansheeEngine
 		treeViewElementSepHighlight.border.top = 1;
 		treeViewElementSepHighlight.border.bottom = 1;
 
-		mSkin.setStyle("TreeViewElementSepHighlight", treeViewElementSepHighlight);
+		mSkin->setStyle("TreeViewElementSepHighlight", treeViewElementSepHighlight);
 	
 		/************************************************************************/
 		/* 							OBJECT DROP FIELD                      		*/
@@ -865,7 +867,7 @@ namespace BansheeEngine
 		objectDropStyle.textHorzAlign = THA_Center;
 		objectDropStyle.textVertAlign = TVA_Center;
 
-		mSkin.setStyle(ObjectFieldDropBtnStyleName, objectDropStyle);
+		mSkin->setStyle(ObjectFieldDropBtnStyleName, objectDropStyle);
 
 		GUIElementStyle objectClearBtnStyle;
 		objectClearBtnStyle.normal.texture = getGUITexture(ObjectClearBtnNormalTex);
@@ -876,7 +878,7 @@ namespace BansheeEngine
 		objectClearBtnStyle.height = 15;
 		objectClearBtnStyle.width = 13;
 
-		mSkin.setStyle(ObjectFieldClearBtnStyleName, objectClearBtnStyle);
+		mSkin->setStyle(ObjectFieldClearBtnStyleName, objectClearBtnStyle);
 
 		GUIElementStyle editorObjectFieldStyle;
 		editorObjectFieldStyle.fixedHeight = true;
@@ -886,7 +888,7 @@ namespace BansheeEngine
 		editorObjectFieldStyle.subStyles[ObjectFieldDropBtnStyleName] = ObjectFieldDropBtnStyleName;
 		editorObjectFieldStyle.subStyles[ObjectFieldClearBtnStyleName] = ObjectFieldClearBtnStyleName;
 
-		mSkin.setStyle(ObjectFieldStyleName, editorObjectFieldStyle);
+		mSkin->setStyle(ObjectFieldStyleName, editorObjectFieldStyle);
 
 		/************************************************************************/
 		/* 								EDITOR FIELDS                      		*/
@@ -901,7 +903,7 @@ namespace BansheeEngine
 		editorFieldLabelStyle.minWidth = 10;
 		editorFieldLabelStyle.textHorzAlign = THA_Left;
 
-		mSkin.setStyle(GUITextField::getLabelStyleType(), editorFieldLabelStyle);
+		mSkin->setStyle(GUITextField::getLabelStyleType(), editorFieldLabelStyle);
 
 		GUIElementStyle editorIntFieldStyle;
 		editorIntFieldStyle.fixedHeight = true;
@@ -910,7 +912,7 @@ namespace BansheeEngine
 		editorIntFieldStyle.subStyles[GUIIntField::getLabelStyleType()] = GUITextField::getLabelStyleType();
 		editorIntFieldStyle.subStyles[GUIIntField::getInputStyleType()] = GUIInputBox::getGUITypeName();
 
-		mSkin.setStyle(GUIIntField::getGUITypeName(), editorIntFieldStyle);
+		mSkin->setStyle(GUIIntField::getGUITypeName(), editorIntFieldStyle);
 
 		GUIElementStyle editorFloatFieldStyle;
 		editorFloatFieldStyle.fixedHeight = true;
@@ -919,7 +921,7 @@ namespace BansheeEngine
 		editorFloatFieldStyle.subStyles[GUIFloatField::getLabelStyleType()] = GUITextField::getLabelStyleType();
 		editorFloatFieldStyle.subStyles[GUIFloatField::getInputStyleType()] = GUIInputBox::getGUITypeName();
 
-		mSkin.setStyle(GUIFloatField::getGUITypeName(), editorFloatFieldStyle);
+		mSkin->setStyle(GUIFloatField::getGUITypeName(), editorFloatFieldStyle);
 
 		GUIElementStyle editorTextFieldStyle;
 		editorTextFieldStyle.fixedHeight = true;
@@ -928,7 +930,7 @@ namespace BansheeEngine
 		editorTextFieldStyle.subStyles[GUITextField::getLabelStyleType()] = GUITextField::getLabelStyleType();
 		editorTextFieldStyle.subStyles[GUITextField::getInputStyleType()] = GUIInputBox::getGUITypeName();
 
-		mSkin.setStyle(GUITextField::getGUITypeName(), editorTextFieldStyle);
+		mSkin->setStyle(GUITextField::getGUITypeName(), editorTextFieldStyle);
 
 		GUIElementStyle editorColorFieldStyle;
 		editorColorFieldStyle.fixedHeight = true;
@@ -937,7 +939,7 @@ namespace BansheeEngine
 		editorColorFieldStyle.subStyles[GUIColorField::getLabelStyleType()] = GUITextField::getLabelStyleType();
 		editorColorFieldStyle.subStyles[GUIColorField::getColorInputStyleType()] = GUIColor::getGUITypeName();
 
-		mSkin.setStyle(GUIColorField::getGUITypeName(), editorColorFieldStyle);
+		mSkin->setStyle(GUIColorField::getGUITypeName(), editorColorFieldStyle);
 
 		GUIElementStyle editorToggleFieldStyle;
 		editorToggleFieldStyle.fixedHeight = true;
@@ -946,7 +948,7 @@ namespace BansheeEngine
 		editorToggleFieldStyle.subStyles[GUIToggleField::getLabelStyleType()] = GUITextField::getLabelStyleType();
 		editorToggleFieldStyle.subStyles[GUIToggleField::getToggleStyleType()] = GUIToggle::getGUITypeName();
 
-		mSkin.setStyle(GUIToggleField::getGUITypeName(), editorToggleFieldStyle);
+		mSkin->setStyle(GUIToggleField::getGUITypeName(), editorToggleFieldStyle);
 
 		GUIElementStyle editorVector2FieldStyle;
 		editorVector2FieldStyle.fixedHeight = true;
@@ -955,7 +957,7 @@ namespace BansheeEngine
 		editorVector2FieldStyle.subStyles[GUIVector2Field::getLabelStyleType()] = GUITextField::getLabelStyleType();
 		editorVector2FieldStyle.subStyles[GUIVector2Field::getFloatFieldStyleType()] = GUIFloatField::getGUITypeName();
 
-		mSkin.setStyle(GUIVector2Field::getGUITypeName(), editorVector2FieldStyle);
+		mSkin->setStyle(GUIVector2Field::getGUITypeName(), editorVector2FieldStyle);
 
 		GUIElementStyle editorVector3FieldStyle;
 		editorVector3FieldStyle.fixedHeight = true;
@@ -964,7 +966,7 @@ namespace BansheeEngine
 		editorVector3FieldStyle.subStyles[GUIVector3Field::getLabelStyleType()] = GUITextField::getLabelStyleType();
 		editorVector3FieldStyle.subStyles[GUIVector3Field::getFloatFieldStyleType()] = GUIFloatField::getGUITypeName();
 
-		mSkin.setStyle(GUIVector3Field::getGUITypeName(), editorVector3FieldStyle);
+		mSkin->setStyle(GUIVector3Field::getGUITypeName(), editorVector3FieldStyle);
 
 		GUIElementStyle editorVector4FieldStyle;
 		editorVector4FieldStyle.fixedHeight = true;
@@ -973,7 +975,7 @@ namespace BansheeEngine
 		editorVector4FieldStyle.subStyles[GUIVector4Field::getLabelStyleType()] = GUITextField::getLabelStyleType();
 		editorVector4FieldStyle.subStyles[GUIVector4Field::getFloatFieldStyleType()] = GUIFloatField::getGUITypeName();
 
-		mSkin.setStyle(GUIVector4Field::getGUITypeName(), editorVector4FieldStyle);
+		mSkin->setStyle(GUIVector4Field::getGUITypeName(), editorVector4FieldStyle);
 
 		/************************************************************************/
 		/* 							COMPONENT FOLDOUT                      		*/
@@ -996,7 +998,7 @@ namespace BansheeEngine
 		cmpFoldoutBtnStyle.contentOffset = RectOffset(12, 0, 0, 0);
 		cmpFoldoutBtnStyle.border.left = 8;
 
-		mSkin.setStyle(GUIComponentFoldout::getFoldoutButtonStyleType(), cmpFoldoutBtnStyle);
+		mSkin->setStyle(GUIComponentFoldout::getFoldoutButtonStyleType(), cmpFoldoutBtnStyle);
 
 		GUIElementStyle cmpFoldoutStyle;
 		cmpFoldoutStyle.fixedHeight = true;
@@ -1004,7 +1006,7 @@ namespace BansheeEngine
 		cmpFoldoutStyle.minWidth = 30;
 		cmpFoldoutStyle.subStyles[GUIComponentFoldout::getFoldoutButtonStyleType()] = GUIComponentFoldout::getFoldoutButtonStyleType();
 
-		mSkin.setStyle(GUIComponentFoldout::getGUITypeName(), cmpFoldoutStyle);
+		mSkin->setStyle(GUIComponentFoldout::getGUITypeName(), cmpFoldoutStyle);
 
 		/************************************************************************/
 		/* 							     FOLDOUT                      		    */
@@ -1021,7 +1023,7 @@ namespace BansheeEngine
 		foldoutBtnStyle.height = 10;
 		foldoutBtnStyle.width = 8;
 
-		mSkin.setStyle(GUIFoldout::getFoldoutButtonStyleType(), foldoutBtnStyle);
+		mSkin->setStyle(GUIFoldout::getFoldoutButtonStyleType(), foldoutBtnStyle);
 
 		GUIElementStyle foldoutStyle;
 		foldoutStyle.fixedHeight = true;
@@ -1030,7 +1032,7 @@ namespace BansheeEngine
 		foldoutStyle.subStyles[GUIFoldout::getLabelStyleType()] = GUIFoldout::getLabelStyleType();
 		foldoutStyle.subStyles[GUIFoldout::getFoldoutButtonStyleType()] = GUIFoldout::getFoldoutButtonStyleType();
 
-		mSkin.setStyle(GUIFoldout::getGUITypeName(), foldoutStyle);
+		mSkin->setStyle(GUIFoldout::getGUITypeName(), foldoutStyle);
 
 		/************************************************************************/
 		/* 								PROGRESS BAR                      		*/
@@ -1040,14 +1042,14 @@ namespace BansheeEngine
 		progressBarBgStyle.height = 18;
 		progressBarBgStyle.normal.texture = getGUITexture(ProgressBarBgTex);
 
-		mSkin.setStyle(GUIProgressBar::getBackgroundStyleType(), progressBarBgStyle);
+		mSkin->setStyle(GUIProgressBar::getBackgroundStyleType(), progressBarBgStyle);
 
 		GUIElementStyle progressBarFillStyle;
 		progressBarFillStyle.fixedHeight = true;
 		progressBarFillStyle.height = 12;
 		progressBarFillStyle.normal.texture = getGUITexture(ProgressBarFillTex);
 
-		mSkin.setStyle(GUIProgressBar::getBarStyleType(), progressBarFillStyle);
+		mSkin->setStyle(GUIProgressBar::getBarStyleType(), progressBarFillStyle);
 
 		GUIElementStyle progressBarStyle;
 		progressBarStyle.fixedHeight = true;
@@ -1059,7 +1061,7 @@ namespace BansheeEngine
 		progressBarStyle.subStyles[GUIProgressBar::getBarStyleType()] = GUIProgressBar::getBarStyleType();
 		progressBarStyle.subStyles[GUIProgressBar::getBackgroundStyleType()] = GUIProgressBar::getBackgroundStyleType();
 
-		mSkin.setStyle(GUIProgressBar::getGUITypeName(), progressBarStyle);
+		mSkin->setStyle(GUIProgressBar::getGUITypeName(), progressBarStyle);
 
 		/************************************************************************/
 		/* 							COLOR PICKER SLIDER                      	*/
@@ -1074,7 +1076,7 @@ namespace BansheeEngine
 		colorPickerSliderHorzHandleStyle.hover.texture = colorPickerSliderHorzHandleStyle.normal.texture;
 		colorPickerSliderHorzHandleStyle.active.texture = colorPickerSliderHorzHandleStyle.normal.texture;
 
-		mSkin.setStyle("ColorSliderHorzHandle", colorPickerSliderHorzHandleStyle);
+		mSkin->setStyle("ColorSliderHorzHandle", colorPickerSliderHorzHandleStyle);
 
 		GUIElementStyle colorPickerSliderHorzStyle;
 		colorPickerSliderHorzHandleStyle.fixedHeight = true;
@@ -1082,7 +1084,7 @@ namespace BansheeEngine
 		colorPickerSliderHorzHandleStyle.minWidth = 20;
 		colorPickerSliderHorzStyle.subStyles[GUISlider::getHandleStyleType()] = "ColorSliderHorzHandle";
 
-		mSkin.setStyle("ColorSliderHorz", colorPickerSliderHorzStyle);
+		mSkin->setStyle("ColorSliderHorz", colorPickerSliderHorzStyle);
 
 		GUIElementStyle colorPickerSliderVertHandleStyle;
 		colorPickerSliderVertHandleStyle.fixedHeight = true;
@@ -1093,7 +1095,7 @@ namespace BansheeEngine
 		colorPickerSliderVertHandleStyle.hover.texture = colorPickerSliderVertHandleStyle.normal.texture;
 		colorPickerSliderVertHandleStyle.active.texture = colorPickerSliderVertHandleStyle.normal.texture;
 
-		mSkin.setStyle("ColorSliderVertHandle", colorPickerSliderVertHandleStyle);
+		mSkin->setStyle("ColorSliderVertHandle", colorPickerSliderVertHandleStyle);
 
 		GUIElementStyle colorPickerSliderVertStyle;
 		colorPickerSliderVertStyle.fixedWidth = true;
@@ -1101,7 +1103,7 @@ namespace BansheeEngine
 		colorPickerSliderVertStyle.minHeight = 20;
 		colorPickerSliderVertStyle.subStyles[GUISlider::getHandleStyleType()] = "ColorSliderVertHandle";
 
-		mSkin.setStyle("ColorSliderVert", colorPickerSliderVertStyle);
+		mSkin->setStyle("ColorSliderVert", colorPickerSliderVertStyle);
 
 		GUIElementStyle colorPickerSlider2DHandleStyle;
 		colorPickerSlider2DHandleStyle.fixedHeight = true;
@@ -1112,7 +1114,7 @@ namespace BansheeEngine
 		colorPickerSlider2DHandleStyle.hover.texture = colorPickerSlider2DHandleStyle.normal.texture;
 		colorPickerSlider2DHandleStyle.active.texture = colorPickerSlider2DHandleStyle.normal.texture;
 
-		mSkin.setStyle("ColorSlider2DHandle", colorPickerSlider2DHandleStyle);
+		mSkin->setStyle("ColorSlider2DHandle", colorPickerSlider2DHandleStyle);
 
 		/************************************************************************/
 		/* 									OTHER                      			*/
@@ -1128,7 +1130,7 @@ namespace BansheeEngine
 		rightAlignedLabelStyle.minWidth = 10;
 		rightAlignedLabelStyle.textHorzAlign = THA_Right;
 
-		mSkin.setStyle("RightAlignedLabel", rightAlignedLabelStyle);
+		mSkin->setStyle("RightAlignedLabel", rightAlignedLabelStyle);
 	}
 
 	void BuiltinEditorResources::preprocess()

+ 1 - 1
BansheeEditor/Source/BsGUIMenuBar.cpp

@@ -252,7 +252,7 @@ namespace BansheeEngine
 		GUIDropDownAreaPlacement placement = GUIDropDownAreaPlacement::aroundBoundsHorz(subMenu->button->_getCachedBounds());
 
 		GameObjectHandle<GUIDropDownBox> dropDownBox = GUIDropDownBoxManager::instance().openDropDownBox(widget->getTarget(), 
-			placement, dropDownData, widget->getSkin(), GUIDropDownType::MenuBar, std::bind(&GUIMenuBar::onSubMenuClosed, this));
+			placement, dropDownData, widget->getSkinResource(), GUIDropDownType::MenuBar, std::bind(&GUIMenuBar::onSubMenuClosed, this));
 
 		subMenu->button->_setOn(true);
 

+ 1 - 1
BansheeEditor/Source/BsGUIWindowFrameWidget.cpp

@@ -13,7 +13,7 @@ namespace BansheeEngine
 {
 	const UINT32 WindowFrameWidget::RESIZE_BORDER_WIDTH = 3;
 
-	WindowFrameWidget::WindowFrameWidget(const HSceneObject& parent, bool allowResize, Viewport* target, RenderWindow* parentWindow, const GUISkin& skin)
+	WindowFrameWidget::WindowFrameWidget(const HSceneObject& parent, bool allowResize, Viewport* target, RenderWindow* parentWindow, const HGUISkin& skin)
 		:GUIWidget(parent, target), mWindowFrameArea(nullptr), mParentWindow(parentWindow), mAllowResize(allowResize)
 	{
 		setSkin(skin);

+ 4 - 0
BansheeEngine/BansheeEngine.vcxproj

@@ -236,9 +236,11 @@
     <ClCompile Include="Source\BsCursor.cpp" />
     <ClCompile Include="Source\BsDrawHelper.cpp" />
     <ClCompile Include="Source\BsGUIDropDownContent.cpp" />
+    <ClCompile Include="Source\BsGUIElementStyle.cpp" />
     <ClCompile Include="Source\BsGUILayoutExplicit.cpp" />
     <ClCompile Include="Source\BsGUILayoutUtility.cpp" />
     <ClCompile Include="Source\BsGUIProgressBar.cpp" />
+    <ClCompile Include="Source\BsGUISkinRTTI.cpp" />
     <ClCompile Include="Source\BsGUISlider.cpp" />
     <ClCompile Include="Source\BsGUISpace.cpp" />
     <ClCompile Include="Source\BsInputConfiguration.cpp" />
@@ -260,8 +262,10 @@
     <ClInclude Include="Include\BsCursor.h" />
     <ClInclude Include="Include\BsDrawHelper.h" />
     <ClInclude Include="Include\BsGUIDropDownContent.h" />
+    <ClInclude Include="Include\BsGUIElementStyleRTTI.h" />
     <ClInclude Include="Include\BsGUILayoutExplicit.h" />
     <ClInclude Include="Include\BsGUIProgressBar.h" />
+    <ClInclude Include="Include\BsGUISkinRTTI.h" />
     <ClInclude Include="Include\BsGUISlider.h" />
     <ClInclude Include="Include\BsPlainText.h" />
     <ClInclude Include="Include\BsPlainTextImporter.h" />

+ 15 - 0
BansheeEngine/BansheeEngine.vcxproj.filters

@@ -36,6 +36,9 @@
     <Filter Include="Source Files\Script">
       <UniqueIdentifier>{74630e1e-ef0d-4dbc-9e23-0ae6ea24fc02}</UniqueIdentifier>
     </Filter>
+    <Filter Include="Source Files\RTTI">
+      <UniqueIdentifier>{ced1e9e9-483b-493e-b64b-9de22ec86f3e}</UniqueIdentifier>
+    </Filter>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="Include\BsPrerequisites.h">
@@ -323,6 +326,12 @@
     <ClInclude Include="Include\BsGUIDropDownContent.h">
       <Filter>Header Files\GUI</Filter>
     </ClInclude>
+    <ClInclude Include="Include\BsGUIElementStyleRTTI.h">
+      <Filter>Header Files\RTTI</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsGUISkinRTTI.h">
+      <Filter>Header Files\RTTI</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="Source\BsGUIElement.cpp">
@@ -562,5 +571,11 @@
     <ClCompile Include="Source\BsGUIDropDownContent.cpp">
       <Filter>Source Files\GUI</Filter>
     </ClCompile>
+    <ClCompile Include="Source\BsGUIElementStyle.cpp">
+      <Filter>Source Files\GUI</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsGUISkinRTTI.cpp">
+      <Filter>Source Files\RTTI</Filter>
+    </ClCompile>
   </ItemGroup>
 </Project>

+ 2 - 2
BansheeEngine/Include/BsBuiltinResources.h

@@ -21,7 +21,7 @@ namespace BansheeEngine
 		/**
 		 * @brief	Returns the default skin used by engine GUI elements.
 		 */
-		const GUISkin& getGUISkin() const { return mSkin; }
+		const HGUISkin& getGUISkin() const { return mSkin; }
 
 		/**
 		 * @brief	Returns a small entirely white texture.
@@ -140,7 +140,7 @@ namespace BansheeEngine
 		 */
 		static HShader getShader(const WString& name);
 
-		GUISkin mSkin;
+		HGUISkin mSkin;
 
 		PixelDataPtr mCursorArrow;
 		PixelDataPtr mCursorArrowDrag;

+ 1 - 1
BansheeEngine/Include/BsGUIDropDownBox.h

@@ -180,7 +180,7 @@ namespace BansheeEngine
 		 * @param	type			Specific type of drop down box to display.
 		 */
 		GUIDropDownBox(const HSceneObject& parent, Viewport* target, const GUIDropDownAreaPlacement& placement,
-			const GUIDropDownData& dropDownData, const GUISkin& skin, GUIDropDownType type);
+			const GUIDropDownData& dropDownData, const HGUISkin& skin, GUIDropDownType type);
 		~GUIDropDownBox();
 
 	private:

+ 1 - 1
BansheeEngine/Include/BsGUIDropDownBoxManager.h

@@ -26,7 +26,7 @@ namespace BansheeEngine
 		 * @param	onClosedCallback	Callback triggered when drop down box is closed.
 		 */
 		GameObjectHandle<GUIDropDownBox> openDropDownBox(Viewport* target, const GUIDropDownAreaPlacement& placement,
-			const GUIDropDownData& dropDownData, const GUISkin& skin, GUIDropDownType type, std::function<void()> onClosedCallback);
+			const GUIDropDownData& dropDownData, const HGUISkin& skin, GUIDropDownType type, std::function<void()> onClosedCallback);
 
 		/**
 		 * @brief	Closes the currently active drop down box (if any).

+ 10 - 1
BansheeEngine/Include/BsGUIElementStyle.h

@@ -1,6 +1,7 @@
 #pragma once
 
 #include "BsPrerequisites.h"
+#include "BsIReflectable.h"
 #include "BsRectOffset.h"
 #include "BsTextSprite.h"
 #include "BsColor.h"
@@ -19,7 +20,7 @@ namespace BansheeEngine
 	/**
 	 * @brief	GUI element style that determines GUI element look depending on its active state
 	 */
-	struct BS_EXPORT GUIElementStyle
+	struct BS_EXPORT GUIElementStyle : public IReflectable
 	{
 		/**
 		 * @brief	Specific texture and text color used in a particular GUI element style
@@ -70,5 +71,13 @@ namespace BansheeEngine
 		bool fixedHeight; /**< If height is fixed, layout will not attempt to resize the element depending on available size. */
 
 		Map<String, String> subStyles; /**< Sub-styles used by certain more complex elements. */
+
+		/************************************************************************/
+		/* 								SERIALIZATION                      		*/
+		/************************************************************************/
+	public:
+		friend class GUIElementStyleRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		virtual RTTITypeBase* getRTTI() const;
 	};
 }

+ 180 - 0
BansheeEngine/Include/BsGUIElementStyleRTTI.h

@@ -0,0 +1,180 @@
+#pragma once
+
+#include "BsPrerequisites.h"
+#include "BsRTTIType.h"
+#include "BsGUIElementStyle.h"
+
+namespace BansheeEngine
+{
+	class BS_EXPORT GUIElementStyleRTTI : public RTTIType <GUIElementStyle, IReflectable, GUIElementStyleRTTI>
+	{
+	private:
+		HFont& getFont(GUIElementStyle* obj) { return obj->font; }
+		void setFont(GUIElementStyle* obj, HFont& val) { obj->font = val; }
+		
+		UINT32& getFontSize(GUIElementStyle* obj) { return obj->fontSize; }
+		void setFontSize(GUIElementStyle* obj, UINT32& val) { obj->fontSize = val; }
+
+		TextHorzAlign& getTextHorzAlign(GUIElementStyle* obj) { return obj->textHorzAlign; }
+		void setTextHorzAlign(GUIElementStyle* obj, TextHorzAlign& val) { obj->textHorzAlign = val; }
+
+		TextVertAlign& getTextVertAlign(GUIElementStyle* obj) { return obj->textVertAlign; }
+		void setTextVertAlign(GUIElementStyle* obj, TextVertAlign& val) { obj->textVertAlign = val; }
+
+		GUIImagePosition& getImagePosition(GUIElementStyle* obj) { return obj->imagePosition; }
+		void setImagePosition(GUIElementStyle* obj, GUIImagePosition& val) { obj->imagePosition = val; }
+
+		bool& getWordWrap(GUIElementStyle* obj) { return obj->wordWrap; }
+		void setWordWrap(GUIElementStyle* obj, bool& val) { obj->wordWrap = val; }
+
+
+		HSpriteTexture& getNormalTexture(GUIElementStyle* obj) { return obj->normal.texture; }
+		void setNormalTexture(GUIElementStyle* obj, HSpriteTexture& val) { obj->normal.texture = val; }
+
+		Color& getNormalTextColor(GUIElementStyle* obj) { return obj->normal.textColor; }
+		void setNormalTextColor(GUIElementStyle* obj, Color& val) { obj->normal.textColor = val; }
+
+		HSpriteTexture& getHoverTexture(GUIElementStyle* obj) { return obj->hover.texture; }
+		void setHoverTexture(GUIElementStyle* obj, HSpriteTexture& val) { obj->hover.texture = val; }
+
+		Color& getHoverTextColor(GUIElementStyle* obj) { return obj->hover.textColor; }
+		void setHoverTextColor(GUIElementStyle* obj, Color& val) { obj->hover.textColor = val; }
+
+		HSpriteTexture& getActiveTexture(GUIElementStyle* obj) { return obj->active.texture; }
+		void setActiveTexture(GUIElementStyle* obj, HSpriteTexture& val) { obj->active.texture = val; }
+
+		Color& getActiveTextColor(GUIElementStyle* obj) { return obj->active.textColor; }
+		void setActiveTextColor(GUIElementStyle* obj, Color& val) { obj->active.textColor = val; }
+
+		HSpriteTexture& getFocusedTexture(GUIElementStyle* obj) { return obj->focused.texture; }
+		void setFocusedTexture(GUIElementStyle* obj, HSpriteTexture& val) { obj->focused.texture = val; }
+
+		Color& getFocusedTextColor(GUIElementStyle* obj) { return obj->focused.textColor; }
+		void setFocusedTextColor(GUIElementStyle* obj, Color& val) { obj->focused.textColor = val; }
+
+
+		HSpriteTexture& getNormalOnTexture(GUIElementStyle* obj) { return obj->normalOn.texture; }
+		void setNormalOnTexture(GUIElementStyle* obj, HSpriteTexture& val) { obj->normalOn.texture = val; }
+
+		Color& getNormalOnTextColor(GUIElementStyle* obj) { return obj->normalOn.textColor; }
+		void setNormalOnTextColor(GUIElementStyle* obj, Color& val) { obj->normalOn.textColor = val; }
+
+		HSpriteTexture& getHoverOnTexture(GUIElementStyle* obj) { return obj->hoverOn.texture; }
+		void setHoverOnTexture(GUIElementStyle* obj, HSpriteTexture& val) { obj->hoverOn.texture = val; }
+
+		Color& getHoverOnTextColor(GUIElementStyle* obj) { return obj->hoverOn.textColor; }
+		void setHoverOnTextColor(GUIElementStyle* obj, Color& val) { obj->hoverOn.textColor = val; }
+
+		HSpriteTexture& getActiveOnTexture(GUIElementStyle* obj) { return obj->activeOn.texture; }
+		void setActiveOnTexture(GUIElementStyle* obj, HSpriteTexture& val) { obj->activeOn.texture = val; }
+
+		Color& getActiveOnTextColor(GUIElementStyle* obj) { return obj->activeOn.textColor; }
+		void setActiveOnTextColor(GUIElementStyle* obj, Color& val) { obj->activeOn.textColor = val; }
+
+		HSpriteTexture& getFocusedOnTexture(GUIElementStyle* obj) { return obj->focusedOn.texture; }
+		void setFocusedOnTexture(GUIElementStyle* obj, HSpriteTexture& val) { obj->focusedOn.texture = val; }
+
+		Color& getFocusedOnTextColor(GUIElementStyle* obj) { return obj->focusedOn.textColor; }
+		void setFocusedOnTextColor(GUIElementStyle* obj, Color& val) { obj->focusedOn.textColor = val; }
+
+
+		RectOffset& getBorder(GUIElementStyle* obj) { return obj->border; }
+		void setBorder(GUIElementStyle* obj, RectOffset& val) { obj->border = val; }
+
+		RectOffset& getMargins(GUIElementStyle* obj) { return obj->margins; }
+		void setMargins(GUIElementStyle* obj, RectOffset& val) { obj->margins = val; }
+
+		RectOffset& getContentOffset(GUIElementStyle* obj) { return obj->contentOffset; }
+		void setContentOffset(GUIElementStyle* obj, RectOffset& val) { obj->contentOffset = val; }
+
+		RectOffset& getPadding(GUIElementStyle* obj) { return obj->padding; }
+		void setPadding(GUIElementStyle* obj, RectOffset& val) { obj->padding = val; }
+
+		UINT32& getWidth(GUIElementStyle* obj) { return obj->width; }
+		void setWidth(GUIElementStyle* obj, UINT32& val) { obj->width = val; }
+
+		UINT32& getHeight(GUIElementStyle* obj) { return obj->height; }
+		void setHeight(GUIElementStyle* obj, UINT32& val) { obj->height = val; }
+
+		UINT32& getMinWidth(GUIElementStyle* obj) { return obj->minWidth; }
+		void setMinWidth(GUIElementStyle* obj, UINT32& val) { obj->minWidth = val; }
+
+		UINT32& getMaxWidth(GUIElementStyle* obj) { return obj->maxWidth; }
+		void setMaxWidth(GUIElementStyle* obj, UINT32& val) { obj->maxWidth = val; }
+
+		UINT32& getMinHeight(GUIElementStyle* obj) { return obj->minHeight; }
+		void setMinHeight(GUIElementStyle* obj, UINT32& val) { obj->minHeight = val; }
+
+		UINT32& getMaxHeight(GUIElementStyle* obj) { return obj->maxHeight; }
+		void setMaxHeight(GUIElementStyle* obj, UINT32& val) { obj->maxHeight = val; }
+
+		bool& getFixedWidth(GUIElementStyle* obj) { return obj->fixedWidth; }
+		void setFixedWidth(GUIElementStyle* obj, bool& val) { obj->fixedWidth = val; }
+
+		bool& getFixedHeight(GUIElementStyle* obj) { return obj->fixedHeight; }
+		void setFixedHeight(GUIElementStyle* obj, bool& val) { obj->fixedHeight = val; }
+
+		Map<String, String>& getSubStyles(GUIElementStyle* obj) { return obj->subStyles; }
+		void setSubStyles(GUIElementStyle* obj, Map<String, String>& val) { obj->subStyles = val; }
+
+	public:
+		GUIElementStyleRTTI()
+		{
+			addReflectableField("font", 0, &GUIElementStyleRTTI::getFont, &GUIElementStyleRTTI::setFont);
+			addPlainField("fontSize", 1, &GUIElementStyleRTTI::getFontSize, &GUIElementStyleRTTI::setFontSize);
+			addPlainField("textHorzAlign", 2, &GUIElementStyleRTTI::getTextHorzAlign, &GUIElementStyleRTTI::setTextHorzAlign);
+			addPlainField("textVertAlign", 3, &GUIElementStyleRTTI::getTextVertAlign, &GUIElementStyleRTTI::setTextVertAlign);
+			addPlainField("imagePosition", 4, &GUIElementStyleRTTI::getImagePosition, &GUIElementStyleRTTI::setImagePosition);
+			addPlainField("wordWrap", 5, &GUIElementStyleRTTI::getWordWrap, &GUIElementStyleRTTI::setWordWrap);
+
+			addReflectableField("normalTex", 6, &GUIElementStyleRTTI::getNormalTexture, &GUIElementStyleRTTI::setNormalTexture);
+			addPlainField("normalTextColor", 7, &GUIElementStyleRTTI::getNormalTextColor, &GUIElementStyleRTTI::setNormalTextColor);
+			addReflectableField("hoverTex", 8, &GUIElementStyleRTTI::getHoverTexture, &GUIElementStyleRTTI::setHoverTexture);
+			addPlainField("hoverTextColor", 9, &GUIElementStyleRTTI::getHoverTextColor, &GUIElementStyleRTTI::setHoverTextColor);
+			addReflectableField("activeTex", 10, &GUIElementStyleRTTI::getActiveTexture, &GUIElementStyleRTTI::setActiveTexture);
+			addPlainField("activeTextColor", 11, &GUIElementStyleRTTI::getActiveTextColor, &GUIElementStyleRTTI::setActiveTextColor);
+			addReflectableField("focusedTex", 12, &GUIElementStyleRTTI::getFocusedTexture, &GUIElementStyleRTTI::setFocusedTexture);
+			addPlainField("focusedTextColor", 13, &GUIElementStyleRTTI::getFocusedTextColor, &GUIElementStyleRTTI::setFocusedTextColor);
+
+			addReflectableField("normalOnTex", 14, &GUIElementStyleRTTI::getNormalOnTexture, &GUIElementStyleRTTI::setNormalOnTexture);
+			addPlainField("normalOnTextColor", 15, &GUIElementStyleRTTI::getNormalOnTextColor, &GUIElementStyleRTTI::setNormalOnTextColor);
+			addReflectableField("hoverOnTex", 16, &GUIElementStyleRTTI::getHoverOnTexture, &GUIElementStyleRTTI::setHoverOnTexture);
+			addPlainField("hoverOnTextColor", 17, &GUIElementStyleRTTI::getHoverOnTextColor, &GUIElementStyleRTTI::setHoverOnTextColor);
+			addReflectableField("activeOnTex", 18, &GUIElementStyleRTTI::getActiveOnTexture, &GUIElementStyleRTTI::setActiveOnTexture);
+			addPlainField("activeOnTextColor", 19, &GUIElementStyleRTTI::getActiveOnTextColor, &GUIElementStyleRTTI::setActiveOnTextColor);
+			addReflectableField("focusedOnTex", 20, &GUIElementStyleRTTI::getFocusedOnTexture, &GUIElementStyleRTTI::setFocusedOnTexture);
+			addPlainField("focusedOnTextColor", 21, &GUIElementStyleRTTI::getFocusedOnTextColor, &GUIElementStyleRTTI::setFocusedOnTextColor);
+
+			addPlainField("border", 22, &GUIElementStyleRTTI::getBorder, &GUIElementStyleRTTI::setBorder);
+			addPlainField("margins", 23, &GUIElementStyleRTTI::getMargins, &GUIElementStyleRTTI::setMargins);
+			addPlainField("contentOffset", 24, &GUIElementStyleRTTI::getContentOffset, &GUIElementStyleRTTI::setContentOffset);
+			addPlainField("padding", 25, &GUIElementStyleRTTI::getPadding, &GUIElementStyleRTTI::setPadding);
+
+			addPlainField("width", 26, &GUIElementStyleRTTI::getWidth, &GUIElementStyleRTTI::setWidth);
+			addPlainField("height", 27, &GUIElementStyleRTTI::getHeight, &GUIElementStyleRTTI::setHeight);
+			addPlainField("minWidth", 28, &GUIElementStyleRTTI::getMinWidth, &GUIElementStyleRTTI::setMinWidth);
+			addPlainField("maxWidth", 29, &GUIElementStyleRTTI::getMaxWidth, &GUIElementStyleRTTI::setMaxWidth);
+			addPlainField("minHeight", 30, &GUIElementStyleRTTI::getMinHeight, &GUIElementStyleRTTI::setMinHeight);
+			addPlainField("maxHeight", 31, &GUIElementStyleRTTI::getMaxHeight, &GUIElementStyleRTTI::setMaxHeight);
+			addPlainField("fixedWidth", 32, &GUIElementStyleRTTI::getFixedWidth, &GUIElementStyleRTTI::setFixedWidth);
+			addPlainField("fixedHeight", 33, &GUIElementStyleRTTI::getFixedHeight, &GUIElementStyleRTTI::setFixedHeight);
+
+			addPlainField("subStyles", 34, &GUIElementStyleRTTI::getSubStyles, &GUIElementStyleRTTI::setSubStyles);
+		}
+		virtual const String& getRTTIName()
+		{
+			static String name = "GUIElementStyle";
+			return name;
+		}
+
+		virtual UINT32 getRTTIId()
+		{
+			return TID_GUIElementStyle;
+		}
+
+		virtual std::shared_ptr<IReflectable> newRTTIObject()
+		{
+			return bs_shared_ptr<GUIElementStyle>();
+		}
+	};
+}

+ 25 - 4
BansheeEngine/Include/BsGUISkin.h

@@ -1,6 +1,7 @@
 #pragma once
 
 #include "BsPrerequisites.h"
+#include "BsResource.h"
 #include "BsGUIElementStyle.h"
 
 namespace BansheeEngine
@@ -9,11 +10,9 @@ namespace BansheeEngine
 	 * @brief	Holds information about how are GUI element types positioned and
 	 *			displayed in the GUI. Each element type can be assigned a specific style.
 	 */
-	class BS_EXPORT GUISkin
+	class BS_EXPORT GUISkin : public Resource
 	{
 	public:
-		GUISkin() {}
-
 		/**
 		 * @brief	Returns a style for the specified GUI element type.
 		 *
@@ -32,9 +31,31 @@ namespace BansheeEngine
 		 * @brief	Default style that may be used when no other is available.
 		 */
 		static GUIElementStyle DefaultStyle;
+
+		/**
+		 * @brief	Creates an empty GUI skin and returns a handle to it.
+		 */
+		static HGUISkin create();
+
+		/**
+		 * @brief	Creates an empty GUI skin and returns a pointer to it.
+		 *
+		 * @note	Internal method. Use "create" returning handle for normal use.
+		 */
+		static GUISkinPtr _createPtr();
+
 	private:
-		GUISkin(const GUISkin& skin) {} // Disable copying
+		GUISkin();
+		GUISkin(const GUISkin& skin); // Disable copying
 
 		UnorderedMap<String, GUIElementStyle> mStyles;
+
+		/************************************************************************/
+		/* 								SERIALIZATION                      		*/
+		/************************************************************************/
+	public:
+		friend class GUISkinRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		virtual RTTITypeBase* getRTTI() const;
 	};
 }

+ 114 - 0
BansheeEngine/Include/BsGUISkinRTTI.h

@@ -0,0 +1,114 @@
+#pragma once
+
+#include "BsPrerequisites.h"
+#include "BsRTTIType.h"
+#include "BsGUISkin.h"
+
+namespace BansheeEngine
+{
+	class BS_EXPORT GUISkinEntry : public IReflectable
+	{
+	public:
+		GUISkinEntry() { }
+		GUISkinEntry(const String& name, const GUIElementStyle& style);
+
+		String name;
+		GUIElementStyle style;
+
+	public:
+		friend class GUISkinEntryRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		virtual RTTITypeBase* getRTTI() const;
+	};
+
+	class BS_EXPORT GUISkinEntryRTTI : public RTTIType <GUISkinEntry, IReflectable, GUISkinEntryRTTI>
+	{
+	private:
+		String& getName(GUISkinEntry* obj) { return obj->name; }
+		void setName(GUISkinEntry* obj, String& val) { obj->name = val; }
+
+		GUIElementStyle& getStyle(GUISkinEntry* obj) { return obj->style; }
+		void setStyle(GUISkinEntry* obj, GUIElementStyle& val) { obj->style = val; }
+
+	public:
+		GUISkinEntryRTTI()
+		{
+			addPlainField("name", 0, &GUISkinEntryRTTI::getName, &GUISkinEntryRTTI::setName);
+			addReflectableField("style", 1, &GUISkinEntryRTTI::getStyle, &GUISkinEntryRTTI::setStyle);
+		}
+
+		virtual const String& getRTTIName()
+		{
+			static String name = "GUISkinEntry";
+			return name;
+		}
+
+		virtual UINT32 getRTTIId()
+		{
+			return TID_GUISkinEntry;
+		}
+
+		virtual std::shared_ptr<IReflectable> newRTTIObject()
+		{
+			return bs_shared_ptr<GUISkinEntry>();
+		}
+	};
+
+	class BS_EXPORT GUISkinRTTI : public RTTIType <GUISkin, Resource, GUISkinRTTI>
+	{
+	private:
+		GUISkinEntry& getStyle(GUISkin* obj, UINT32 idx) 
+		{ 
+			Vector<GUISkinEntry>& entries = any_cast_ref<Vector<GUISkinEntry>>(obj->mRTTIData);
+			
+			return entries[idx];
+		}
+
+		void setStyle(GUISkin* obj, UINT32 idx, GUISkinEntry& val) { obj->mStyles[val.name] = val.style; }
+		UINT32 getStyleArraySize(GUISkin* obj) { return (UINT32)obj->mStyles.size(); }
+		void setStyleArraySize(GUISkin* obj, UINT32 size) { /* Do nothing */ }
+
+	public:
+		GUISkinRTTI()
+		{
+			addReflectableArrayField("mStyles", 0, &GUISkinRTTI::getStyle, &GUISkinRTTI::getStyleArraySize,
+				&GUISkinRTTI::setStyle, &GUISkinRTTI::setStyleArraySize);
+		}
+
+		void onSerializationStarted(IReflectable* obj)
+		{
+			GUISkin* skin = static_cast<GUISkin*>(obj);
+			Vector<GUISkinEntry> entries;
+
+			for (auto& style : skin->mStyles)
+			{
+				entries.push_back(GUISkinEntry(style.first, style.second));
+			}
+
+			skin->mRTTIData = entries;
+		}
+
+		void onSerializationEnded(IReflectable* obj)
+		{
+			GUISkin* skin = static_cast<GUISkin*>(obj);
+
+			skin->mRTTIData = nullptr;
+		}
+
+		virtual const String& getRTTIName()
+		{
+			static String name = "GUISkin";
+			return name;
+		}
+
+		virtual UINT32 getRTTIId()
+		{
+			return TID_GUISkin;
+		}
+
+		virtual std::shared_ptr<IReflectable> newRTTIObject()
+		{
+			return GUISkin::_createPtr();
+		}
+	};
+}

+ 7 - 6
BansheeEngine/Include/BsGUIWidget.h

@@ -25,13 +25,18 @@ namespace BansheeEngine
 		 * @brief	Sets the skin used for all GUI elements in the widget. This will update
 		 *			the look of all current elements.
 		 */
-		void setSkin(const GUISkin& skin);
+		void setSkin(const HGUISkin& skin);
 
 		/**
 		 * @brief	Returns the currently active GUI skin.
 		 */
 		const GUISkin& getSkin() const;
 
+		/**
+		 * @brief	Returns the currently active GUI skin resource.
+		 */
+		const HGUISkin& getSkinResource() const { return mSkin; }
+
 		/**
 		 * @brief	Returns the depth to render the widget at. If two widgets overlap the
 		 *			widget with the lower depth will be rendered in front.
@@ -103,10 +108,6 @@ namespace BansheeEngine
 		 */
 		virtual bool _virtualButtonEvent(GUIElement* element, const GUIVirtualButtonEvent& ev);
 
-		/**
-		 * @brief	Default skin that is used when no other is assigned.
-		 */
-		static GUISkin DefaultSkin;
 	protected:
 		friend class SceneObject;
 		friend class GUIElement;
@@ -183,6 +184,6 @@ namespace BansheeEngine
 		mutable Vector<HMesh> mCachedMeshes;
 		mutable Vector<HMaterial> mCachedMaterials;
 
-		const GUISkin* mSkin;
+		HGUISkin mSkin;
 	};
 }

+ 6 - 1
BansheeEngine/Include/BsPrerequisites.h

@@ -116,6 +116,7 @@ namespace BansheeEngine
 	typedef std::shared_ptr<InputConfiguration> InputConfigurationPtr;
 	typedef std::shared_ptr<PlainText> PlainTextPtr;
 	typedef std::shared_ptr<ScriptCode> ScriptCodePtr;
+	typedef std::shared_ptr<GUISkin> GUISkinPtr;
 
 	typedef GameObjectHandle<GUIWidget> HGUIWidget;
 	typedef GameObjectHandle<Camera> HCamera;
@@ -125,6 +126,7 @@ namespace BansheeEngine
 	typedef ResourceHandle<SpriteTexture> HSpriteTexture;
 	typedef ResourceHandle<PlainText> HPlainText;
 	typedef ResourceHandle<ScriptCode> HScriptCode;
+	typedef ResourceHandle<GUISkin> HGUISkin;
 
 	static const char* ENGINE_ASSEMBLY = "MBansheeEngine";
 	static const char* SCRIPT_GAME_ASSEMBLY = "MScriptGame";
@@ -142,6 +144,9 @@ namespace BansheeEngine
 		TID_RenderableHandler = 30004,
 		TID_PlainText = 30005,
 		TID_ScriptCode = 30006,
-		TID_ScriptCodeImportOptions = 30007
+		TID_ScriptCodeImportOptions = 30007,
+		TID_GUIElementStyle = 30008,
+		TID_GUISkin = 30009,
+		TID_GUISkinEntry = 30010
 	};
 }

+ 2 - 0
BansheeEngine/Include/BsRectOffset.h

@@ -20,4 +20,6 @@ namespace BansheeEngine
 
 		INT32 left, right, top, bottom;
 	};
+
+	BS_ALLOW_MEMCPY_SERIALIZATION(RectOffset);
 }

+ 36 - 35
BansheeEngine/Source/BsBuiltinResources.cpp

@@ -220,6 +220,7 @@ namespace BansheeEngine
 		fontPath.append(DefaultFontFilename + L".asset");
 
 		HFont font = Resources::instance().load<Font>(fontPath);
+		mSkin = GUISkin::create();
 
 		// Label
 		GUIElementStyle labelStyle;
@@ -230,7 +231,7 @@ namespace BansheeEngine
 		labelStyle.height = 11;
 		labelStyle.minWidth = 10;
 
-		mSkin.setStyle(GUILabel::getGUITypeName(), labelStyle);
+		mSkin->setStyle(GUILabel::getGUITypeName(), labelStyle);
 
 		// Button
 		GUIElementStyle buttonStyle;
@@ -251,7 +252,7 @@ namespace BansheeEngine
 		buttonStyle.textHorzAlign = THA_Center;
 		buttonStyle.textVertAlign = TVA_Center;
 
-		mSkin.setStyle(GUIButton::getGUITypeName(), buttonStyle);
+		mSkin->setStyle(GUIButton::getGUITypeName(), buttonStyle);
 
 		// Toggle
 		GUIElementStyle toggleStyle;
@@ -266,7 +267,7 @@ namespace BansheeEngine
 		toggleStyle.height = 15;
 		toggleStyle.width = 15;
 
-		mSkin.setStyle(GUIToggle::getGUITypeName(), toggleStyle);
+		mSkin->setStyle(GUIToggle::getGUITypeName(), toggleStyle);
 
 		// Input box
 		GUIElementStyle inputBoxStyle;
@@ -290,7 +291,7 @@ namespace BansheeEngine
 		inputBoxStyle.textHorzAlign = THA_Left;
 		inputBoxStyle.textVertAlign = TVA_Top;
 
-		mSkin.setStyle(GUIInputBox::getGUITypeName(), inputBoxStyle);
+		mSkin->setStyle(GUIInputBox::getGUITypeName(), inputBoxStyle);
 
 		/************************************************************************/
 		/* 								SCROLL BAR                      		*/
@@ -306,7 +307,7 @@ namespace BansheeEngine
 		scrollUpBtnStyle.height = 4;
 		scrollUpBtnStyle.width = 8;
 
-		mSkin.setStyle("ScrollUpBtn", scrollUpBtnStyle);
+		mSkin->setStyle("ScrollUpBtn", scrollUpBtnStyle);
 
 		// Down button
 		GUIElementStyle scrollDownBtnStyle;
@@ -318,7 +319,7 @@ namespace BansheeEngine
 		scrollDownBtnStyle.height = 4;
 		scrollDownBtnStyle.width = 8;
 
-		mSkin.setStyle("ScrollDownBtn", scrollDownBtnStyle);
+		mSkin->setStyle("ScrollDownBtn", scrollDownBtnStyle);
 
 		// Left button
 		GUIElementStyle scrollLeftBtnStyle;
@@ -330,7 +331,7 @@ namespace BansheeEngine
 		scrollLeftBtnStyle.height = 8;
 		scrollLeftBtnStyle.width = 4;
 
-		mSkin.setStyle("ScrollLeftBtn", scrollLeftBtnStyle);
+		mSkin->setStyle("ScrollLeftBtn", scrollLeftBtnStyle);
 
 		// Right button
 		GUIElementStyle scrollRightBtnStyle;
@@ -342,7 +343,7 @@ namespace BansheeEngine
 		scrollRightBtnStyle.height = 8;
 		scrollRightBtnStyle.width = 4;
 
-		mSkin.setStyle("ScrollRightBtn", scrollRightBtnStyle);
+		mSkin->setStyle("ScrollRightBtn", scrollRightBtnStyle);
 
 		// Horizontal handle
 		GUIElementStyle scrollBarHorzBtnStyle;
@@ -354,7 +355,7 @@ namespace BansheeEngine
 		scrollBarHorzBtnStyle.height = 6;
 		scrollBarHorzBtnStyle.width = 4;
 
-		mSkin.setStyle("ScrollBarHorzBtn", scrollBarHorzBtnStyle);
+		mSkin->setStyle("ScrollBarHorzBtn", scrollBarHorzBtnStyle);
 
 		// Vertical handle
 		GUIElementStyle scrollBarVertBtnStyle;
@@ -366,7 +367,7 @@ namespace BansheeEngine
 		scrollBarVertBtnStyle.height = 4;
 		scrollBarVertBtnStyle.width = 6;
 
-		mSkin.setStyle("ScrollBarVertBtn", scrollBarVertBtnStyle);
+		mSkin->setStyle("ScrollBarVertBtn", scrollBarVertBtnStyle);
 
 		HSpriteTexture scrollBarBgPtr = getSkinTexture(ScrollBarBgTex);
 
@@ -380,7 +381,7 @@ namespace BansheeEngine
 		vertScrollBarStyle.minHeight = 16;
 		vertScrollBarStyle.width = 8;
 
-		mSkin.setStyle("ScrollBarVert", vertScrollBarStyle);
+		mSkin->setStyle("ScrollBarVert", vertScrollBarStyle);
 
 		// Horizontal scroll bar
 		GUIElementStyle horzScrollBarStyle;
@@ -392,7 +393,7 @@ namespace BansheeEngine
 		horzScrollBarStyle.minWidth = 16;
 		horzScrollBarStyle.height = 8;
 
-		mSkin.setStyle("ScrollBarHorz", horzScrollBarStyle);
+		mSkin->setStyle("ScrollBarHorz", horzScrollBarStyle);
 
 		/************************************************************************/
 		/* 								DROP DOWN BOX                      		*/
@@ -423,7 +424,7 @@ namespace BansheeEngine
 		dropDownListStyle.textHorzAlign = THA_Left;
 		dropDownListStyle.textVertAlign = TVA_Top;
 
-		mSkin.setStyle("ListBox", dropDownListStyle);
+		mSkin->setStyle("ListBox", dropDownListStyle);
 
 		// DropDown scroll up button arrow
 		GUIElementStyle dropDownScrollUpBtnArrowStyle;
@@ -439,9 +440,9 @@ namespace BansheeEngine
 		dropDownScrollUpBtnArrowStyle.border.top = 1;
 		dropDownScrollUpBtnArrowStyle.border.bottom = 1;
 
-		mSkin.setStyle("ListBoxScrollUpBtnArrow", dropDownScrollUpBtnArrowStyle);
-		mSkin.setStyle("MenuBarScrollUpBtnArrow", dropDownScrollUpBtnArrowStyle);
-		mSkin.setStyle("ContextMenuScrollUpBtnArrow", dropDownScrollUpBtnArrowStyle);
+		mSkin->setStyle("ListBoxScrollUpBtnArrow", dropDownScrollUpBtnArrowStyle);
+		mSkin->setStyle("MenuBarScrollUpBtnArrow", dropDownScrollUpBtnArrowStyle);
+		mSkin->setStyle("ContextMenuScrollUpBtnArrow", dropDownScrollUpBtnArrowStyle);
 
 		// DropDown scroll up button
 		GUIElementStyle dropDownScrollUpBtnStyle;
@@ -457,9 +458,9 @@ namespace BansheeEngine
 		dropDownScrollUpBtnStyle.border.top = 1;
 		dropDownScrollUpBtnStyle.border.bottom = 1;
 
-		mSkin.setStyle("ListBoxScrollUpBtn", dropDownScrollUpBtnStyle);
-		mSkin.setStyle("MenuBarScrollUpBtn", dropDownScrollUpBtnStyle);
-		mSkin.setStyle("ContextMenuScrollUpBtn", dropDownScrollUpBtnStyle);
+		mSkin->setStyle("ListBoxScrollUpBtn", dropDownScrollUpBtnStyle);
+		mSkin->setStyle("MenuBarScrollUpBtn", dropDownScrollUpBtnStyle);
+		mSkin->setStyle("ContextMenuScrollUpBtn", dropDownScrollUpBtnStyle);
 
 		// DropDown scroll down button arrow
 		GUIElementStyle dropDownScrollDownBtnArrowStyle;
@@ -475,9 +476,9 @@ namespace BansheeEngine
 		dropDownScrollDownBtnArrowStyle.border.top = 1;
 		dropDownScrollDownBtnArrowStyle.border.bottom = 1;
 		
-		mSkin.setStyle("ListBoxScrollDownBtnArrow", dropDownScrollDownBtnArrowStyle);
-		mSkin.setStyle("MenuBarScrollDownBtnArrow", dropDownScrollDownBtnArrowStyle);
-		mSkin.setStyle("ContextMenuScrollDownBtnArrow", dropDownScrollDownBtnArrowStyle);
+		mSkin->setStyle("ListBoxScrollDownBtnArrow", dropDownScrollDownBtnArrowStyle);
+		mSkin->setStyle("MenuBarScrollDownBtnArrow", dropDownScrollDownBtnArrowStyle);
+		mSkin->setStyle("ContextMenuScrollDownBtnArrow", dropDownScrollDownBtnArrowStyle);
 
 		// DropDown scroll down button
 		GUIElementStyle dropDownScrollDownBtnStyle;
@@ -493,9 +494,9 @@ namespace BansheeEngine
 		dropDownScrollDownBtnStyle.border.top = 1;
 		dropDownScrollDownBtnStyle.border.bottom = 1;
 
-		mSkin.setStyle("ListBoxScrollDownBtn", dropDownScrollDownBtnStyle);
-		mSkin.setStyle("MenuBarScrollDownBtn", dropDownScrollDownBtnStyle);
-		mSkin.setStyle("ContextMenuScrollDownBtn", dropDownScrollDownBtnStyle);
+		mSkin->setStyle("ListBoxScrollDownBtn", dropDownScrollDownBtnStyle);
+		mSkin->setStyle("MenuBarScrollDownBtn", dropDownScrollDownBtnStyle);
+		mSkin->setStyle("ContextMenuScrollDownBtn", dropDownScrollDownBtnStyle);
 
 		// DropDown entry button
 		GUIElementStyle dropDownEntryBtnStyle;
@@ -518,7 +519,7 @@ namespace BansheeEngine
 		dropDownEntryBtnStyle.textHorzAlign = THA_Left;
 		dropDownEntryBtnStyle.textVertAlign = TVA_Top;
 
-		mSkin.setStyle(GUIDropDownContent::ENTRY_STYLE_TYPE, dropDownEntryBtnStyle);
+		mSkin->setStyle(GUIDropDownContent::ENTRY_STYLE_TYPE, dropDownEntryBtnStyle);
 
 		// DropDown entry button with expand
 		GUIElementStyle dropDownEntryExpBtnStyle;
@@ -541,7 +542,7 @@ namespace BansheeEngine
 		dropDownEntryExpBtnStyle.textHorzAlign = THA_Left;
 		dropDownEntryExpBtnStyle.textVertAlign = TVA_Top;
 
-		mSkin.setStyle(GUIDropDownContent::ENTRY_EXP_STYLE_TYPE, dropDownEntryExpBtnStyle);
+		mSkin->setStyle(GUIDropDownContent::ENTRY_EXP_STYLE_TYPE, dropDownEntryExpBtnStyle);
 
 		// Drop down separator
 		GUIElementStyle dropDownSeparatorStyle;
@@ -555,7 +556,7 @@ namespace BansheeEngine
 		dropDownSeparatorStyle.border.top = 1;
 		dropDownSeparatorStyle.border.bottom = 1;
 
-		mSkin.setStyle(GUIDropDownContent::SEPARATOR_STYLE_TYPE, dropDownSeparatorStyle);
+		mSkin->setStyle(GUIDropDownContent::SEPARATOR_STYLE_TYPE, dropDownSeparatorStyle);
 
 		// Drop down content
 		GUIElementStyle dropDownContentStyle;
@@ -565,9 +566,9 @@ namespace BansheeEngine
 		dropDownContentStyle.subStyles[GUIDropDownContent::ENTRY_EXP_STYLE_TYPE] = GUIDropDownContent::ENTRY_EXP_STYLE_TYPE;
 		dropDownContentStyle.subStyles[GUIDropDownContent::SEPARATOR_STYLE_TYPE] = GUIDropDownContent::SEPARATOR_STYLE_TYPE;
 
-		mSkin.setStyle("ListBoxContent", dropDownContentStyle);
-		mSkin.setStyle("MenuBarContent", dropDownContentStyle);
-		mSkin.setStyle("ContextMenuContent", dropDownContentStyle);
+		mSkin->setStyle("ListBoxContent", dropDownContentStyle);
+		mSkin->setStyle("MenuBarContent", dropDownContentStyle);
+		mSkin->setStyle("ContextMenuContent", dropDownContentStyle);
 
 		// DropDown box frame
 		GUIElementStyle dropDownBoxStyle;
@@ -585,9 +586,9 @@ namespace BansheeEngine
 		dropDownBoxStyle.margins.top = 1;
 		dropDownBoxStyle.margins.bottom = 1;
 
-		mSkin.setStyle("ListBoxFrame", dropDownBoxStyle);
-		mSkin.setStyle("MenuBarFrame", dropDownBoxStyle);
-		mSkin.setStyle("ContextMenuFrame", dropDownBoxStyle);
+		mSkin->setStyle("ListBoxFrame", dropDownBoxStyle);
+		mSkin->setStyle("MenuBarFrame", dropDownBoxStyle);
+		mSkin->setStyle("ContextMenuFrame", dropDownBoxStyle);
 
 		/************************************************************************/
 		/* 									OTHER                      			*/
@@ -603,7 +604,7 @@ namespace BansheeEngine
 		rightAlignedLabelStyle.minWidth = 10;
 		rightAlignedLabelStyle.textHorzAlign = THA_Right;
 
-		mSkin.setStyle("RightAlignedLabel", rightAlignedLabelStyle);
+		mSkin->setStyle("RightAlignedLabel", rightAlignedLabelStyle);
 	}
 
 	void BuiltinResources::preprocess()

+ 1 - 1
BansheeEngine/Source/BsGUIContextMenu.cpp

@@ -20,7 +20,7 @@ namespace BansheeEngine
 		GUIDropDownAreaPlacement placement = GUIDropDownAreaPlacement::aroundPosition(position);
 
 		GameObjectHandle<GUIDropDownBox> dropDownBox = GUIDropDownBoxManager::instance().openDropDownBox(widget.getTarget(), 
-			placement, getDropDownData(), widget.getSkin(), GUIDropDownType::ContextMenu, std::bind(&GUIContextMenu::onMenuClosed, this));
+			placement, getDropDownData(), widget.getSkinResource(), GUIDropDownType::ContextMenu, std::bind(&GUIContextMenu::onMenuClosed, this));
 
 		mContextMenuOpen = true;
 	}

+ 3 - 3
BansheeEngine/Source/BsGUIDropDownBox.cpp

@@ -79,7 +79,7 @@ namespace BansheeEngine
 	}
 
 	GUIDropDownBox::GUIDropDownBox(const HSceneObject& parent, Viewport* target, const GUIDropDownAreaPlacement& placement,
-		const GUIDropDownData& dropDownData, const GUISkin& skin, GUIDropDownType type)
+		const GUIDropDownData& dropDownData, const HGUISkin& skin, GUIDropDownType type)
 		:GUIWidget(parent, target), mRootMenu(nullptr), mHitBox(nullptr), mCaptureHitBox(nullptr)
 	{
 		String stylePrefix = "";
@@ -101,8 +101,8 @@ namespace BansheeEngine
 		mBackgroundStyle = stylePrefix + "Frame";
 		mContentStyle = stylePrefix + "Content";
 
-		mScrollUpBtnArrow = skin.getStyle(stylePrefix + "ScrollUpBtnArrow")->normal.texture;
-		mScrollDownBtnArrow = skin.getStyle(stylePrefix + "ScrollDownBtnArrow")->normal.texture;
+		mScrollUpBtnArrow = skin->getStyle(stylePrefix + "ScrollUpBtnArrow")->normal.texture;
+		mScrollDownBtnArrow = skin->getStyle(stylePrefix + "ScrollDownBtnArrow")->normal.texture;
 
 		setDepth(0); // Needs to be in front of everything
 		setSkin(skin);

+ 1 - 1
BansheeEngine/Source/BsGUIDropDownBoxManager.cpp

@@ -9,7 +9,7 @@ namespace BansheeEngine
 	}
 
 	GameObjectHandle<GUIDropDownBox> GUIDropDownBoxManager::openDropDownBox(Viewport* target, const GUIDropDownAreaPlacement& placement,
-		const GUIDropDownData& dropDownData, const GUISkin& skin, GUIDropDownType type, std::function<void()> onClosedCallback)
+		const GUIDropDownData& dropDownData, const HGUISkin& skin, GUIDropDownType type, std::function<void()> onClosedCallback)
 	{
 		closeDropDownBox();
 

+ 15 - 0
BansheeEngine/Source/BsGUIElementStyle.cpp

@@ -0,0 +1,15 @@
+#include "BsGUIElementStyle.h"
+#include "BsGUIElementStyleRTTI.h"
+
+namespace BansheeEngine
+{
+	RTTITypeBase* GUIElementStyle::getRTTIStatic()
+	{
+		return GUIElementStyleRTTI::instance();
+	}
+
+	RTTITypeBase* GUIElementStyle::getRTTI() const
+	{
+		return GUIElementStyle::getRTTIStatic();
+	}
+}

+ 1 - 1
BansheeEngine/Source/BsGUIListBox.cpp

@@ -109,7 +109,7 @@ namespace BansheeEngine
 		GUIDropDownAreaPlacement placement = GUIDropDownAreaPlacement::aroundBoundsHorz(_getCachedBounds());
 
 		GameObjectHandle<GUIDropDownBox> dropDownBox = GUIDropDownBoxManager::instance().openDropDownBox(widget->getTarget(), 
-			placement, dropDownData, widget->getSkin(), GUIDropDownType::MenuBar, std::bind(&GUIListBox::onListBoxClosed, this));
+			placement, dropDownData, widget->getSkinResource(), GUIDropDownType::MenuBar, std::bind(&GUIListBox::onListBoxClosed, this));
 
 		_setOn(true);
 		mIsListBoxOpen = true;

+ 36 - 0
BansheeEngine/Source/BsGUISkin.cpp

@@ -1,11 +1,21 @@
 #include "BsGUISkin.h"
 #include "BsGUIElementStyle.h"
 #include "BsDebug.h"
+#include "BsResources.h"
+#include "BsGUISkinRTTI.h"
 
 namespace BansheeEngine
 {
 	GUIElementStyle GUISkin::DefaultStyle;
 
+	GUISkin::GUISkin()
+		:Resource(false)
+	{ }
+
+	GUISkin::GUISkin(const GUISkin& skin)
+		:Resource(false)
+	{ }
+
 	const GUIElementStyle* GUISkin::getStyle(const String& guiElemType) const
 	{
 		auto iterFind = mStyles.find(guiElemType);
@@ -22,4 +32,30 @@ namespace BansheeEngine
 	{
 		mStyles[guiElemType] = style;
 	}
+
+	HGUISkin GUISkin::create()
+	{
+		GUISkinPtr newSkin = _createPtr();
+
+		return static_resource_cast<GUISkin>(gResources()._createResourceHandle(newSkin));
+	}
+
+	GUISkinPtr GUISkin::_createPtr()
+	{
+		GUISkinPtr newSkin = bs_core_ptr<GUISkin, PoolAlloc>(new (bs_alloc<GUISkin, PoolAlloc>()) GUISkin());
+		newSkin->_setThisPtr(newSkin);
+		newSkin->initialize();
+
+		return newSkin;
+	}
+
+	RTTITypeBase* GUISkin::getRTTIStatic()
+	{
+		return GUISkinRTTI::instance();
+	}
+
+	RTTITypeBase* GUISkin::getRTTI() const
+	{
+		return GUISkin::getRTTIStatic();
+	}
 }

+ 18 - 0
BansheeEngine/Source/BsGUISkinRTTI.cpp

@@ -0,0 +1,18 @@
+#include "BsGUISkinRTTI.h"
+
+namespace BansheeEngine
+{
+	GUISkinEntry::GUISkinEntry(const String& name, const GUIElementStyle& style)
+		:name(name), style(style)
+	{ }
+
+	RTTITypeBase* GUISkinEntry::getRTTIStatic()
+	{
+		return GUISkinEntryRTTI::instance();
+	}
+
+	RTTITypeBase* GUISkinEntry::getRTTI() const
+	{
+		return GUISkinEntry::getRTTIStatic();
+	}
+}

+ 7 - 7
BansheeEngine/Source/BsGUIWidget.cpp

@@ -18,10 +18,8 @@
 
 namespace BansheeEngine
 {
-	GUISkin GUIWidget::DefaultSkin;
-
 	GUIWidget::GUIWidget(const HSceneObject& parent, Viewport* target)
-		:Component(parent), mSkin(nullptr), mWidgetIsDirty(false), mTarget(nullptr), mDepth(0)
+		:Component(parent), mWidgetIsDirty(false), mTarget(nullptr), mDepth(0)
 	{
 		setName("GUIWidget");
 
@@ -179,9 +177,9 @@ namespace BansheeEngine
 		mWidgetIsDirty = true;
 	}
 
-	void GUIWidget::setSkin(const GUISkin& skin)
+	void GUIWidget::setSkin(const HGUISkin& skin)
 	{
-		mSkin = &skin;
+		mSkin = skin;
 
 		for(auto& element : mElements)
 			element->_refreshStyle();
@@ -189,10 +187,12 @@ namespace BansheeEngine
 
 	const GUISkin& GUIWidget::getSkin() const
 	{
-		if(mSkin != nullptr)
+		static const HGUISkin DEFAULT_SKIN = GUISkin::create();
+
+		if(mSkin.isLoaded())
 			return *mSkin;
 		else
-			return DefaultSkin;
+			return *DEFAULT_SKIN;
 	}
 
 	bool GUIWidget::isDirty(bool cleanIfDirty)

+ 1 - 12
TODO.txt

@@ -96,21 +96,10 @@ Later:
 ----------------------------------------------------------------------
 Include files:
 
-Shader dependencies:
- - Store include dependencies in Shader itself
-   - Store by the source path, not referencing the asset
-   - Update shader RTTI so it's properly serialized
- - Add project library template method:
-  - getImportDependencies<Type>(obj)
-    - shader would return a list of include paths, and other types can include other objects
-  - project library keeps a list of all such dependencies
-   - it detects when the dependencies change (i.e. are moved, renamed, deleted or reimported) and also triggers a reimport of the dependentee
-    - TODO - what if multiple dependencies are reimported at once? do I want to reimport the dependntee 
-       for each one or should there be some kind of a delay?
-
 Test:
  - Try preprocessing using one RenderAPi and then load the shaders using another and see if they're created normally
  - Test if default values work
+ - Test project library dependant resources
 
 ----------------------------------------------------------------------
 Scene View