Search Unity

OpenGUI: Open source GUI framework for Unity

Discussion in 'Works In Progress - Archive' started by mrzapp, May 26, 2013.

  1. Lokkij

    Lokkij

    Joined:
    Aug 18, 2013
    Posts:
    22
    No, it's more that text is scaled a bit differently depending on position. Here's a sloppily edited image of the exact same text, but in a different position in the scene:

    You can see it a lot better when you zoom in: especially the C and the P is a lot "flatter" in the bottom version.

    The text in the image is just a regular OGLabel, and it is the exact same object too (not two different labels with the same text in different positions). It is a child of another widget (OGSlicedSprite), could that have something to do with it?
     

    Attached Files:

    Last edited: Apr 1, 2014
  2. mrzapp

    mrzapp

    Joined:
    May 26, 2013
    Posts:
    137
    That's.. odd. If that is consistent, that it really depends on where it's placed, then I am kind of clueless. Otherwise it might be the import settings of the bitmap, we can control that from the OGFont component.

    Widgets being children of each other isn't new, no problem there.

    EDIT: Added to the tracker
     
    Last edited: Apr 2, 2014
  3. mrzapp

    mrzapp

    Joined:
    May 26, 2013
    Posts:
    137
    You guys, I just had an idea. Long story short, we could make OpenGUI behave like OnGUI while still maintaining its current functionality. So you'd be able to make your GUI entirely in code, but without losing the convenience of previewing it outside play mode, and while still maintaining the reduced draw calls.

    Is anyone here interested in this? I reckon it's doable, just not quite sure how yet.
     
    Last edited: Apr 4, 2014
  4. Lokkij

    Lokkij

    Joined:
    Aug 18, 2013
    Posts:
    22
    I'm not sure how useful that really would be. Sure, creating the GUI in code could be useful, but the reason I'm using OpenGUI is because you can create the GUI outside of the code ;)
    If you think it'd be useful though, I'm all for it :)
     
  5. mrzapp

    mrzapp

    Joined:
    May 26, 2013
    Posts:
    137
    I am just trying to weigh the pros and cons of managing a lot of GameObjects via code against drawing them directly. The former causes clutter in your scene, but the latter causes clutter in your code. At the very least, though, in a draw loop you can be sure that all widgets are gone when you leave the screen, no objects to clean up. But anywho, if it's not such a sought after feature, I'll focus on the most requested ones first :)

    I am looking into dynamic font rendering currently, as that could solve the problem with the oddly rendered glyphs.
     
  6. cjke-7777

    cjke-7777

    Joined:
    Apr 28, 2013
    Posts:
    9
    I love this idea. I've just stumbled across this thread looking for a GUI solution (having both NGUI and tk2d, but not being 100% sold (they're good, don't get me wrong)).

    I'd be interested how you would approach the code approach
     
  7. mrzapp

    mrzapp

    Joined:
    May 26, 2013
    Posts:
    137
    OpenGUI already supports all the relevant widget states, and the drawing methods are written in OGDrawHelper. The only real problem we're having is that font glyphs and all other textures are are drawn in 2 separate passes. If we want direct drawing, we'll have to find a way to either queue or merge them.

    For now, you can still create your own widget types, as outlined in this guide, but it's not quite the same.

    I appreciate your feedback, I was beginning to think I was the only one interested in this :D Please let me know if there's anything I can help with, or if you have any other feature requests.
     
  8. mrzapp

    mrzapp

    Joined:
    May 26, 2013
    Posts:
    137
    I started another plugin, OpenStash, which is an inventory framework. Also, in case you're interested in runtime pathfinding and didn't come across it yet, OpenPath is also a thing, although it hasn't been updated much lately. I'll get around to it when it becomes a more central part of my own development, though.
     
    Last edited: Apr 15, 2014
  9. Lokkij

    Lokkij

    Joined:
    Aug 18, 2013
    Posts:
    22
    Hmm, it seems the link to OpenStash isn't working.
     
  10. mrzapp

    mrzapp

    Joined:
    May 26, 2013
    Posts:
    137
    Yeah, looks like a database error. I contacted the admins, hope it'll be back up soon. In the meantime, have a look at the repo and the website

    EDIT: Screw it, I created a new thread, updated links
     
    Last edited: Apr 15, 2014
  11. Deleted User

    Deleted User

    Guest

    I hate to sound needy and all, but I've started using your framework recently and I'm wondering.
    What about text styling? Is it possible to have part of a string bold etc?
    I think it'd be awesome feature if we were able to use html/bbcode tags in order to achieve simple text styling.
    Honestly it might be already implemented but I cannot find it on the wiki.

    Oh and before I forget: Good job, it's brilliant framework.
     
  12. mrzapp

    mrzapp

    Joined:
    May 26, 2013
    Posts:
    137
    There is an issue ticket aboit colour coding, and I have been considering implementing markdown as well, but it'll have to be after it supports FreeType. It'll happen hefore v1.0
     
  13. Deleted User

    Deleted User

    Guest

    There's an issue I've found with TextAlignment property...
    You see when the text and the container and unchanged then it's alright but when you change the container size and force wordwrap (if text was fitting in single line before) the Middle alignment is still keeping first line aligned with Middle instead of keeping the aligning the multi-lines with the middle.

    I know I've probably failed to make myself clear so here's some screenshots :

     
  14. mrzapp

    mrzapp

    Joined:
    May 26, 2013
    Posts:
    137
    That is a known issue as well, it has to do with the glyph rendering algorithm being procedural in a way that it can't anticipate how many lines are going to be in the OGLabel. This will also be addressed before v1.0, but thanks for pointing it out. It's always good to have examples.
     
  15. Lokkij

    Lokkij

    Joined:
    Aug 18, 2013
    Posts:
    22
    Is it possible to change a widget's position based on screen size? This would allow multiple widgets to scale based on screen size without clipping eachother.
     
  16. mrzapp

    mrzapp

    Joined:
    May 26, 2013
    Posts:
    137
    That would be the "anchor" property of OGWidget. The "factor" modifier lets you position it by percentage ( 0.0 - 1.0 ), and the "offset" modifier lets you further adjust the position by a specific pixel value.
     
  17. Lokkij

    Lokkij

    Joined:
    Aug 18, 2013
    Posts:
    22
    I know about the anchor property, but I can't seem to find the factor modifier. Is it only in the code, or also visible in the inspector?
     
  18. mrzapp

    mrzapp

    Joined:
    May 26, 2013
    Posts:
    137
    Oh dang, my bad. That's only for the "stretch" parameter. I guess that would be useful to add there. I''l put it in the tracker.
     
  19. Limyc

    Limyc

    Joined:
    Jan 27, 2013
    Posts:
    29
    Links to the repo in the OP are broken. Both the logo and the "github repo" links.
     
  20. mrzapp

    mrzapp

    Joined:
    May 26, 2013
    Posts:
    137
    The logo doesn't seem broken to me, but the repo link needed fixing. Thanks for pointing it out, I have been restructuring a bit lately
     
  21. chrisall76

    chrisall76

    Joined:
    May 19, 2012
    Posts:
    667
    Documentation doesn't say, so how do I go about checking button states and using them (C#)? Such as if the user presses it, hovers it, etc.
     
  22. chrisx84

    chrisx84

    Joined:
    Nov 9, 2011
    Posts:
    85
    me likey. ill give it a try in the morning.
     
  23. MrMassively

    MrMassively

    Joined:
    Sep 4, 2013
    Posts:
    115
    Hi there,

    got a quick question , i cant seem to find the blinking caret in the text field, is this supported out of the box?

    also do not see the option for password ***** substitute in the text field for like a login authentication UI.

    i wonder if this is not there already? or is this something we need to work on ourselves?

    thanks in advanced
     
  24. MrMassively

    MrMassively

    Joined:
    Sep 4, 2013
    Posts:
    115
    also, how do i change the OGLlabel text color dynamically from script?
    cant seem to find the way.

    thanks in advanced
     
  25. mrzapp

    mrzapp

    Joined:
    May 26, 2013
    Posts:
    137
    @MrMassively: The OGTextField component is undergoing some changes. To use the tried-and-true OnGUI hijack method, untick the "enabled" flag in the "Text Editor" dropdown. There is currently no option for obfuscating the glyphs, I'll put that in the issue tracker. As for the text in a label, please see the documentation, linked in the first post.
     
  26. MrMassively

    MrMassively

    Joined:
    Sep 4, 2013
    Posts:
    115
    thanks for the reply,
    but i am not following your answer,

    --where is this dropdown at? i looked in the OGTextField game object of my gui and did not see that.
    what i need is when i put my cursor in a text field to have a blinking caret so i know where my cursor is at, like any other textfield in any other gui systems, are we talking about the same caret deal here?


    -i am not trying to obfuscate the text, i just want to show **** instead of the actual password in a password field of a login gui like other gui system do, i do not think they obfuscate, they just replace the password for ***** when typing passowrd, not sure tho.

    not following either . i just want to be able to change a label text color on the fly from script.
    i can do it from the inspector without any problem, but when i try to do it from script can seem to find a way. ie:
    Code (CSharp):
    1.    
    2. public static OGLabel objLbl;
    3.  
    4.     // Use this for initialization
    5.     void Start () {
    6.      
    7.         objLbl =  GetComponent<OGLabel>();
    8.         objLbl.text = "";
    9.         objLbl.text.color =         // here to add my text label color
    10.  
    11.  
    12.     }
    13.  
    14.  
    15.     }
    something like this to add a text label color on the fly from script, currently there is no way to do the text.color since it does not exist.
    objLbl.text.color = // here to add my text label color




    also, noticed some sort of a bug, with sprites alpha transparency, here is how to replicate:
    you create a background sprite, then in top of that sprite you create another sprite and when you try to alpha fade the sprite in top of background sprite, it fades to black instead of transparency.

    is this a known bug? or maybe i am missing a step or not doing it correctly?



    thanks again for your time.
     
    Last edited: Jul 19, 2014
  27. mrzapp

    mrzapp

    Joined:
    May 26, 2013
    Posts:
    137
    0. Make sure you have the latest version of OpenGUI to follow what I am talking about

    1. We agree on what a caret is, yes :) The OGTextField class has the variable "editor" of the class OGTextEditor, which is work in progress. It should show up as a dropdown in the inspector. Untick the "enabled" boolean of the OGTextEditor to get the default OnGUI behaviour in your textfields. If OnGUI has a blinking caret, then it should appear.

    2. I meant there is no built-in functionality for replacing the displayed text with ***, although it's very easy to add. It will be in the next update.

    3. Just use the "tint" variable of the OGWidget class, which OGLabel is a subclass of. Like "objLbl.tint = Color.red".
     
  28. MrMassively

    MrMassively

    Joined:
    Sep 4, 2013
    Posts:
    115
    Thank you for your quick reply,

    i edited my post and added another issue on the very last maybe you missed it, ill post here again incase you missed it:
     
  29. mrzapp

    mrzapp

    Joined:
    May 26, 2013
    Posts:
    137
    Update: I actually ended up implementing your request in a new release right away, because it was so simple.
     
  30. mrzapp

    mrzapp

    Joined:
    May 26, 2013
    Posts:
    137
    About your other problem, it could have something to do with the way you are clearing the draw buffer on your camera. try changing the culling
     
  31. MrMassively

    MrMassively

    Joined:
    Sep 4, 2013
    Posts:
    115
    thanks for the new update, is it going to be live today?


    as per the camera culling , i disable the culling in the root camera and still the same issue,

    now, the weird thing is that the sprite alpha fades correctly with the scene background, meaning no other gui sprite or gui object behind it, but once you add a gui object, sprite, text etc.. behind the sprite, or text or gui object to alpha fade, it fades to black instead of transparency.
     
  32. mrzapp

    mrzapp

    Joined:
    May 26, 2013
    Posts:
    137
    It's there, just follow the link. I can't seem to reproduce your alpha problem. Is this in a fresh scene? Do you have other cameras in there, and if so, does it have the correct depth parameter set? It should be set lower than the OGRoot camera.
     
  33. MrMassively

    MrMassively

    Joined:
    Sep 4, 2013
    Posts:
    115
    ok, i think i found the issue, this is on fresh scene, no cameras but the one from gui root and depth parameters seems to be correct in relation to the OGRoot,

    the issue is when using a OGTexture as a background, any other gui elelments in top of the OGTexture will not be able to alpha fade while having an OGTexture as background.

    i removed the OGTexture and use a SlicedSprite instead as background and all other gui elements in top of it will render correctly the alpha transparency.



    ok, i am using the latest release of Opengui , well at least what shows on the download link is:

    OpenGUI v0.9-beta-24

    Jeppe Zapp mrzapp released this on Apr 14 · 46 commits to master since this release


    regarding the caret/cursor, i now used the "Editor" enabled feature but still having issues, for instance:
    the caret wont blink, also set the caret/cursor size to 5 width and height 47 o fit the text field rec but then when i type text in the text field the caret/cursor becomes very small size and still no blinking.

    any advice where to look to fix this size changing and no blinking?
     
  34. mrzapp

    mrzapp

    Joined:
    May 26, 2013
    Posts:
    137
    The text editor needs to _not_ be enabled. It's only for testing so far.

    You are right about the OGTexture as background, however, because of the draw order. All widgets bitmaps are drawn first, as they are part of the same atlas, then text, and then textures. I can't think of a way to solve that issue right this moment, but I might be able to come up with something.

    Thanks for your feedback, this hasn't been brought up before. I'll be sure to look at it.
     
  35. MrMassively

    MrMassively

    Joined:
    Sep 4, 2013
    Posts:
    115
    well, i disabled it as your note but now there no caret/cursor at all showing. i am a little bit confused, so you saying the caret/cursor is not working or will not work so far?


    sure, no problem i am glad i found out about that, is no big deal, since OGTexture is not really needed since we can use slicedsprite or sprite instead and avoid this bug, but glad it helped.

    I should be thanking you for providing this nice asset to the community. :)

    ohh, also found other bug i think, in the text fields even if you check the single line box option, and even if you reduce the max characters in the text field, it wont do such a thing because you can still do infinite characters and still do multilines aswell in the textfield, so seems that even checking the single line box and reducing max characters does not seem to work.
     
  36. Recons

    Recons

    Joined:
    Feb 13, 2013
    Posts:
    1
    Great work, thank you very much.
     
  37. mrzapp

    mrzapp

    Joined:
    May 26, 2013
    Posts:
    137
    @MrMassively: Darnit, I seem to have introduced those bugs lately, as I've been struggling with the custom text editor. I have a 18 hour flight coming up in my near future, maybe I can tackle it there :)

    @Recons: Thanks! Let us know if you have any problems.

    @Everyone: I have been thinking lately that the rendering issues we're having could be solved by stepping away from the GL API and instead letting Unity's MeshRenderer/MeshFilter components deal with it. That way we could also have 3D interfaces with quite a few more options in terms of presentation, similar to NGUI, but it would probably also introduce some of the same issues that NGUI has. This would be a pretty significant change in the basic structure of OpenGUI, so it would be a long-term goal. What do you guys think, should we put this on the roadmap, or is the simplicity of OpenGUI what makes it good?
     
  38. Damson

    Damson

    Joined:
    Sep 28, 2013
    Posts:
    1
    HI,

    I am trying to make a 2d texture and all I get is a gray pictrue with OGtexture. How can I load an image using OpenGUI?
     
  39. vertgo

    vertgo

    Joined:
    Aug 12, 2014
    Posts:
    1
    Heya,
    Thanks so much for this, @mrzapp. I am trying to get started on this, as I'm kind of an unity noob.

    I cloned the github repo, and opened the Example scene. Nothing shows up, despite many gameobjects/ui objects on the hierarchy. The only example that has anything is the multipage. Is the example out of date?
     
  40. SteelX

    SteelX

    Joined:
    Apr 14, 2009
    Posts:
    13
    Hi. i have to congratulate you, this plugin looks awesome and i have a question for you as well.
    I'm using the drop container in order to have slots in like tower defense game. Can i drop out items from container? is there any example to achieve that?
     
  41. Affy

    Affy

    Joined:
    Aug 19, 2014
    Posts:
    13
    I downloaded the latest package from the git repo, created a "ROOT" from the OpenGUI menu, added a button. And pressed play.

    But both cameras are drawing my terrain. Why is this? How to I set up so that the camera on the OGRoot object only draws the UI?

    SOLVED
    I read the source code for OGRoot and I realized it was setting the culling for the camera based on the layer of the OGRoot gameobject.

    Thanks, awesome plugin!
     
    Last edited: Aug 30, 2014
  42. mrzapp

    mrzapp

    Joined:
    May 26, 2013
    Posts:
    137
    Hi guys, sorry it took me so long to respond. I am moving to the other side of the planet, and it's taking up a bit of my time :)

    There is a demonstration in the example scene. Check the link in the original post. It should work pretty intuitively.

    Oh damn, what a dumb oversight. I forgot to set up the other example scenes after I implemented multiple pages. Uploaded a new one now.

    There is an example in the project for that as well, check the link in the first post, in the scene "Scenes>DropContainer"

    Yeah, that should be more explicit, not that obvious currently.

    Thanks for your comments guys :)
     
  43. Affy

    Affy

    Joined:
    Aug 19, 2014
    Posts:
    13
    I'm working on a RTS game and as such the player can click in the game world (select units, order them to move etc).

    Question, how do I prevent the player from being able to click both UI elements and the game world simultaneously?
    I should probably be using some sort of event system but I'm new to Unity so I don't know.
     
  44. mrzapp

    mrzapp

    Joined:
    May 26, 2013
    Posts:
    137
    You just check for the OGRoot.GetInstance().mouseOver flag. If it's true, disable whatever actions you might have otherwise scripted.
     
  45. Affy

    Affy

    Joined:
    Aug 19, 2014
    Posts:
    13
    Yeah that's essentially what I ended up doing, as well as some other stuff, I had to add a method on OGRoot that would return the list of widgets currently being hovered.

    Because I want certain widgets to be clickthrough-able. Essentially, I just check whether the widget has "disabled" or not.
     
  46. mrzapp

    mrzapp

    Joined:
    May 26, 2013
    Posts:
    137
    Good point, that should be part of the codebase. I'll add it. Thanks for your feedback :)

    EDIT: done
    Now you just check for the mouseOver flag, the disabled widgets are excluded
     
    Last edited: Sep 7, 2014
  47. Affy

    Affy

    Joined:
    Aug 19, 2014
    Posts:
    13
    Sweet ;D
     
  48. Affy

    Affy

    Joined:
    Aug 19, 2014
    Posts:
    13
    Has anyone experienced the issue of popup widgets not rendering in correct order?

    like this:


    On the right, you see I opened the third popup widget, but it's being drawn before the fourth popup :\
     
  49. mrzapp

    mrzapp

    Joined:
    May 26, 2013
    Posts:
    137
    The popups are rendering on the same z-index. Just put the other widgets at a higher z-position, i.e. further from the camera, like so:

    popup1.position.z = 0;
    popup2.position.z = 1;
    popup3.position.z = 2;
    popup4.position.z = 3;
     
  50. Affy

    Affy

    Joined:
    Aug 19, 2014
    Posts:
    13
    That only partially fixes the issue. Here's how it looks now: The currently selected option's label on the other popups are still being drawn: