Style
Build-in styles and icons
You can find the famous script to see unity styles and icons in Wonderland menu. This version is debugged. (Texture errors removed and draw all results for a search request).
WonderlandBodyScope
Create a scope with your header img.
using (new WonderlandBodyScope("Wonderland_bg")) {
// content
}
Create a scope with your background (use it for windows bg, not inspector because there is no end test)
Vector2 _scrollPosition = Vector2.zero;
public void OnGUI() {
using(var sv = new EditorGUILayout.ScrollViewScope(_scrollPosition)) {
using (new WonderlandBodyScope("Wonderland_bg", true, _scrollPosition)) {
// content
}
_scrollPosition = sv.scrollPosition;
}
}
SimpleScope
Simple container with margins
using (new SimpleScope()) {
// content
}
Wonderland styles
EODE.Wonderland.Style
contains basic styles. You can use it at preconfigured style (margin, paddings...).
GUILayout.BeginVertical(Style.Container);
Style list :
EODE.Wonderland.Style.WonderlandBody => "ShurikenModuleBg"
EODE.Wonderland.Style.WonderlandBodyContent => "ShurikenModuleBg"
EODE.Wonderland.Style.Container => "ShurikenEffectBg"
EODE.Wonderland.Style.Content => "ShurikenModuleBg"
EODE.Wonderland.Style.ListContainer => "ShurikenModuleBg"
EODE.Wonderland.Style.TabTitle => "ShurikenEmitterTitle"
EODE.Wonderland.Style.TabContainer => "ShurikenEffectBg"
EODE.Wonderland.Style.TabContent => "ShurikenModuleBg"
EODE.Wonderland.Style.Drop => "IN DropDown"
EODE.Wonderland.Style.Picker => "ColorPicker2DThumb"
EODE.Wonderland.Style.Colors.Gold => Color(0.72f, 0.62f, 0.3f);
// resize an icon
Texture2D EODE.Wonderland.Style.CreateTabIcon(Texture2D iconRef);
// GUILayoutOption equals
bool EODE.Wonderland.Style.GUILayoutOptionEquals(GUILayoutOption a, GUILayoutOption b);
Create a tab
See next page for more about FadeGroupScope.
Texture2D _icon;
public void Init(UnityEditor.Editor editor, Component component) {
_fgc = new FadeGroupContainer(editor, "", component.GetHashCode());
}
...
if (_icon == null) {
_icon = Style.CreateTabIcon(TextureUtility.GetEmbeddedIcon("My_icon"));
}
var header = new GUIContent(" " + "My title", _icon);
GUILayout.Box(header, Style.TabTitle);
var rect = GUILayoutUtility.GetLastRect();
var e = Event.current;
// Click
if (e.type == EventType.MouseDown && rect.Contains(e.mousePosition)) {
// Context
if (e.button == 1) {
// right click
}
// Fold / unfold
else {
_fgc.Opened = !_fgc.Opened;
}
e.Use();
}
// Content
using(new EditorGUILayout.FadeGroupScope(_fgc.Value)) {
if (_fgc.Visible) {
using(new GUILayout.VerticalScope(Style.TabContent)) {
...
// Draw tab content
}
}
}
_fgc.UpdateAfter();
Resize Texture2D
Texture must be Read/Write
enabled
Style.Resize(texture, width, height);
Style.Resize(texture, -1, height); // auto width
Style.Resize(texture, width, -1); // auto height