public static void Update(int updateLevel) { if (isGUIEnabled) { Initialize(); if (levelDepths[updateLevel] > 0) { color = GUI.color; int baseI = updateLevel * RectsPerLevel; int maxLoop = baseI + levelDepths[updateLevel]; // RECTS_PER_LEVEL;//; for (int i = baseI; i < maxLoop; i++) { r = levels[i]; // Debug.Log("r:"+r+" i:"+i); if (r != null /*&& checkOnScreen(r.rect)*/) { //Debug.Log("label:"+r.labelStr+" textColor:"+r.style.normal.textColor); if (r.UseColor) { GUI.color = r.Color; } if (r.Type == ElementType.Label) { if (r.Style != null) { GUI.skin.label = r.Style; } if (r.UseSimpleScale) { GUI.Label(new Rect((r.Rect.x + r.Margin.x + r.RelativeRect.x) * r.RelativeRect.width, (r.Rect.y + r.Margin.y + r.RelativeRect.y) * r.RelativeRect.height, r.Rect.width * r.RelativeRect.width, r.Rect.height * r.RelativeRect.height), r.LabelStr); } else { GUI.Label(new Rect(r.Rect.x + r.Margin.x, r.Rect.y + r.Margin.y, r.Rect.width, r.Rect.height), r.LabelStr); } } else if (r.Type == ElementType.Texture && r.Texture != null) { Vector2 size = r.UseSimpleScale ? new Vector2(0f, r.Rect.height * r.RelativeRect.height) : new Vector2(r.Rect.width, r.Rect.height); if (r.SizeByHeight) { size.x = r.Texture.width / (float)r.Texture.height * size.y; } if (r.UseSimpleScale) { GUI.DrawTexture(new Rect((r.Rect.x + r.Margin.x + r.RelativeRect.x) * r.RelativeRect.width, (r.Rect.y + r.Margin.y + r.RelativeRect.y) * r.RelativeRect.height, size.x, size.y), r.Texture); } else { GUI.DrawTexture(new Rect(r.Rect.x + r.Margin.x, r.Rect.y + r.Margin.y, size.x, size.y), r.Texture); } } } } GUI.color = color; } } }
public static TweenRectangle Element(TweenRectangle rect, int depth) { isGUIEnabled = true; Initialize(); int maxLoop = depth * RectsPerLevel + RectsPerLevel; int k = 0; if (rect != null) { Destroy(rect.ID); } if (rect.Type == ElementType.Label && rect.Style != null) { if (rect.Style.normal.textColor.a <= 0f) { Debug.LogWarning("Your GUI normal color has an alpha of zero, and will not be rendered."); } } if (rect.RelativeRect.width == float.PositiveInfinity) { rect.RelativeRect = new Rect(0f, 0f, Screen.width, Screen.height); } for (int i = depth * RectsPerLevel; i < maxLoop; i++) { r = levels[i]; if (r == null) { r = rect; r.RotateEnabled = true; r.AlphaEnabled = true; r.SetId(i, global_counter); levels[i] = r; // Debug.Log("k:"+k+ " maxDepth:"+levelDepths[depth]); if (k >= levelDepths[depth]) { levelDepths[depth] = k + 1; } global_counter++; return(r); } k++; } Debug.LogError("You ran out of GUI Element spaces"); return(null); }
public static TweenRectangle Texture(TweenRectangle rect, Texture texture, int depth) { rect.Type = ElementType.Texture; rect.Texture = texture; return(Element(rect, depth)); }
public static TweenRectangle Label(TweenRectangle rect, string label, int depth) { rect.Type = ElementType.Label; rect.LabelStr = label; return(Element(rect, depth)); }
public TweenDescription SetRect(Rect rect) { TweenRectangle = new TweenRectangle(rect); return(this); }
public TweenDescription SetRect(TweenRectangle rect) { TweenRectangle = rect; return(this); }