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. trooper

    trooper

    Joined:
    Aug 21, 2009
    Posts:
    748
    Thanks for that, we'll cross that bridge closer to launch :D
     
  2. DMTSource

    DMTSource

    Joined:
    Jul 11, 2013
    Posts:
    36
    I am still having this issue from 2012 with the web player. Is there a known fix? I am unable to get the uitoolkit to respont to clicks on the web player.
     
    Last edited: Apr 13, 2014
  3. Hasi_Indie

    Hasi_Indie

    Joined:
    Dec 25, 2013
    Posts:
    5

    use Script Execution Order and set UIToolKit.cs at first works for me ;)
     
  4. torghalo

    torghalo

    Joined:
    Nov 5, 2013
    Posts:
    4
    Can someone explain how to use UISlice9 feature? Is there possibility to combine for example progress bar and slice9 together?

    I'm creating UISlice9 object like:
    slice = UISlice9.create("example.png", "example.png", xpos, ypos, width, height, stp, srt, sbt, slt);

    And I'm receiving following output:
    $Untitled.png

    Original image ("example.png"):
    $example.png
     
    Last edited: Apr 17, 2014
  5. mlabarca

    mlabarca

    Joined:
    Jan 22, 2014
    Posts:
    5
    I've been having some issues rezing Uitext instances. My text keeps resizing from a "top anchor" instead of from the center. I've searched around this thread and messed around with the UixAnchor and UiyAnchor, but it still keeps resizing incorrectly. Here's my current code:

    Code (csharp):
    1.    
    2.           // Setting up UI text font
    3.         UIText font = new UIText("font", "font.png");
    4.         font.alignMode = UITextAlignMode.Center;
    5.  
    6.         // Initial text instance. Text size depends on screen width
    7.         scoreText = font.addTextInstance(score.ToString(), Screen.width / 2,
    8.                     Screen.height * 0.90f,  Screen.height* textSize480px/ 480f , 0);
    9.  
    10.         Debug.Log (scoreText.anchorInfo.ToString());
    11.         UIAnchorInfo textAnchor = scoreText.anchorInfo;
    12.  
    13.         textAnchor.ParentUIxAnchor =  UIxAnchor.Center;
    14.         textAnchor.ParentUIyAnchor = UIyAnchor.Center;
    15.         textAnchor.OriginUIxAnchor =  UIxAnchor.Center;
    16.         textAnchor.OriginUIyAnchor = UIyAnchor.Center;
    17.                 textAnchor.UIxAnchor = UIxAnchor.Center;
    18.         textAnchor.UIyAnchor = UIyAnchor.Center;
    19.         scoreText.anchorInfo = textAnchor;
    20.  
    21.         scoreText.refreshPosition();
    22.         Debug.Log (scoreText.anchorInfo.ToString());
    Those two debug statements print:
    (Before messing with anchors)
    Code (csharp):
    1. Parent UIObject:
    2. Parent UIxAnchor: Left
    3. Parent UIyAnchor: Top
    4. UIxAnchor: Left
    5. UIyAnchor: Top
    6. OriginUIxAnchor: Center
    7. OriginUIyAnchor: Top
    8. UIPrecision: Pixel
    9. OffsetX: 132
    10. OffsetY: 423.9
    11. UnityEngine.Debug:Log(Object)
    12. ScoreScript:Start() (at Assets/Scripts/loose/ScoreScript.cs:60)
    (After messing with anchors)
    Code (csharp):
    1. Parent UIObject:
    2. Parent UIxAnchor: Center
    3. Parent UIyAnchor: Center
    4. UIxAnchor: Center
    5. UIyAnchor: Center
    6. OriginUIxAnchor: Center
    7. OriginUIyAnchor: Center
    8. UIPrecision: Pixel
    9. OffsetX: 132
    10. OffsetY: 423.9
    11. UnityEngine.Debug:Log(Object)
    12. ScoreScript:Start() (at Assets/Scripts/loose/ScoreScript.cs:72)
    Am I doing something wrong? Sorry if this has been asked before I've been having a hard time searching this huge thread.
     
  6. torghalo

    torghalo

    Joined:
    Nov 5, 2013
    Posts:
    4
    @mlabarca

    You're doing something wrong.

    Code (csharp):
    1.  
    2. UIText font = new UIText("font", "font.png");
    3. scoreText = font.addTextInstance(score.ToString(), 0.0f,  0.0f);
    4. scoreText.textScale = 1.0f; // Here you set yours scale like 1.0f is meant as 100%
    5. scoreText.positionFromTop(0.0f, 0.0f) // Sets position based on percentage of screen from top, as earlier 1.0f is meant as 100%
    6. scoreText.alignMode = UIxAnchor.Center;
    7. scoreText.verticalAlignMode = UIyAnchor.Top;
    8.  
    For me this piece of code scales text from the center.
     
    mlabarca likes this.
  7. torghalo

    torghalo

    Joined:
    Nov 5, 2013
    Posts:
    4
    BUMP

    EDIT: No one? Even oddgames staff?
     
    Last edited: May 6, 2014
  8. LaurensiusTony

    LaurensiusTony

    Joined:
    May 22, 2013
    Posts:
    78
    [edited]
    hi i trying to build my project to my windows phone 8 and getting error in this line of code

    Code (CSharp):
    1. #if UNITY_EDITOR || UNITY_STANDALONE_OSX || UNITY_STANDALONE_WIN || UNITY_WEBPLAYER || UNITY_ANDROID || UNITY_STANDALONE_LINUX
    2.         var deviceAllowsHD = true;
    3. #else
    4.         var deviceAllowsHD = ( allowPod4GenHD && iPhone.generation == iPhoneGeneration.iPodTouch4Gen ) || iPhone.generation != iPhoneGeneration.iPodTouch4Gen;
    5. #endif
    6.         if (autoTextureSelectionForHD && deviceAllowsHD)
    7.         {
    8.             // are we loading up a 4x texture?
    9.             if (Screen.width >= maxWidthOrHeightForHD || Screen.height >= maxWidthOrHeightForHD)
    10.             {
    11. #if UNITY_EDITOR
    12.                 Debug.Log("switching to 4x GUI texture");
    13. #endif
    14.                 isHD = true;
    15.                 scaleFactor = 4;
    16.                 hdExtension = "4x";
    17.             }
    18.             // are we loading up a 2x texture?
    19.             else if (Screen.width >= maxWidthOrHeightForSD || Screen.height >= maxWidthOrHeightForSD)
    20.             {
    21. #if UNITY_EDITOR
    22.                 Debug.Log("switching to 2x GUI texture");
    23. #endif
    24.                 isHD = true;
    25.                 scaleFactor = 2;
    26.             }
    27.         }
    the error are
    and
     
    Last edited: Jun 4, 2014
  9. BeornSlim

    BeornSlim

    Joined:
    Jun 22, 2014
    Posts:
    3
    "Free" is meant for NonCommercial use, did I get it right?
     
  10. boderless

    boderless

    Joined:
    Jun 4, 2014
    Posts:
    9
    Thank you Sir!
     
  11. evrooije

    evrooije

    Joined:
    Jul 8, 2014
    Posts:
    2
    Little issue I ran into with UIVerticalLayout and absolute positioning e.g. using pixelsFromTopLeft on the vertical layout container itself. If I call any of the pixelsFrom methods, nothing seems to happen (the children of the layout, in my case a bunch of buttons, do not move). The relative positioning does seem to work.

    I investigated the code and found the absolute positioning bit in IPositionablePositioningExtensions. There are only overloads for IPositionable which repositions only the IPositionable and not any children. There is no way to position a container and the children thereof, i.e. there is no overload for UIAbstractContainer and no method to access the children via IPositionable. This means that any call to the container does reposition the container as a sprite but not the children inside the container. Other nasty bit is that _children in UIAbstractContainer is protected so cannot be seen in IPositionablePositioningExtensions...

    What I ended up doing for now was making _children in UIAbstractLayout a public member and add an overload that takes UIAbstractContainer as first argument, loop the children and call refreshPosition. Obviously a bit of a cludge, would be better to create something in IPositionable that exposes the children or provides a method to do the child positioning refresh. Might look into that later but for now my little patch looks like this (in IPositionablePositioningExtensions) which seems to solve the problem:

    Code (CSharp):
    1.  
    2. public static void pixelsFromTopLeft( this UIAbstractContainer container, int pixelsFromTop, int pixelsFromLeft )
    3. {
    4.    container.pixelsFromTopLeft( pixelsFromTop, pixelsFromLeft, UIyAnchor.Top, UIxAnchor.Left );
    5. }
    6.  
    7. public static void pixelsFromTopLeft( this UIAbstractContainer container, int pixelsFromTop, int pixelsFromLeft, UIyAnchor yAnchor, UIxAnchor xAnchor )
    8. {
    9.    UIAnchorInfo anchorInfo = container.anchorInfo;
    10.    anchorInfo.ParentUIxAnchor = UIxAnchor.Left;
    11.    anchorInfo.ParentUIyAnchor = UIyAnchor.Top;
    12.    anchorInfo.UIxAnchor = xAnchor;
    13.    anchorInfo.UIyAnchor = yAnchor;
    14.    anchorInfo.OffsetX = pixelsFromLeft;
    15.    anchorInfo.OffsetY = pixelsFromTop;
    16.    anchorInfo.UIPrecision = UIPrecision.Pixel;
    17.    container.anchorInfo = anchorInfo;
    18.    container.refreshPosition();
    19.  
    20.    foreach( var item in container._children )
    21.      item.refreshPosition();
    22. }
    23.  
    Posting this in case someone runs into a similar issue.
     
    Last edited: Jul 8, 2014
  12. mlabarca

    mlabarca

    Joined:
    Jan 22, 2014
    Posts:
    5
    Hi this is probably a late reply, but there is a fork with wrapper fix that makes Uitoolkit work for webplayer. Try it out:
    https://github.com/hyakugei/UIToolkit
     
  13. Deleted User

    Deleted User

    Guest

    can anybody help with an example of hiding sprites...I can do it from start..but not from anywhere else, I get a null reference exception...object.hidden = true; why can I not get his to work?..how do I hide certain UI items..then on a user button press, show ,certain Sprites,etc..I can disable the whole component, but I can not figure out how to show/hide individual sprites at run time.....an example would really help...thanks..
     
  14. Dogg

    Dogg

    Joined:
    Mar 5, 2014
    Posts:
    203
    Well it looks like it's too bad for you for the people who found this in 2014(sadly I'm one of them), as this thread is dead. No one going to help anymore. Just letting everyone who stumbles upon this know.
     
  15. evrooije

    evrooije

    Joined:
    Jul 8, 2014
    Posts:
    2
    Another one on the list of things I had to fix in UIToolkit, posting here again in case anyone runs into it or for ODD Games to consider as fix. Internally the UIText class has an array of 256 elements to store font information. This causes array index out of bounds when using fonts outside the ASCII & ISO/IEC 8859-1 range of characters. I.e. it already crashes when loading bitmap fonts and font descriptors that contain Unicode characters/ symbols/ glyphs outside of the 256 of Basic Latin and supplement. In order to be able to use the full set of Unicode characters, the array needs to be modified into e.g. a Dictionary.

    In UIText.cs in the UIElements folder (see https://github.com/oddgames/UIToolkit/blob/master/Assets/Plugins/UIToolkit/UIElements/UIText.cs).

    Line 40, change struct UIFontCharInfo into a class as we will be modifying instances of it in a dictionary (structs in dictionary are immutable). Look for the private UIFontCharInfo[] _fontDetails; below that and change it to Dictionary<int, UIFontCharInfo>. Don't forget to import System.Collections.Generic.

    In the UIText constructor, there is the init of _fontDetails array and a for loop filling the elements. Remove them (lines 82, 83, 84) and replace with _fontDetails = new Dictionary<int, UIFontCharInfo>();

    Line 135 where it says _fontDetails[idNum].charID = new int(); add _fontDetails.Add(idNum, new UIFontCharInfo()); on the line above to make sure the character is dynamically added to the dictionary. In all the other cases it goes well as the dictionary's elements are also referenced with square brackets [ ] like the original array. Last but not least, with the above changes a KeyNotFoundException was thrown for some reason in configureSpriteForCharId (line 453). Make sure that at the beginning on this method a ContainsKey test is done on the dictionary to fill in any potential gaps (in the array based system UIToolkit just assumed that all UIFontCharInfo elements were there):

    if (!_fontDetails.ContainsKey(charId)) _fontDetails.Add(charId, new UIFontCharInfo());

    Not sure if this is the most efficient fix (because of the ContainsKey hack), but seems to work for me ... :)
     
  16. JBR-games

    JBR-games

    Joined:
    Sep 26, 2012
    Posts:
    708
    @trooper i went on github and saw a post from 12-4-14 that there were updates coming to UIToolkit. Do you have an approximate date?
    Will you be giving support on the forums or maybe by email ?

    @ForceVFX
    Did you ever find a good way to turn sprites on and off.
    Also does anyone know a good way to rotate sprites so for instance rotating it depending on joystick position.
    Thanks
     
  17. Deleted User

    Deleted User

    Guest

    @ForceVFX
    Did you ever find a good way to turn sprites on and off.
    Also does anyone know a good way to rotate sprites so for instance rotating it depending on joystick position.
    Thanks[/QUOTE]


    1). Yes: Basic structure for showing/hiding individual sprites
    Code (CSharp):
    1. private UISprite rank_E2;
    2.  
    3.                 ////all the ranks per level accomlplished
    4.                 rank_E2 = UI.firstToolkit.addSprite("rank_E2.png", 0, 0, 0);
    5.                 rank_E2.centerize();
    6.                 rank_E2.positionFromTopLeft(rank_posY, rank_posX);
    7.                 rank_E2.scale = new Vector3(currScale, currScale, currScale);
    8.                 rank_E2.hidden = false;
    9.  
    10. public void showUISprite(UISprite rankImg)
    11.     {
    12.         rankImg.hidden=false;
    13.     }
    14.  
    15. public void hideUISprite(UISprite rankImg)
    16.     {
    17.         rankImg.hidden = true;
    18.     }
    #2). Yes..Basic structure for rotating individual sprites

    Code (CSharp):
    1. private UIKnob speed_pointer;
    2.  
    3.  
    4.                 speed_pointer = UIKnob.create("needle_white.png", "needle_white.png", 0, 0);
    5.                 //speed_pointer = UI.firstToolkit.addSprite("Pointer.png", 0, 0, 0);
    6.                 speed_pointer.centerize();
    7.                 speed_pointer.scale = new Vector3(currScale + speedPointer_Scale, currScale + speedPointer_Scale, currScale + speedPointer_Scale);
    8.                 speed_pointer.positionFromTopLeft(speedPointer_posY, speedPointer_posX);
    9.                 speed_pointer.value = 0.0f;
    10.  
    11.  
    12. void Update()
    13. {
    14. updateDials(speed_pointer, (play.Speed * speedPointerStart), alt_pointer, (play.Altitude * altPointer_Start), rpm_pointer, play.vSliderOld, fuel_pointer, (play.Fuel * fuelPointerStart));
    15. }
    16.  
    17. public void updateDials(UIKnob spdDial, float mySpeed, UIKnob altDial, float myAlt, UIKnob rpmDial, float myRPM,UIKnob fuelDial, float myFuel)
    18. {
    19.  
    20.     spdDial.value = Mathf.Clamp(mySpeed, 0.0f, 1.0f);
    21.     altDial.value = Mathf.Clamp(myAlt, 0.0f, 1.0f);
    22.     rpmDial.value = Mathf.Clamp(myRPM, 0.0f, 1.0f);
    23.     fuelDial.value = Mathf.Clamp(myFuel, 0.0f, 1.0f);
    24.  
    25.     //Debug.Log("val to Speedometer:" + Mathf.Clamp(mySpeed, 0.0f, 1.0f));
    26.     //Debug.Log("val to Altimter:" + Mathf.Clamp(myAlt, 0.0f, 1.0f));
    27.  
    28. }
    29.  
    This is what powers my dials and rank graphic / 10 ranks (show/hide)
    This was a 4 hour re creation of my Unity 4.6 UI, I need to see just how much faster UI Toolkit was on same project/UI Design..can I duplication exactly? and at faster speed?...yes!

    Good luck!!

    p-
     
  18. JBR-games

    JBR-games

    Joined:
    Sep 26, 2012
    Posts:
    708
    @ForceVFX
    Thanks, I really appreciate it. Ill give it a try this weekend.