Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Prime31 UIToolkit Multi Resolution GUI Solution Ready for Use...and it's free

Discussion in 'iOS and tvOS' started by prime31, May 3, 2011.

  1. 1337GameDev

    1337GameDev

    Joined:
    Oct 31, 2011
    Posts:
    54
    Im a bit hung up on lambda expressions and scrollable lists of guiTextures / UIButton objects. (I know i could just make empty code UIButtons with same pressed/unpressed image if code needs it) But i am trying to develop a scrolling list i can hide/unhide (with a button) and am running into problems. I have to have the button that hides it slide out of screen (which is ok using sender parameter) but i am confused as to how to access other UIButtons on screen using lambda expressions, as they seem to be unable to modify values / etc if used within a lamda expression method name. I wanted to be able to pass in the buttons/objects i am accessing besides sender in as additional parameters, but i am curious as to how to do this using the current button delegate.
    Am i just missing something here?

    I also am curious as to how to develop a parenting system to move the menu as one unit (rather than moving each independent element when sliding in/out to hide or unhide it). Any way to go about this, and have UIButtons and maybe GUITextures visible and scrollable in this setup?
     
  2. actuallystarky

    actuallystarky

    Joined:
    Jul 12, 2010
    Posts:
    188
    Either way seems valid. Elements that are hidden cost nothing in fill rate and only a tiny amount of GPU on vertex transformations.

    I did have a UI that persisted between scenes but dropped it because the text instances were spawning instances that wouldn't clean up, even after manual .clear() and .destroy() although this was using an older version of UIToolkit. But you might want to check on the UI master object in the inspector as your game runs and check that the sprite list isn't steadily growing.
     
  3. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,204
    The UITextInstance not deleting on the singleton was an issue I was having, but with having all the objects created up front, I don't have to worry about cleanup between scenes as I'm simply hiding them when I don't need them in the singleton. My main concern with making the UI a singleton was so that I have more control over when things are instantiated and have more control between scenes. The other major reason was for Load Screens between scenes it was much easier to have a Sprite I can call at anytime.

    Now that you have reverted to a non-singleton use of the UI again, I was wondering how do you control/setup load screens, as we don't really have control over the order of when the UI and UItoolkits are instantiated/setup when the scene loads?
    Thanks for all your responses by the way.
     
  4. actuallystarky

    actuallystarky

    Joined:
    Jul 12, 2010
    Posts:
    188
    Simply put, I don't. I fade to black at the end of a level, load and fade from black in the new level. My load times are short enough (about a second on the iPhone) so that the lack of moving loading sprites isn't really noticeable.

    But yes, the only way you're getting a nicely animated loading screen is with a persistent UI like you're doing. Do you ever change the .text of a UITextInstance? That's what was causing my uncontrolled sprite growth.
     
  5. mmuller

    mmuller

    Joined:
    Nov 23, 2010
    Posts:
    92
    Anyone have any success with Chinese and Korean text using UIToolkit, When I output mine using Glyphdesigner / Texturepacker when I run the game I get an error

    Code (csharp):
    1. IndexOutOfRangeException: Array index is out of range.
    2. UIText.loadConfigfile (System.String filename) (at Assets/Plugins/UIToolkit/UIElements/UIText.cs:151)
    3. UIText..ctor (.UIToolkit manager, System.String fontFilename, System.String textureFilename) (at Assets/Plugins/UIToolkit/UIElements/UIText.cs:113)
    4. UIText..ctor (System.String fontFilename, System.String textureFilename)
    5. UIBuild.GameStarted (System.String gameType) (at Assets/Scripts/UIBuild.cs:530)
    6. UIBuild.<StartMenu>m__9 (.UIButton startSender) (at Assets/Scripts/UIBuild.cs:288)
    7. UIButton.onTouchEnded (UIFakeTouch touch, Vector2 touchPos, Boolean touchWasInsideTouchFrame) (at Assets/Plugins/UIToolkit/UIElements/UIButton.cs:123)
    8. UIToolkit.lookAtTouch (UIFakeTouch touch) (at Assets/Plugins/UIToolkit/UIToolkit.cs:223)
    9. UIToolkit.Update () (at Assets/Plugins/UIToolkit/UIToolkit.cs:57)
    10.  
    This is the font .txt file:

    Code (csharp):
    1. info face="STHeitiSC-Medium" size=32 bold=0 italic=0 charset="" unicode=0 stretchH=100 smooth=1 aa=1 padding=0,0,0,0 spacing=1,1
    2. common lineHeight=32 base=28 scaleW=256 scaleH=128 pages=1 packed=0
    3. page id=0 file="orbsc.png"
    4. chars count=15
    5. char id=21629 x=1 y=1 width=38 height=39 xoffset=1 yoffset=-3 xadvance=32 page=0 chnl=0 letter="命"
    6. char id=33328 x=40 y=1 width=37 height=38 xoffset=1 yoffset=-2 xadvance=32 page=0 chnl=0 letter="舰"
    7. char id=21578 x=78 y=1 width=37 height=38 xoffset=2 yoffset=-3 xadvance=32 page=0 chnl=0 letter="告"
    8. char id=27700 x=116 y=1 width=37 height=38 xoffset=2 yoffset=-2 xadvance=32 page=0 chnl=0 letter="水"
    9. char id=22833 x=154 y=1 width=36 height=38 xoffset=2 yoffset=-3 xadvance=32 page=0 chnl=0 letter="失"
    10. char id=23436 x=191 y=1 width=35 height=38 xoffset=2 yoffset=-3 xadvance=32 page=0 chnl=0 letter="完"
    11. char id=25439 x=1 y=41 width=37 height=37 xoffset=1 yoffset=-1 xadvance=32 page=0 chnl=0 letter="损"
    12. char id=32423 x=39 y=41 width=37 height=37 xoffset=2 yoffset=-1 xadvance=32 page=0 chnl=0 letter="级"
    13. char id=35686 x=77 y=41 width=37 height=37 xoffset=2 yoffset=-2 xadvance=32 page=0 chnl=0 letter="警"
    14. char id=30340 x=115 y=41 width=35 height=37 xoffset=3 yoffset=-2 xadvance=32 page=0 chnl=0 letter="的"
    15. char id=27597 x=151 y=41 width=37 height=36 xoffset=2 yoffset=-0 xadvance=32 page=0 chnl=0 letter="母"
    16. char id=25972 x=189 y=41 width=36 height=36 xoffset=2 yoffset=-2 xadvance=32 page=0 chnl=0 letter="整"
    17. char id=24179 x=1 y=79 width=36 height=36 xoffset=2 yoffset=-0 xadvance=32 page=0 chnl=0 letter="平"
    18. char id=29983 x=38 y=79 width=36 height=36 xoffset=2 yoffset=-3 xadvance=32 page=0 chnl=0 letter="生"
    19. char id=32 x=75 y=79 width=0 height=0 xoffset=8 yoffset=48 xadvance=8 page=0 chnl=0 letter="space"
    I only have the characters I need in the fontfile and its txt file. and copy/pasted them into my addTextInstance String?


    Okay, so I fixed it - the way to deal with this was to alter the char id's to those in the ASCII range for the characters I needed and use the ASCII character equivalent. painful but works and much better than having an array that reaches the lofty heights of 30,000+ elements to get the whole unicode set in...
     
    Last edited: Feb 14, 2012
  6. KeeZ

    KeeZ

    Joined:
    Feb 1, 2011
    Posts:
    20
    I was the one to rewrite the layout positioning system to include parented offsets, as I really needed it for our project (Distorpia). I also needed a proper menu system and ended up hacking the containers to allow basic UIObjects instead of only UISprites cascading of colors to children objects made the menu behave very nicely with fading etc.

    You can see it work in the link I posted, but as for the core of UIToolkit I agree that it needs a big rewrite to accommodate for better extensibility.
     
  7. Markus

    Markus

    Joined:
    Jan 9, 2010
    Posts:
    7
    Yo UIToolkiters of the commUnity,

    I'm using UIToolkit in a project (obviously) and have been exploring the various animations: position, rotation, alpha, etc. Trouble is, the framerate on device (iOS) is garbage and the buttons have a delay on them before any animation begins (input hits right away).

    Wondering if anyone else is experiencing this or any similar poor performance.

    I've got two atlases being used and have been manipulating the animations via a few coroutines. I suspect this is related to UIToolkit since the framerate of the game is fine after the FE assets are destroyed. In the meantime I'm going to try the same thing in a clean project on the chance it's something else.

    Thanks for this, thanks to Prime31 for putting the tool out there in the first place! Hoping I can clear this up and keep using it!
     
  8. auzette

    auzette

    Joined:
    Mar 23, 2009
    Posts:
    74
    This is probably really obvious, but I'm wondering how to create just a simple sprite. No interaction, just a background image I can pull and display through UIToolkit.

    I know there's a UISprite class, and I could make a wrapper for it that does nothing but add/remove the sprite, but I keep thinking there must be an easy way that I'm just plain missing.

    Thanks for any insight.
     
  9. ej2009

    ej2009

    Joined:
    Mar 2, 2009
    Posts:
    353
    This thread is huge, only discovered UIToolit yesterday :)

    Anyway, simple question - is this possible to create panel with horizontal and vertical layout at the same time?

    For example I need 3 rows with 5 columns of buttons in it?

    If this is possible I'm probably going to ditch EZ GUI for my current game as I find it hard to work with (powerful, yes).
     
  10. auzette

    auzette

    Joined:
    Mar 23, 2009
    Posts:
    74
    another question as I work with UIToolkit for the first time... I created a button, set its size (300 x 400, just for fun), and then called:

    // Positions a sprite in the center of the screen
    public static void positionCenter( this UISprite sprite )

    which according to the documentation will center it to the middle of the screen...

    It doesn't, though. The button stays at the top left of the screen.
    Here's my code:

    var background = UIButton.create ( "background.png", "background_hit.png", 0, 0);
    background.positionCenter();
    background.setSize (400, 300);
    AppDebug.Log(background.anchorInfo.ToString ());
     
  11. auzette

    auzette

    Joined:
    Mar 23, 2009
    Posts:
    74
    Found the solution. You can't setSize after positionCenter(), or it will screw up the centering. I had to setSize, THEN positionCenter(). Not sure why the set size would dictate changing the anchoring...
     
  12. yuriks

    yuriks

    Joined:
    Nov 11, 2011
    Posts:
    25
    May be related to this: http://forum.unity3d.com/threads/111870-Procedural-mesh-update-slow-on-iphone-4
     
  13. aronsommer

    aronsommer

    Joined:
    Dec 5, 2010
    Posts:
    202
    Hi guys!

    Before i found this awesome UIToolkit i used GUITextures and GUIText for buttons on iOS.

    In Javascript i drag the GUITexture in the inspector and than i make a HitTest.

    Code (csharp):
    1. var ButtonFireAcc : GUITexture;
    2.  
    3. function Update(){
    4. var count = Input.touchCount;
    5. for(var i : int = 0;i < count; i++){   
    6. var touch : Touch = Input.GetTouch(i);
    7. touch = Input.GetTouch(i);
    8. if(ButtonFireAcc.HitTest(touch.position)){
    9. Fire();
    10. }
    11. }
    12. }
    Can i access a UIButton with my Javascript HitTest when i now create the UIButton in a C# script like this?

    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class ButtonFireAcc : MonoBehaviour {
    5. void Start () {
    6. var ButtonFireAcc = UIButton.create( "ButtonFireAcc.png", "ButtonFireAcc.png", 0, 0 );
    7. }
    8. }
     
  14. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,204
    I'm having a little bit of difficulty understanding how UIStateButton works exactly. What's the difference between onTouchUpInside and onStateChange? Also, how do I properly switch between the sprites saved in my UIStateButton, similar to how the the UIButton would be able to switch to the highlighted sprite when it detected a touchupinside? I looked over the UIStateManager example, but it seems incomplete and rather vague on how the UIStateButton functions. Thanks.

    Also, has anyone had issues with zOrdering with regards to using multiple atlases? It seems despite giving the correct zOrder, if sprites are on separate atlases the zOrder seems to not sort correctly.

    Edit:
    Directly modifying the sprite.zIndex in code to what I want seems to fix the zOrder issue.
     
    Last edited: Feb 17, 2012
  15. kamikazetg

    kamikazetg

    Joined:
    Feb 17, 2012
    Posts:
    1
    Been sifting through the posts here trying to find an answer to my issue but have yet to come across anything. Maybe I'm just searching for the wrong thing..but here's my issue with UIToolkit:

    When I create a VerticalPanel that is empty, it looks perfectly fine (using offsets to manually increase the size for visual check). But, when I add any child to it, no matter what size it is, the Vertical Panel always leaves a gap at the bottom before adding the bottom image. This gap is always exactly the same size as the middle texture. I have yet to figure out why..I even tried plain black and white boxes. Every time I add a child..it adds the gap. The demo looks perfectly fine...and I even copied and pasted the demo code and ran it directly. It's got me stumped for sure.

    I solved it, temporarily, by modifying the verticalpanel class and increasing the middlebar height by the size of the middle bar image height.

    Edit: I also noticed that positionCenter on a panel is not actually centered. It's more to the right/bottom like it's centering from a point other than the middle or topleft of the panel or not calculating the size of the panel (this is when calling positionCenter AFTER ending updates on the panel). Though that could simply be an issue with padding on my elements..they're just crappy prototypes afterall. Not nearly as confusing as the gap issue.
     
    Last edited: Feb 17, 2012
  16. Virtual

    Virtual

    Joined:
    Oct 30, 2010
    Posts:
    15
    HI Prime31 i am having an issue that I am trying to solve I am using UIButton for a button then I am using a UISprite to add a highlight over the button when its pressed, at the end of a turn its then hidden and placed over the next UIButton that is pressed, now the problem i am having is that its not doing the alpha blending properly. as you can see with picture A the alpha works fine but in picture B (after only moving it down) the alpha doesn't seam to work as well.


    Any Help would be great :D

    Virtual
     

    Attached Files:

  17. guyo

    guyo

    Joined:
    Feb 19, 2012
    Posts:
    3
    I'm trying to figure out how to make a toggle mute button in C# for a mobile game.
    I've tried searching unity ref and the web for help but this UI toolkit doesn't seem to have any support (where's the wiki????) aside from what's in this forum.

    I'm a designer, not a coder so any help on this super basic task would be greatly appreciated guys!

    This is what I have which obviously just turns the music off once clicked. Toggle states work as far as the texture swapping is concerned, but turning that audio back on is where I'm stuck.



    using UnityEngine;
    using System.Collections;

    public class myGame_ui : MonoBehaviour
    {

    // Use this for initialization
    void Start()
    {


    //Sound Button
    var soundButton = UIToggleButton.create( "btn_pause.png", "btn_sound.png", "btn_pause.png", 0, 0 );


    //Position
    soundButton.positionFromTopLeft( 0.48f, 0.18f );

    //Action
    soundButton.onToggle += ( sender, newValue ) => AudioListener.volume = 0.0f;
    soundButton.selected = true;

    }
     
  18. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,204

    Just write a custom function that does this:

    Code (csharp):
    1.  
    2.  
    3. public void MyCustomOnToggleFunction( UIToggleButton sender)
    4. {
    5.             if(sender.selected)
    6.             {
    7.                         AudioListener.volume = 1.0f;
    8.             }
    9.             else
    10.             {
    11.                         AudioListener.volume = 0.0f;
    12.             }
    13. }
    14.  
    Then attach it to the onToggle event:

    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4.  
    5. public class myGame_ui : MonoBehaviour
    6. {  
    7.  
    8. // Use this for initialization
    9. void Start()
    10. {
    11.  
    12.  
    13. //Sound Button
    14. var soundButton = UIToggleButton.create( "btn_pause.png", "btn_sound.png", "btn_pause.png", 0, 0 );
    15.  
    16.  
    17. //Position
    18. soundButton.positionFromTopLeft( 0.48f, 0.18f );
    19.  
    20. //Action   
    21. soundButton.onToggle += MyCustomOnToggleFunction;
    22. soundButton.selected = true;
    23.  
    24. }
    25.  
    26.  
    27.  
     
    Last edited: Feb 20, 2012
  19. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,204
    Does anybody know if you can use the advance features on the licensed version of TexturePacker, such as using Heuristics and Algorithms and trim/crop, for the spritesheets that can be loaded by UIToolkit? This would beneficial to me, so I can fit more sprites on one sheet.

    And if you can are there any special export properties I need to set for it to export properly?
    Thank you.
     
  20. actuallystarky

    actuallystarky

    Joined:
    Jul 12, 2010
    Posts:
    188
    The advanced features all work fine except for rotation. I'm glad to see that there are other paid users of Texture Packer. It's an awesome piece of software that's never caused me a moment of grief.
     
  21. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,204
    I've noticed when using the advanced features like trim and crop, the size of my sprites on my UI seem to be off. But only the normal frame, not the highlighted frame. Does anyone have any ideas?

    My initial guess is that because the sourcesize width and height are not equal like they are in the free version, when I tried to set their size with UIToolkit they are not properly scaled, but I could be wrong. If I am right though, can anyone think of a way to scale it properly the way I want? Or am I out of luck in this case?

    I'll check and post what I find.
     
  22. KeeZ

    KeeZ

    Joined:
    Feb 1, 2011
    Posts:
    20
    We're in the process of supporting trim and crop of TexturePacker, but currently they aren't.
     
  23. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,204
    Ok, that's what I thought. Do you know is there a specific file I should be looking in if I want to attempt to add this feature myself?
     
  24. numberkruncher

    numberkruncher

    Joined:
    Feb 18, 2012
    Posts:
    953
    Are draw calls reduced to one like with EZGUI?
     
  25. defjr

    defjr

    Joined:
    Apr 27, 2009
    Posts:
    436
    Yes.
     
  26. MaGe

    MaGe

    Joined:
    Feb 26, 2012
    Posts:
    3
    Hey!

    Edit: Rephrase question

    I was wondering if its possible to reposition an element of the UIToolkit without using positionTo. I wrote a class which returns a UIButton and a UISpriteAnimation parented to the Button.

    I can choose the positioning functions for the field var which holds the button but it doesn't apply them.
    E.g.:
    _test = SkillButton.create("fireball", 0, 0);
    _test.positionFromBottomLeft( 0.1f, 0.1f);

    The test button and the child are still at 0,0 (top-left corner);

    Greetz
     
    Last edited: Feb 26, 2012
  27. BeforeTheLight

    BeforeTheLight

    Joined:
    Jan 7, 2011
    Posts:
    168
    Looking for a little help here on a progress bar. I have two exact same images both filled one blue for a foreground, the bg is colored from green to yellow to red and should get exposed as the top bar goes down. When I create my progress bar I get the BG on top of the Foreground and cannot see the bar scaling. If i swap their positions I get the desired effect however the back image once again is the one that scales and the foreground image covers it up. Is there a way to make this work with this kit? Or do i have to make a new bar with just a frame thats empty in the center? Thanks in advance!
     
  28. MaGe

    MaGe

    Joined:
    Feb 26, 2012
    Posts:
    3
    It sounds as if you use it like that (respectively, the png swapped):
    UIProgressBar.create( "foreground.png", "bg.png", xPos, yPos, 0, 0);

    Look at the bars properties, it actually asks for the bar and a border, not background and foreground.
    The border is ofc on top of the bar, thats why you see your colored background when you swap the images.
     
  29. BeforeTheLight

    BeforeTheLight

    Joined:
    Jan 7, 2011
    Posts:
    168
    I understand this as I have read the docs, but I have BG and FG and am converting from Unity GUI to UIToolKit. I want to use them. Can I use them?
    bar = UIProgressBar.create(graphicUI,"TimerFG.png","TimerBG.png",0,0,0,0,false); is what allows me to scale the proper image, however it is behind what should be the back image. If I Swap the images I get the proper image on top but the rear image still is the one that changes. Is it possible to change the border instead of the bar, or put the bar on top of the border, to make it so MaGe can understand. Or do I need to make a border that is clear in the center?
     
  30. MaGe

    MaGe

    Joined:
    Feb 26, 2012
    Posts:
    3
    Yes, thats how I understood the class.
    Bar = actual scaling bar image
    Border = Frame with transparent center

    To achieve what you want, i would create a sprite with your BG and add the bar with your FG on top. Optionally u create a border or fill the property with an empty 1x1px png (Or rewrite the bar class).
     
  31. MythicalCity

    MythicalCity

    Joined:
    Feb 10, 2011
    Posts:
    420
    Hi, has anyone figured out how to add a textInstance into a scrollable container? I tried this:

    scrollView.addChild(theName.textSprites.ToArray());

    Where theName is a textInstance.

    This kind of works but it places each letter on a separate line within the container.
     
  32. guyo

    guyo

    Joined:
    Feb 19, 2012
    Posts:
    3
    Thanks for the input! Unfortunately is still does not work, I get this error

    Assets/Price Check UI/scripts/priceCheck_ui.cs(66,49): error CS0119: Expression denotes a `type', where a `variable', `value' or `method group' was expected

    It seems there were errors on both ends of your script examples. The current error I'm getting is in the main script with all the button info.

    I remedied the handler scripts issues by making these adjustments ;

    using UnityEngine;
    using System.Collections;

    public class muteScript : MonoBehaviour
    {

    public void testMute (UIToggleButton sender)
    {
    if(sender.selected)
    {
    AudioListener.volume = 1.0f;
    }
    else
    {
    AudioListener.volume = 0.0f;
    }
    }
    }



    The second script is as follows


    //Sound Button
    var soundButton = UIToggleButton.create( "btn_pause.png", "btn_sound.png", "btn_pause.png", 0, 0 );

    //Position
    soundButton.positionFromTopLeft( 0.48f, 0.18f );

    //Action
    //soundButton.onToggle += (sender, newValue) => Debug.Log( "clicked Sound button: " + sender );
    soundButton.onToggle += muteScript ;
    soundButton.selected = true ;


    //Console Msg
    //soundButton.onToggle += ( sender ) => Debug.Log( "clicked Sound button: " + sender );




    Any more suggestions would be great!
     
  33. KeeZ

    KeeZ

    Joined:
    Feb 1, 2011
    Posts:
    20
    UISpriteManager and UISprite in BaseElements at least. There may be other classes you have to change as well, but it is not something I have looked in to yet.
     
  34. KeeZ

    KeeZ

    Joined:
    Feb 1, 2011
    Posts:
    20
    Unless you link the code for SkillButton somewhere it's hard to figure out where it goes wrong.
     
  35. KeeZ

    KeeZ

    Joined:
    Feb 1, 2011
    Posts:
    20
    You can't unless you hack the container to allow it, and I know from experience it won't be pretty.
     
  36. defjr

    defjr

    Joined:
    Apr 27, 2009
    Posts:
    436
    I've been putting buttons or empty sprites into the scrollview and positioning text relative to the buttons. It's kinda nasty but I make the text hidden when my button or sprite is clipped.

    I hope this helps. :-/
     
  37. KeeZ

    KeeZ

    Joined:
    Feb 1, 2011
    Posts:
    20
    The easiest would be this:
    Code (csharp):
    1.  
    2. soundButton.onToggle += (sender, selected) => AudioListener.volume = selected ? 1.0f : 0.0f;
    3.  
     
  38. guyo

    guyo

    Joined:
    Feb 19, 2012
    Posts:
    3
    Thank you so much! Works like a charm. Is there a Wiki (or something like it) with scripting references for the UIToolkit? As a beginner I constantly hit road blocks when I look up references/ examples that don't seem to "align" with the way things are laid out in UIToolkit.
    I hope I can one day soon help others like you've all helped me , thanks again!
     
  39. numberkruncher

    numberkruncher

    Joined:
    Feb 18, 2012
    Posts:
    953
    What would be the best approach (in terms of efficiency for iOS) for overlays (that move upwards and fade out) for "Head Shot", "Extra Life", etc. type messages?
     
  40. KeeZ

    KeeZ

    Joined:
    Feb 1, 2011
    Posts:
    20
    Unfortunately many examples are getting outdated, and with this being an open source project where multiple people add each their bit, there isn't a clear overview or scripting reference anymore.
     
  41. KeeZ

    KeeZ

    Joined:
    Feb 1, 2011
    Posts:
    20
    I would use a sort of buffer system with either UISprite or UITextInstance depending on what you use, and assign the sprites or text to a free instance in the buffer and animate that, just using the hidden property to check if the instance is free.
     
  42. numberkruncher

    numberkruncher

    Joined:
    Feb 18, 2012
    Posts:
    953
    @KeeZ that sounds like a good approach. If I had a pool of say 5 UITextInstance's would each instance cache an unused number of characters for efficiency (to avoid lots of garbage collection)? or does it allocate and free individual character polygons on demand?

    Thanks!
     
  43. KeeZ

    KeeZ

    Joined:
    Feb 1, 2011
    Posts:
    20
    Currently unneeded character spaces are freed, but existing ones have their sprites replaced.
     
  44. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,204
    I seem to running into an issue where our game is GUI asset heavy and we have to have numerous atlases due to the fact UIToolkit does no import trimmed/cropped pixels from TexturePacker.

    Normally this wouldn't be an issue, but b/c of the direction of our game it requires the textures to be truecolor for the best possible quality. The major issue is right now b/c of this, the iPad runs out of of memory and crashes.

    I was wondering is there a way I can control how much memory is taken up by the textures at one time if they're set through the inspector on UIToolkit, and if there's a way to simulate TexturePacker's trim feature in code using UIToolkit to shrink my atlases, or combine my atlases somehow? Thanks.
     
  45. KeeZ

    KeeZ

    Joined:
    Feb 1, 2011
    Posts:
    20
    UIToolkit solely rely on Unity (and you) to handle compression, so if you hit the memory limit with packed sprites in 2048x2048 images I'm not sure there's anything to do. Remember it's the combined texture memory of the whole game, so if you have huge textures/normal maps for models and such that will add to the problem as well.
     
  46. DexRobinson

    DexRobinson

    Joined:
    Jul 26, 2011
    Posts:
    594
    This is the easiest system I have seen for making HUD's. I would like to see something for setting how big you want the object to be displayed on your screen. Other than that took my 13 HUD draw calls to 1. I can't complain about that.
     
  47. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,204
    While we're on that subject does anyone know the official texture memory limit on iPad and iPhones?
    Also is there a way to control when a texture is loaded that is set in the Inspector of a game object?
     
  48. OmniverseProduct

    OmniverseProduct

    Joined:
    Feb 26, 2012
    Posts:
    1,568
    Forgive me if this was already answered, but, is there any chance for a mac or windows release for this?
     
  49. KeeZ

    KeeZ

    Joined:
    Feb 1, 2011
    Posts:
    20
    UIToolkit works very well for Mac OSX and Windows.
     
  50. lockd

    lockd

    Joined:
    Jul 22, 2011
    Posts:
    5
    Does anyone know how to create an array of UISprite objects?


    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4.    
    5. public class uiGameplay : MonoBehaviour
    6. {
    7.     public ArrayList scoreSetA ;
    8.     public UISprite scoreA0;
    9.  
    10.     void Start(){
    11.         scoreA0 = UI.firstToolkit.addSprite( "score_0.png", 0, 0, 1 );
    12.         scoreSetA[0]= scoreA0; 
    13.     }
    14. }
    Gives this error:

    Code (csharp):
    1.  
    2. NullReferenceException: Object reference not set to an instance of an object
    3. uiGameplay.gameStart () (at Assets/Scripts/uiGameplay.cs:11)
    4. UnityEngine.GameObject:SendMessage(String)
    5. uiMenu:playButtonClick() (at Assets/Scripts/uiMenu.cs:195)
    6. uiMenu:<Start>m__6(UIButton) (at Assets/Scripts/uiMenu.cs:38)
    7. UIButton:onTouchEnded(UIFakeTouch, Vector2, Boolean) (at Assets/Plugins/UIToolkit/UIElements/UIButton.cs:119)
    8. UIToolkit:lookAtTouch(UIFakeTouch) (at Assets/Plugins/UIToolkit/UIToolkit.cs:233)
    9. UIToolkit:Update() (at Assets/Plugins/UIToolkit/UIToolkit.cs:57)
    10.  
    11.  
    EDIT:
    Fixed it, I was delcaring the array the wrong way, need to be:

    Code (csharp):
    1.  
    2.     public UISprite [] scoreSetA = new UISprite[10];
    3.  
     
    Last edited: Mar 2, 2012