/// <summary> /// /// </summary> /// <param name="label"></param> /// <param name="color"></param> /// <param name="options"> /// GUIOptionType.Width /// GUIOptionType.expended /// GUIOptionType.Grid /// </param> /// <returns></returns> public static bool Button(string label, Vector4 color, params GUIOption[] options) { int width = 50; bool adaptive = true; if (options != null) { foreach (var opt in options) { if (opt.type == GUIOption.GUIOptionType.width) { width = (int)opt.value; adaptive = false; } else if (opt.type == GUIOption.GUIOptionType.expended) { width = (int)(s_ctx.currentArea.Rect.Z - s_ctx.currentLayout.Offset.X); adaptive = false; } else if (opt.type == GUIOption.GUIOptionType.grid) { width = (int)(s_ctx.currentArea.Rect.Z * opt.FloatValue); adaptive = false; } } } var curarea = s_ctx.currentArea.Rect; var rect = new Vector4(s_ctx.currentLayout.Offset, width, s_svLineHeight.Value); var rectpre = rect; Vector4 clip; bool valid = GUIUtility.RectClip(ref rect, curarea, out clip); bool clicked = false; if (valid) { if (adaptive) { var adaptiveValue = GUIOption.AdaptiveValue(curarea.X + curarea.Z - rect.X); clicked = GUI.Button(rect, label, color, GUI.Context.Color, true, options.Append(adaptiveValue, GUIOption.TextClip(clip))); width = adaptiveValue.IntValue; } else { clicked = GUI.Button(rect, label, color, GUI.Context.Color, true, options.Append(GUIOption.TextClip(clip))); } } AutoCaculateOffsetW(width); return(clicked); }