private void SampleGUIOption() { if (GUILayout.BeginCollapseGroup("[GUIOptions]", ref m_sampleGUIOption)) { GUILayout.Button("Expended", GUIOption.Expended); GUILayout.BeginHorizontal(); GUILayout.Button("Short-Label"); GUILayout.Button("LLLLLLLLLLLLong-Label"); GUILayout.Button("Width-100", GUIOption.Width(100)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Button("Grid 0.5", GUIOption.Grid(0.5f)); GUILayout.Button("Grid 0.25", GUIOption.Grid(0.25f)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Button("AlignLeft", GUIOption.AlignHLeft, GUIOption.Grid(0.33f)); GUILayout.Button("AlignCenter", GUIOption.AlignHCenter, GUIOption.Grid(0.34f)); GUILayout.Button("AlignRight", GUIOption.AlignHRight, GUIOption.Grid(0.33f)); } GUILayout.EndHorizontal(); } GUILayout.EndCollapseGroup(); }
public bool DrawMenuItem() { if (GUILayout.Button(Label, GUIOption.Width(GUIMenuList.ItemWidth))) { Invoke(); return(true); } return(false); }
public override void Draw(GUIEvent guievent) { var rect = new Vector4(0, 0, 500, 150).CenterPos(GUI.Context.baseRect.Size()); GUILayout.BeginArea(rect, GUIStyle.Current.DockContentColor, GUIOption.Border(null)); { rect.W = GUILayout.s_svLineHeight; GUI.Rect(rect, GUIStyle.Current.ColorActiveD); GUILayout.Text(title); GUILayout.Text(info, (Vector4?)null, GUIOption.Width(480)); var off = GUILayout.s_ctx.currentLayout.Offset; GUILayout.Space(120 - off.Y); bool hascancel = m_callbackCancel != null; GUILayout.BeginHorizontal(); if (!hascancel) { GUILayout.Indent(200); if (GUILayout.Button(buttonConfirm, GUIOption.Width(100), GUIOption.Border())) { if (m_callbackConfirm != null) { m_callbackConfirm.Invoke(); } OnDestroy(); } } else { GUILayout.Indent(150); if (GUILayout.Button(buttonConfirm, GUIOption.Width(100), GUIOption.Border())) { if (m_callbackConfirm != null) { m_callbackConfirm.Invoke(); } OnDestroy(); } if (GUILayout.Button(buttonCancel, GUIOption.Width(100), GUIOption.Border())) { if (m_callbackCancel != null) { m_callbackCancel.Invoke(); } OnDestroy(); } } GUILayout.EndHorizontal(); } GUILayout.EndArea(); }
public bool DrawMenuItem() { var pos = GUILayout.s_ctx.GetNextDrawPos(); if (GUILayout.Button(Label, GUIStyle.Current.TabBtnColor, GUIOption.Width(ItemWidth))) { pos.X += GUILayout.s_ctx.currentLayout.LastDrawWidth; InternalSetStartPos(pos); Invoke(); return(true); } return(false); }
private void SampleTabView() { GUILayout.Indent(10); GUILayout.Text("TabView Horizontal"); m_sampleTabIndex = GUILayout.TabView(m_sampleTabIndex, m_sampleTabNames, (index) => { GUILayout.Button("TabItems " + index); }, GUIOption.Width(300), GUIOption.Height(100)); GUILayout.Space(10); GUILayout.Text("TabView Vertical"); m_sampleTabIndex = GUILayout.TabViewVertical(m_sampleTabIndex, m_sampleTabNames, (index) => { GUILayout.Button("TabItems " + index); }, 50, GUIOption.Width(300), GUIOption.Height(100)); }
private void SampleText() { string longtext = "A game engine is a software framework designed for the creation and development of video games.Developers use them to create games for consoles, mobile devices and personal computers.The core functionality typically provided by a game engine includes a rendering engine(renderer) for 2D or 3D graphics, a physics engine or collision detection(and collision response), sound, scripting"; if (GUILayout.BeginCollapseGroup("[TextRendering]", ref m_sampleText)) { //GUILayout.Text(longtext); //GUILayout.Text(@"Single line text."); //GUILayout.Text("Space[ ]"); //GUILayout.Text("Tab[\t]"); GUILayout.BeginContainer(new Vector4(GUILayout.s_ctx.currentLayout.Offset, 100, 100), RigelColor.Green); GUI.TextBlock(new Vector4(0, 0, 100, 100), longtext, RigelColor.Red); GUILayout.EndContainer(); GUILayout.Space(100); GUILayout.TextBlock(longtext, GUIOption.Width(300)); GUILayout.TextBlock(longtext); } GUILayout.EndCollapseGroup(); }
private void DrawTabBar() { GUILayout.BeginHorizontal(); { GUILayout.SetLineHeight(20); { if (GUILayout.Button("+", GUIStyle.Current.TabBtnColorS, GUIOption.Width(20))) { var win = new GUIWindowTest1(); AddContent(win); } if (GUILayout.Button("-", GUIStyle.Current.TabBtnColorS, GUIOption.Width(20))) { if (m_info != null) { RemoveContent(m_contentFocus); } } if (m_content.Count == 0) { GUILayout.Text("No-Content"); } else { foreach (var c in m_content) { GUILayout.Space(2); DrawTabBarContentBtn(c); GUILayout.Space(-2); } } } GUILayout.RestoreLineHeight(); } GUILayout.EndHorizontal(); }
private int DrawTabHeader(Vector4 rectHeader) { GUILayout.BeginAreaR(rectHeader, GUIStyle.Current.BackgroundColorS); if (m_verticalMode) { GUILayout.BeginVertical(); for (int i = 0; i < m_tabnames.Count; i++) { if (GUILayout.Button(m_tabnames[i], m_tabindex == i ? GUIStyle.Current.ColorActiveD : GUIStyle.Current.BackgroundColorS, GUIOption.Width(m_verticalTabWidth))) { m_tabindex = i; } } GUILayout.EndVertical(); } else { GUILayout.BeginHorizontal(); for (int i = 0; i < m_tabnames.Count; i++) { if (GUILayout.Button(m_tabnames[i], m_tabindex == i ? GUIStyle.Current.ColorActiveD : GUIStyle.Current.BackgroundColorS)) { m_tabindex = i; } } GUILayout.EndHorizontal(); } GUILayout.EndArea(); return(m_tabindex); }
/// <summary> /// /// </summary> /// <param name="rect">relative</param> /// <param name="content"></param> /// <param name="label"></param> /// <returns></returns> public string Draw(Vector4 rect, string content, string label) { bool contentChanged = false; bool posChanged = false; if (content != LastString) { Pos = content.Length; posChanged = true; } var rectab = GUILayout.GetRectAbsolute(rect); if (GUI.Event.IsMouseActiveEvent()) { Focused = GUIUtility.RectContainsCheck(rectab, GUI.Event.Pointer); } else if (!GUI.Event.Used) { if (Focused && GUI.Event.EventType == RigelEGUIEventType.KeyDown) { int lastpos = Pos; var newcontent = GUITextProcessor.ProcessInput(content, GUI.Event.Key, ref Pos); if (content != newcontent) { contentChanged = true; content = newcontent; GUI.Context.InputChanged = true; } else { if (lastpos != Pos) { posChanged = true; GUI.Context.InputChanged = true; } } } } int labelwidth = 0; GUILayout.BeginHorizontal(); if (!string.IsNullOrEmpty(label)) { labelwidth = (int)(rect.Z * 0.4f); labelwidth = Mathf.Clamp(labelwidth, 40, 100); GUILayout.Text(label, (Vector4?)null, GUIOption.Width(labelwidth)); GUILayout.Indent(10); } GUILayout.RectOnFlow(new Vector2(GUILayout.SizeRemain.X, GUILayout.s_svLineHeight), Focused ? GUIStyle.Current.BackgroundColorS: GUIStyle.Current.BackgroundColor); var startpos = GUILayout.CurrentLayout.Offset; if (Focused) { GUILayout.Text(content, GUIStyle.Current.ColorActiveD); } else { GUILayout.Text(content); } if (contentChanged || posChanged) { string substr = content.Substring(0, Pos); int posx = GUI.Context.Font.GetTextWidth(substr); PointerRect = new Vector4(startpos.X + posx + 3, startpos.Y, 1, GUILayout.s_svLineHeight); } if (Focused) { GUILayout.Rect(PointerRect, GUIStyle.Current.Color); } GUILayout.EndHorizontal(); LastString = content; return(content); }
private void SampleLayout() { GUILayout.Text("GUILayout Flow"); GUI.Context.BackgroundColor.Set(GUIStyle.Current.BackgroundColorS1); GUILayout.Text("GUILayout.Horizontal"); { GUILayout.BeginHorizontal(); { GUILayout.BeginVertical(); { GUILayout.Button("V1-0"); GUILayout.Button("V1-1"); GUILayout.Button("V1-2"); } GUILayout.EndVertical(); GUILayout.BeginVertical(); { GUILayout.Button("V0-0"); GUILayout.Button("V0-1"); } GUILayout.EndVertical(); GUILayout.BeginVertical(); { GUILayout.BeginHorizontal(); { GUILayout.Button("V1-H0-0"); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Button("V1-H1-0"); GUILayout.Button("V1-H1-1"); } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); } GUILayout.EndHorizontal(); //wrong GUILayout.Text("AAAAAA"); } GUILayout.Text("GUILayout.Vertical"); GUILayout.BeginVertical(); { GUILayout.BeginHorizontal(); { GUILayout.Text("TestText"); GUILayout.BeginVertical(); GUILayout.Button("ButtonExtend"); GUILayout.Button("ButtonExtend"); GUILayout.EndVertical(); GUILayout.Button("TestButton"); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Button("Width 100px", GUIOption.Width(100)); GUILayout.Button("Height 40px", GUIOption.Height(40)); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Text("Test Text"); } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); GUI.Context.BackgroundColor.Restore(); }
private void SampleText() { m_sampleTextTabIndex = GUILayout.TabView(m_sampleTextTabIndex, m_sampleTextTabList, (index) => { if (index == 0) { //GUI GUILayout.Text("GUI.DrawChar"); var rect = GUI.GetRectAbsolute(new Vector4(5, 30, 20, 20)); GUI.RectA(rect, RigelColor.White); GUI.TextA(rect, new Vector2(-3, -3), "R", RigelColor.Black); rect.X += 25; GUI.RectA(rect, RigelColor.White); GUI.TextA(rect, new Vector2(13, 10), "R", RigelColor.Black); GUILayout.Space(30); GUILayout.Text("GUI.DrawTextA"); rect = new Vector4(rect.X - 25, rect.Y + 50, 50, 30); GUI.RectA(rect, RigelColor.White); GUI.TextA(rect, new Vector2(-5, -3), "ABCDEFGHI", RigelColor.Black); GUI.TextA(rect, new Vector2(5, 20), "ZXVBNMGHGJ", RigelColor.Black); GUILayout.Space(35); GUILayout.Text("GUI.DrawText (With Group)"); GUI.BeginGroup(new Vector4(5, 140, 135, 50), RigelColor.White); { GUI.Text(new Vector4(-10, -3, 140, 30), "HELLOWORLD!", GUIStyle.Current.ColorActive); var rectg = new Vector4(50, 20, 100, 25); GUI.Rect(rectg, RigelColor.Black); GUI.Text(rectg, "HELLO WORLD!", GUIStyle.Current.ColorActive); } GUI.EndGroup(); //GUILayout GUILayout.Space(55); GUILayout.Text("GUILayout Text"); GUILayout.BeginHorizontal(); { GUILayout.Text("DefaultText"); GUILayout.Text("Text with Border", null, null, 3, GUIOption.Border(GUIStyle.Current.ColorActiveD)); GUILayout.Text("TextWithColor", GUIStyle.Current.ColorActiveD); GUILayout.Text("TextWithBG", GUI.Context.Color, GUIStyle.Current.ColorActiveD); } GUILayout.EndHorizontal(); GUILayout.Text("Text Width"); GUILayout.BeginHorizontal(); { GUILayout.Text("100px", GUI.Context.Color, GUIStyle.Current.ColorActiveD, GUIOption.Width(100)); GUILayout.Text("50px", GUI.Context.Color, GUIStyle.Current.ColorActiveD, GUIOption.Width(50)); GUILayout.Text("20px", GUI.Context.Color, GUIStyle.Current.ColorActiveD, GUIOption.Width(10)); } GUILayout.EndHorizontal(); GUILayout.Text("Horizontal Alignment"); GUILayout.BeginHorizontal(); { GUILayout.Text("Align Center", GUI.Context.Color, GUIStyle.Current.ColorActiveD, GUIOption.Width(100), GUIOption.AlignHCenter); GUILayout.Text("Align Center", GUI.Context.Color, GUIStyle.Current.ColorActiveD, GUIOption.Width(100), GUIOption.AlignHLeft); GUILayout.Text("Align Right", GUI.Context.Color, GUIStyle.Current.ColorActiveD, GUIOption.Width(100), GUIOption.AlignHRight); } GUILayout.EndHorizontal(); GUILayout.Text("Vertical Alignment"); GUILayout.BeginHorizontal(); { GUILayout.SetLineHeight(30); GUILayout.Text("Line Height 30", GUI.Context.Color, GUIStyle.Current.ColorActiveD, GUIOption.Width(100), GUIOption.AlignHCenter); GUILayout.Text("Align Top", GUI.Context.Color, GUIStyle.Current.ColorActiveD, GUIOption.Width(100), GUIOption.AlignVTop); GUILayout.Text("Align Center", GUI.Context.Color, GUIStyle.Current.ColorActiveD, GUIOption.Width(100), GUIOption.AlignVCenter); GUILayout.Text("Align Bottom", GUI.Context.Color, GUIStyle.Current.ColorActiveD, GUIOption.Width(100), GUIOption.AlignVBottom); GUILayout.RestoreLineHeight(); } GUILayout.EndHorizontal(); } else { GUILayout.TextBlock(m_sampleLongText); } }); }
private void SampleScrollView() { if (GUILayout.BeginCollapseGroup("[ScrollView]", ref m_sampleScrollView)) { //scrollview1 GUILayout.BeginHorizontal(); { m_scrollViewPosV = GUILayout.BeginScrollView(m_scrollViewPosV, GUIScrollType.Vertical, GUIOption.Width(200), GUIOption.Height(200)); { GUILayout.Button("Scroll Vertical"); for (int i = 0; i < 5; i++) { GUILayout.Space(100); GUILayout.Text("WWW" + i); GUILayout.Button("Btn" + i); } } GUILayout.EndScrollView(); m_scrollViewPosH = GUILayout.BeginScrollView(m_scrollViewPosH, GUIScrollType.Horizontal, GUIOption.Width(200), GUIOption.Height(200)); { GUILayout.Button("Scroll Horizontal"); GUILayout.Space(20); GUILayout.BeginHorizontal(); for (int i = 0; i < 5; i++) { GUILayout.Button("Btn " + i); GUILayout.Text("TEXT:" + i); GUILayout.Indent(100); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); for (int i = 0; i < 7; i++) { GUILayout.Button("-Btn----" + i); } GUILayout.EndHorizontal(); } GUILayout.EndScrollView(); m_scrollViewPosAll = GUILayout.BeginScrollView(m_scrollViewPosAll, GUIScrollType.All, GUIOption.Width(200), GUIOption.Height(200)); { GUILayout.Button("Scroll All"); GUILayout.BeginHorizontal(); for (int i = 0; i < 7; i++) { GUILayout.Button("-Btn----" + i); } GUILayout.EndHorizontal(); GUILayout.BeginVertical(); for (int i = 0; i < 5; i++) { GUILayout.Space(100); GUILayout.Text("WWW" + i); GUILayout.Button("Btn" + i); } GUILayout.EndVertical(); } GUILayout.EndScrollView(); } GUILayout.EndHorizontal(); GUILayout.Button("dwdw"); } GUILayout.EndCollapseGroup(); }
public sealed override void Draw(GUIEvent guievent) { m_hedaerRect.Z = m_size.X; m_pos.X = (int)m_pos.X; m_pos.Y = (int)m_pos.Y; var rect = new Vector4(m_pos, m_size.X, m_size.Y); GUILayout.BeginContainer(rect, GUIStyle.Current.BackgroundColor, GUIOption.Border()); { bool headerover = GUIUtility.RectContainsCheck(GUILayout.GetRectAbsolute(m_hedaerRect), GUI.Event.Pointer); GUILayout.Rect(m_hedaerRect, headerover ? GUIStyle.Current.ColorActive : GUIStyle.Current.ColorActiveD); GUILayout.BeginHorizontal(); GUILayout.Text(m_title); if (m_dialogCloseable) { GUILayout.Indent((int)(rect.Z - GUILayout.CurrentLayout.Offset.X - 24)); if (GUILayout.Button("X", GUIStyle.Current.ColorActiveD, GUIOption.Width(23))) { OnDestroy(); } } GUILayout.EndHorizontal(); var contentrect = GUILayout.Context.currentArea.Rect; contentrect.Y += m_hedaerRect.W; contentrect.Z -= 1; contentrect.W -= (m_hedaerRect.W + 1); GUILayout.BeginContainer(contentrect); { OnDraw(); } GUILayout.EndContainer(); //for optimize bool onmove = false; if (m_dialogMoveable && m_dragMove.OnDrag(headerover)) { m_pos += GUI.Event.DragOffset; m_pos.X = Mathf.Clamp(m_pos.X, 0, GUI.Context.baseRect.Z); m_pos.Y = Mathf.Clamp(m_pos.Y, 0, GUI.Context.baseRect.W); onmove = true; } if (m_dialogRezieable && !onmove) { var rectResize = GUILayout.Context.currentArea.Rect; rectResize.Y += (rectResize.W - 3); rectResize.X += rectResize.Z - 3; rectResize.Z = 6; rectResize.W = 6; if (m_dragResizeHV.OnDrag(rectResize)) { m_size += GUI.Event.DragOffset; m_size.Y = Mathf.Clamp(m_size.Y, m_dialogMinSize.Y, m_dialogMaxSize.Y); m_size.X = Mathf.Clamp(m_size.X, m_dialogMinSize.X, m_dialogMaxSize.X); } } } //var grect = new Vector4(0, 0, 100, 30); //GUI.DrawRect(grect, RigelColor.Green); //GUI.DrawText(grect, "GUITEXT", RigelColor.White); //GUI.Button(grect, "GUIBUTTON"); //GUI.DrawBorder(grect, 2, RigelColor.Green); GUILayout.EndContainer(); }