Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fixes to UIAnimation and UITextInstance #40

Merged
merged 3 commits into from

2 participants

@FrittenKeeZ

Fixed auto reverse in UIAnimation to work with alpha and color animations.
Made UITextInstance able to use IPositionable extensions.

FrittenKeeZ added some commits
@FrittenKeeZ FrittenKeeZ Added UIStateSprite that functions almost the same way as UIStateButt…
…on, but without the whole touch part.

Merge branch 'master' of https://github.com/prime31/UIToolkit
Updated UITextInstance to be positionable by IPositionable extensions.
Fixed auto reverse to work with alpha and color in UIAnimation
1f3e4c9
@FrittenKeeZ FrittenKeeZ Removed UIStateSprite from master 19fa201
@FrittenKeeZ FrittenKeeZ Fixed auto reverse in UIAnimation to work with alpha and color animat…
…ions.

Made UITextInstance able to use IPositionable extensions.
82089d7
@prime31 prime31 merged commit e5433a8 into oddgames:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 22, 2011
  1. @FrittenKeeZ

    Added UIStateSprite that functions almost the same way as UIStateButt…

    FrittenKeeZ authored
    …on, but without the whole touch part.
    
    Merge branch 'master' of https://github.com/prime31/UIToolkit
    Updated UITextInstance to be positionable by IPositionable extensions.
    Fixed auto reverse to work with alpha and color in UIAnimation
Commits on Nov 23, 2011
  1. @FrittenKeeZ
  2. @FrittenKeeZ

    Fixed auto reverse in UIAnimation to work with alpha and color animat…

    FrittenKeeZ authored
    …ions.
    
    Made UITextInstance able to use IPositionable extensions.
This page is out of date. Refresh to see the latest.
View
11 Assets/Plugins/UIToolkit/UIAnimation/UIAnimation.cs
@@ -143,10 +143,19 @@ public IEnumerator animate()
{
autoreverse = false; // make sure this only happens once!
- // flip our start and target and reset the start time
+ // flip our start and target
var temp = start;
start = target;
target = temp;
+ // flip alpha variables
+ var tempFloat = startFloat;
+ startFloat = targetFloat;
+ targetFloat = tempFloat;
+ // flip color variables
+ var tempColor = startColor;
+ startColor = targetColor;
+ targetColor = tempColor;
+ // reset the start time
startTime = Time.time;
}
else
View
22 Assets/Plugins/UIToolkit/UIElements/UITextInstance.cs
@@ -5,13 +5,17 @@
// addTextInstance (from the UIText class) returns one of these so we just need to do a .text on the instance to update it's text
-public class UITextInstance : UIObject
+public class UITextInstance : UIObject, IPositionable
{
private UIText _parentText;
private string _text;
public UITextAlignMode alignMode;
public UITextVerticalAlignMode verticalAlignMode;
-
+
+ private float _width;
+ public new float width { get { return _width; } }
+ private float _height;
+ public new float height { get { return _height; } }
public float xPos;
public float yPos;
public float scale;
@@ -33,7 +37,7 @@ public string text
_text = value;
// cleanse our textSprites of any excess that we dont need
- if( _text.Length < textSprites.Count )
+ if( _text.Length > textSprites.Count )
{
for( var i = textSprites.Count - 1; i > _text.Length; i-- )
{
@@ -44,6 +48,7 @@ public string text
}
_parentText.updateText( this );
+ updateSize();
}
}
@@ -89,8 +94,15 @@ public UITextInstance( UIText parentText, string text, float xPos, float yPos, f
this.depth = depth;
this.colors = colors;
_hidden = false;
+ updateSize();
}
-
+
+ private void updateSize()
+ {
+ Vector2 size = _parentText.sizeForText(_text, scale);
+ _width = size.x;
+ _height = size.y;
+ }
private void applyColorToSprites()
{
@@ -171,5 +183,5 @@ public override void transformChanged()
{
}
-
+
}
Something went wrong with that request. Please try again.