public static int alpha(LTRect ltRect, float to, float time, object[] optional){ return alpha( ltRect, to, time, h(optional) ); }
public static int scale(LTRect ltRect, Vector2 to, float time, object[] optional){ return scale( ltRect, to, time, h(optional) ); }
public static int alpha(LTRect ltRect, float to, float time, Hashtable optional){ init(); if( optional==null || optional.Count == 0 ) optional = new Hashtable(); ltRect.alphaEnabled = true; optional["rect"] = ltRect; return pushNewTween( tweenEmpty, new Vector3(to,0f,0f), time, TweenAction.GUI_ALPHA, optional ); }
public static int move(LTRect ltRect, Vector3 to, float time, object[] optional){ return move( ltRect, to, time, LeanTween.h( optional ) ); }
public static int scale(LTRect ltRect,Vector2 to, float time, Hashtable optional) { init(); if( optional==null || optional.Count == 0 ) optional = new Hashtable(); optional["rect"] = ltRect; return pushNewTween( tweenEmpty, to, time, TweenAction.GUI_SCALE, optional ); }
public static LTRect texture(LTRect rect, Texture texture, int depth) { rect.type = Element_Type.Texture; rect.texture = texture; return element(rect, depth); }
public LTDescr setRect(Rect rect) { this.ltRect = new LTRect(rect); return this; }
/** * Rotate a GUI element (using an LTRect object), to a value that is in degrees * * @method LeanTween.rotate * @param {LTRect} ltRect:LTRect LTRect that you wish to rotate * @param {float} to:float The final rotation with which to rotate to * @param {float} time:float The time to complete the tween in * @param {Array} optional:Array Object Array where you can pass <a href="#optional">optional items</a>. * @return {LTDescr} LTDescr an object that distinguishes the tween * @example * if(GUI.Button(buttonRect.rect, "Rotate"))<br> * LeanTween.rotate( buttonRect4, 150.0f, 1.0f).setEase(LeanTweenType.easeOutElastic);<br> * GUI.matrix = Matrix4x4.identity;<br> */ public static LTDescr rotate(LTRect ltRect, float to, float time) { return pushNewTween(tweenEmpty, new Vector3(to, 0f, 0f), time, TweenAction.GUI_ROTATE, options().setRect(ltRect)); }
/** * Scale a GUI Element to a certain width and height * * @method LeanTween.scale (GUI) * @param {LTRect} LTRect ltRect LTRect object that you wish to move * @param {Vector2} Vector2 to The final width and height to scale to (pixel based) * @param {float} float time The time to complete the tween in * @return {LTDescr} LTDescr an object that distinguishes the tween * @example * <i>Example Javascript: </i><br> * var bRect:LTRect = new LTRect( 0, 0, 100, 50 );<br> * LeanTween.scale( bRect, Vector2(bRect.rect.width, bRect.rect.height) * 1.3, 0.25 ).setEase(LeanTweenType.easeOutBounce);<br> * function OnGUI(){<br> * if(GUI.Button(bRect.rect, "Scale")){ }<br> * }<br> * <br> * <i>Example C#: </i> <br> * LTRect bRect = new LTRect( 0f, 0f, 100f, 50f );<br> * LeanTween.scale( bRect, new Vector2(150f,75f), 0.25f ).setEase(LeanTweenType.easeOutBounce);<br> * void OnGUI(){<br> * if(GUI.Button(bRect.rect, "Scale")){ }<br> * }<br> */ public static LTDescr scale(LTRect ltRect, Vector2 to, float time) { return pushNewTween(tweenEmpty, to, time, TweenAction.GUI_SCALE, options().setRect(ltRect)); }
public static LTDescr destroyAfter(LTRect rect, float delayTime) { return pushNewTween(tweenEmpty, Vector3.zero, delayTime, TweenAction.CALLBACK, options().setRect(rect).setDestroyOnComplete(true)); }
public static LTDescr moveMargin(LTRect ltRect, Vector2 to, float time) { return pushNewTween(tweenEmpty, to, time, TweenAction.GUI_MOVE_MARGIN, options().setRect(ltRect)); }
/** * Fade a GUI Object * * @method LeanTween.alpha * @param {LTRect} ltRect:LTRect LTRect that you wish to fade * @param {float} to:float the final alpha value (0-1) * @param {float} time:float The time with which to fade the object * @return {LTDescr} LTDescr an object that distinguishes the tween * @example * LeanTween.alpha(ltRect, 1f, 1f) .setEase(LeanTweenType.easeInCirc); */ public static LTDescr alpha(LTRect ltRect, float to, float time) { ltRect.alphaEnabled = true; return pushNewTween(tweenEmpty, new Vector3(to, 0f, 0f), time, TweenAction.GUI_ALPHA, options().setRect(ltRect)); }
/** * Test whether or not a tween is active on a LTRect * * @method LeanTween.isTweening * @param {LTRect} ltRect:LTRect LTRect that you want to test if it is tweening */ public static bool isTweening(LTRect ltRect) { for (int i = 0; i <= tweenMaxSearch; i++) { if (tweens[i].toggle && tweens[i].ltRect == ltRect) return true; } return false; }
/** * Cancel a specific tween with the provided id * * @method LeanTween.cancel * @param {LTRect} ltRect:LTRect LTRect object whose tweens you want to cancel * @param {float} id:int unique id that represents that tween */ public static void cancel(LTRect ltRect, int uniqueId) { if (uniqueId >= 0) { init(); int backId = uniqueId & 0xFFFF; int backCounter = uniqueId >> 16; // Debug.Log("uniqueId:"+uniqueId+ " id:"+backId +" action:"+(TweenAction)backType + " tweens[id].type:"+tweens[backId].type); if (tweens[backId].ltRect == ltRect && tweens[backId].counter == backCounter) removeTween((int)backId); } }
public static void update(int updateLevel) { if (isGUIEnabled) { init(); if (levelDepths[updateLevel] > 0) { color = GUI.color; int baseI = updateLevel * RECTS_PER_LEVEL; 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 == Element_Type.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 == Element_Type.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 = (float)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 int rotate(LTRect ltRect, float to, float time, Hashtable optional){ init(); if( optional==null || optional.Count == 0 ) optional = new Hashtable(); optional["rect"] = ltRect; return pushNewTween( tweenEmpty, new Vector3(to,0f,0f), time, TweenAction.GUI_ROTATE, optional ); }
public static LTRect label(LTRect rect, string label, int depth) { rect.type = Element_Type.Label; rect.labelStr = label; return element(rect, depth); }
public static int rotate(LTRect ltRect, float to, float time, object[] optional){ return rotate( ltRect, to, time, h(optional) ); }
public static LTRect element(LTRect rect, int depth) { isGUIEnabled = true; init(); int maxLoop = depth * RECTS_PER_LEVEL + RECTS_PER_LEVEL; int k = 0; if (rect != null) { destroy(rect.id); } if (rect.type == LTGUI.Element_Type.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 * RECTS_PER_LEVEL; 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 LTDescr setRect(LTRect rect) { this.ltRect = rect; return this; }