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

OpenGUI: Open source GUI framework for Unity

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

  1. mrzapp

    mrzapp

    Joined:
    May 26, 2013
    Posts:
    137
    Thanks, I appreciate it. Be sure to let us know if you find any errors or missing features. I'd also recommend joining on GitHub, if you should want to comment issues or commit fixes :)
     
  2. Lokkij

    Lokkij

    Joined:
    Aug 18, 2013
    Posts:
    22
    Okay, makes sense. Thanks for the amazing support so far, I just hope you're not being overloaded with help/feature requests :p

    EDIT: when saving, I keep getting these messages about "cleaing up leaked objects since nothing is referencing them. Texture2D has been leaked X times". X ranges from ~80 to ~10000. It doesn't seem to cause any problems, but I thought I'd let you know.
     
    Last edited: Feb 15, 2014
  3. mrzapp

    mrzapp

    Joined:
    May 26, 2013
    Posts:
    137
    no problem, that's what the tracker is for ;)
     
  4. Lokkij

    Lokkij

    Joined:
    Aug 18, 2013
    Posts:
    22
    It seems it's also not possible to rotate the root camera, probably for the reasons you mentioned earlier. Is there any way to work around this? I used to rotate the camera to get an upside-down view of the game, but now that's no longer possible. I know I could probably flip everything in the game upside down, but that just seems a bit.. rigorous.
     
  5. frankyboy450

    frankyboy450

    Joined:
    Jan 21, 2011
    Posts:
    106
    @Lokkij
    You can use the InvertCamera script from the Unity wiki
    LINK HERE
    Just attach the script to the camera and it'll work ;)
     
  6. Lokkij

    Lokkij

    Joined:
    Aug 18, 2013
    Posts:
    22
    Hmm, that mostly works, except it screws up the OGSlicedSprites (which are no longer visible). I'm not sure why exactly, since the rest works fine. Thanks though, that's a pretty useful script :)
     
  7. frankyboy450

    frankyboy450

    Joined:
    Jan 21, 2011
    Posts:
    106
    Sure, I use it myself in the game I'm working on.
    Thanks MrZapp for all the help. Now comes the fun part of re-making all the GUI :)
     
  8. mrzapp

    mrzapp

    Joined:
    May 26, 2013
    Posts:
    137
    I had to redo my own GUI when I rewrote this, and I put a few batch scripts in there like "reset all styles" on OGPage and "auto detect" on the OGSkin to make things less tedious. If you could think of some useful features like that, we should put it in the tracker as well.

    @Lokkij, MuNgLo, I'll make you contributors on GitHub, so you can add issues to the tracker. If more of you guys get GitHub accounts, I could start a markdown-based forum there, so everything's a little more integrated.
     
    Last edited: Feb 16, 2014
  9. MuNgLo

    MuNgLo

    Joined:
    Jan 27, 2014
    Posts:
    31
    So far I haven't written a single line on unityscript so not sure if I can contribute more then nagging. :D

    I was a bit curious so ended up making these lines ( c# )

    using UnityEngine;
    using System.Collections;

    public class OGfloat : MonoBehaviour {
    public GameObject target; // the object that represent the position in worldspace you want
    public GameObject camTrace; // the camera you want to send the trace from to get screen position

    // Update is called once per frame
    void Update () {
    Vector3 pos = camTrace.GetComponent<Camera>().WorldToScreenPoint (target.transform.position);
    pos.z = 0F;
    pos.y = Screen.height - pos.y;
    transform.localPosition = pos;
    }
    }

    It works fine for having GUI bits track objects in 3d space but it isn't compatible with OGWidget handling of positions for it self and childs which overrides it.
    Ran it in the latest 0.9b4
     
    Last edited: Feb 16, 2014
  10. MuNgLo

    MuNgLo

    Joined:
    Jan 27, 2014
    Posts:
    31
    Lets say you want to update the text field of an OGLabel from an c# script. How would you do that?

    I've tried placing the script in every step of the compileorder and OGLabel isn't available as type for GetComponent anywhere. I assume it is possible if you do it the right way but how?

    --edit-- nvm :/
    It works. It just doesn't work well with autocompletion in Mono. I just assumed it wouldn't work.
     
    Last edited: Feb 18, 2014
  11. mrzapp

    mrzapp

    Joined:
    May 26, 2013
    Posts:
    137
    Yeah, MonoDevelop doesn't give too much of a crap about UnityScript. It's a bummer, I know. I should add a warning to the first post though
     
  12. frankyboy450

    frankyboy450

    Joined:
    Jan 21, 2011
    Posts:
    106
    Progress on converting UnityGUI To OpenGUI is going forward. it's easy when you start understanding how the system works.
    I've managed to convert parts of the HUD and pause menu +options menu and I tried to build it to android to see how it worked.

    Performance is good. there's no "lag spikes" it runs smoothly and nice but there's a problem(2 actually)

    Some times the OGButtons and OGTextures loose their color and become black for no reason. it just happens from time to time.
    You can't see the text or anything, it's just black textures stretched over the area where the button/Texture is supposed to be at

    The other problem is that there appears to be some kind of input "lag" If I press the pause button(located in the upper left corner), nothing happens.


    if I press it again, it pauses the game and shows the pause menu:


    when I press the options button. the "back to game" buttons looks like it's being pressed and nothing happens. Then when I press the options button again it appears.

    So it's like the touch is delayed one touch count or something like that.

    Hope that made sense. please tell me if it didn't.
     
  13. mrzapp

    mrzapp

    Joined:
    May 26, 2013
    Posts:
    137
    Curently, the widget behaviour is set up to respond to mouse only, anything that works by touch is entirely translated by Unity. I'll add an issue about input types to the tracker.

    The black boxes you describe sound like rendering queue issues. That kind of stuff might happen if there are other runtime errors. Is your log error free?
     
  14. frankyboy450

    frankyboy450

    Joined:
    Jan 21, 2011
    Posts:
    106
    Hmm.. I Wrote a reply yesterday but it appears to have disappeared...
    Thanks for adding it to the tracker.

    There aren't any runtime errors. just some complaints about a font not set to dynamic, but that shouldn't do anything so far I know.
     
  15. frankyboy450

    frankyboy450

    Joined:
    Jan 21, 2011
    Posts:
    106
    I managed to make a cool loading screen:

    Supposedly it's supposed to load stuff... but I chose to make the "loading: sprites" and "Loading: Audio" not do anything. It's just to give the game a chance to load some other stuff..

    It only shows first time starting the game and it sets the value of all OG widgets and then I use DontDestroyOnLoad to keep it in the game. hopefully it works... It might stop working when the player restarts the game.
    http://gyazo.com/f3686602126a55b868b9db222601c878.png
     

    Attached Files:

  16. mrzapp

    mrzapp

    Joined:
    May 26, 2013
    Posts:
    137
    Neat, the OGProgressBar seems like good fit for that. Not sure how well the DontDestroyOnLoad() plays, but as long as the OGPage object is a child of OGRoot, everything should be dandy :) BTW, sorry for not doing any updates the past weeks, I've had a lot to do. I'll be able to get back to it in a few days.
     
    Last edited: Feb 27, 2014
  17. frankyboy450

    frankyboy450

    Joined:
    Jan 21, 2011
    Posts:
    106
    The OGProgressBar is really good for this, even though I should make it load more smooth, now I add 0.1 to the value every 0.5 second and setup the GUI anchor etc... each time.
    I had to use DontDestroyOnLoad(transform.root.gameObject); because my GUIController script is attached to an empty gameobject within the Root and it works fine, just have to be careful not to load the same scene again otherwise I'll have several root objects.
    I'm just glad that someone is making this so even if I have to wait It doesn't matter ;) Thanks for working on this!
     
  18. mrzapp

    mrzapp

    Joined:
    May 26, 2013
    Posts:
    137
    Yeah, you might want to use Mathf.SmoothStep to make.. the steps.. smoother :p You'd have to update every CPU cycle though, instead of every 0.5 seconds
     
  19. frankyboy450

    frankyboy450

    Joined:
    Jan 21, 2011
    Posts:
    106
    Cool. I'm using a coroutine now(because I was lazy)... I'd have to rewrite some code to use the Update instead.
     
  20. Vunpac

    Vunpac

    Joined:
    Mar 13, 2012
    Posts:
    34
  21. frankyboy450

    frankyboy450

    Joined:
    Jan 21, 2011
    Posts:
    106
    @Vunpac
    That's weird, it also crashed for me. Probably some bug in the code which caused it. What do you need the demo for?
     
  22. mrzapp

    mrzapp

    Joined:
    May 26, 2013
    Posts:
    137
    Just tested on Windows and Mac OS, doesn't crash for me. Does the plugin fail to render at all, or is there some sort of error code? It could have been a temporary issue. I built it again and re-uploaded, just in case.
     
    Last edited: Mar 2, 2014
  23. shery91

    shery91

    Joined:
    Mar 3, 2014
    Posts:
    3
    Im totally new to Unity and forced to use it for the graduation project :D your library is really AMAZING and has all what i was really needed (as I saw ur demo)
    I have 2 problems..
    First::
    I have this error: Assets/Editor/OpenGUI/OGSkinInspector.js(341,83): BCE0023: No appropriate version of 'UnityEditor.EditorGUILayout.GetControlRect' for the argument list '(boolean, float, UnityEngine.GUILayoutOption)' was found.... Is there anything wrong with my unity version? I have 4.2.2f and how can I solve this?
    and also this error typeTree.m_Children.front ().m_Type != SerializeTraits<SInt32>::GetTypeString (NULL)

    I dont really know what I did wrong to have these errors and it seems that it is working almost fine with everyone... PLEASE HELP ME :)
     
    Last edited: Mar 3, 2014
  24. mrzapp

    mrzapp

    Joined:
    May 26, 2013
    Posts:
    137
    Glad you like it :)

    Welcome to Unity! It's proprietary, focuses on some strange scripting languages for game development, and it's definitely got its technical issues, but it's undoubtedly one of the best frameworks out there.

    It seems like an important API call is inaccessible there, though it's in the official documentation. Try to upgrade to the latest Unity first, see if that helps. I've never before seen these errors while working with Unity, although I'm guessing the SerializeTraits is a bug, which you might be able to solve by restarting it.

    Good luck with your graduation project, I've always found those interesting :)
     
    Last edited: Mar 4, 2014
  25. shery91

    shery91

    Joined:
    Mar 3, 2014
    Posts:
    3
    Thanks alot for ur reply..

    Actually the problem is solved by removing the OGSkinInspector file and commenting its references in the OGWidgetInspector... can u help me with editing the skin with the code? i didnt find documentation for the skin..

    Thanks alot again :D
     
  26. mrzapp

    mrzapp

    Joined:
    May 26, 2013
    Posts:
    137
    Heh, I wouldn't call that solved. I think you should try to download the example project and see if that works for you. If not, then the problem is with Unity.
     
  27. Lokkij

    Lokkij

    Joined:
    Aug 18, 2013
    Posts:
    22
    I think there's a few issues with the OGLabels/fonts. There's a couple strange things, like characters being too close to eachother (see attachment), and fonts being a lot "flatter" in some positions on the screen (I think this has to do with position relative to other UI elements. The labels are generally readable, but aren't particularly pleasing to look at, possibly because of these scaling issues. Would there be any way to fix these issues?
     

    Attached Files:

  28. MuNgLo

    MuNgLo

    Joined:
    Jan 27, 2014
    Posts:
    31
    I just had a fun experience. I tossed in OpenGUI in my latest little testingproject and whatever I did it refused to render any GUI. I already done this a couple of times so I was a bit baffled. Started double and tripplechecking everything.
    Finally it turns out that when I made the OGPage, the transform was way of in coordinates. Think it had like -200+ in Z. I'm unsure of all the impacts of it but maybe have some kind of warning if the tranform position on the OGPage object isn't 0,0,0 or whatever is reasonable.
     
  29. mrzapp

    mrzapp

    Joined:
    May 26, 2013
    Posts:
    137
    @ Lokkij: That is called text kerning, and Unity has inherent issues with it. It's there on the issue tracker, so it's being worked on, but I must admit that I am still not sure what'll be the solution.

    @MuNgLo: I should just force it in the update loop as I have with OGRoot. Good observation.
     
  30. shery91

    shery91

    Joined:
    Mar 3, 2014
    Posts:
    3
  31. frankyboy450

    frankyboy450

    Joined:
    Jan 21, 2011
    Posts:
    106
    Setting up references to these widgets can be fun :X


    Now everything pretty much works. Level select, Settings page, Advanced settings page, Stats page, Pause and win page etc...
    but my only problems are that OGTextures are black when testing it on an android device and touch is delayed.
    Could you lead me in the right direction to implementing touch to this system? I'm thinking that making a Rect and checking for touches inside that area would be easiest, or do you have any other ideas?

    Thanks again for making this awesome GUI Framework.
     
  32. mrzapp

    mrzapp

    Joined:
    May 26, 2013
    Posts:
    137
    Dang, that is a lot of buttons :D I wonder if that could be automated, like scanning for similar GameObject names. I am not seeing the black textures myself on Android, so it's hard to troubleshoot. I managed to get the touches working a little bit better, there are just some funky workarounds I have to improve upon. If you're curious, you can checkout the GitHub repo and use the code in the Example project, although it's not considered stable.
     
  33. frankyboy450

    frankyboy450

    Joined:
    Jan 21, 2011
    Posts:
    106
    hehe, I'm sure there could be an easier way, but it works. so...
    It's weird that it only happens to me, I'll try and place the code for it before anything else or check if I messed up somewhere with the size or something.
    Glad to hear you got it to work better, I'll take a look at it ;)
     
  34. MuNgLo

    MuNgLo

    Joined:
    Jan 27, 2014
    Posts:
    31
    Is there any way to easily flip the text in a OGLabel and is there anyway to lock a scrollviews default position to bottom and manually trigger a position reset?

    I am in need of this since I want to have a textfeed like consolefeed or chatfeed where you can scroll up into history but that will snap back to show the latest textadded when updated. I've looked around a bit and also tried giving negative values in scale and lineheight. But so far I had no success.
    Did I miss something?
     
  35. mrzapp

    mrzapp

    Joined:
    May 26, 2013
    Posts:
    137
    No easy way to "flip" the text that I know of. Every glyph is quite painstakingly drawn within its own Rect, so I'd have to do some serious modification to allow that. I might be able to modify the matrix to handle rotation, but not mirroring

    You can at any time force the OGScrollView position with the "position" Vector2 variable. 0,0 would naturally be a reset. I hope that answers your questions, dunno if I misunderstood something there.
     
  36. MuNgLo

    MuNgLo

    Joined:
    Jan 27, 2014
    Posts:
    31
    Thanks. I figured it wouldn't be easy like flipping a flag but I was hoping. :)
    Gonna have to make a workaround using a list of OGLabels and iterate over I guess but that has it's own problems but it's doable. As long as I can trigger a position change on the scrollview I should be fine.
    Thanks again.
     
  37. RapRogue

    RapRogue

    Joined:
    Mar 17, 2014
    Posts:
    3
    First of all. Mrzapp thanks for the wonderful job. Congratulations!!! ^^

    Well, I've just passed eyes through the thread and I would like to know if there is a way to not stretch the skin (not the object), instead I would like to make it repeat forever, the center and borders.

    Here, two images to make it clear. First one is what happens and the second one is how I would like to do. (I made them on paint, it's just an idea)

    $forum2.png

    I know there is the problem when the sizes aren't multiples, but if this was not done it will be great to implement. If you could give me some tip where to go to try make this...

    (sorry for my bad english)

    Thanks again, amazing tool!!!
     
    Last edited: Mar 17, 2014
  38. mrzapp

    mrzapp

    Joined:
    May 26, 2013
    Posts:
    137
    Thanks very much, I'm glad you like it!

    Generally, when using atlases, you can't "repeat" or "tile" anything. That's just how it works.
    The only way to achieve this is to render the texture in several instances.
    This is possible by using an OGSprite and then mess around with the "repeat" properties.

    I'm sure you'll figure something out that way :)
    Let me know if I can help you any further.

    And don't worry about your English, it's good enough.
    It's not my native language either :)
     
  39. XAfgun

    XAfgun

    Joined:
    Oct 2, 2012
    Posts:
    33
    Is there any option for All screen width and height or we design different guis for other screen resolutions
     
  40. mrzapp

    mrzapp

    Joined:
    May 26, 2013
    Posts:
    137
    You can define your widgets with "stretch" and "anchor" parameters, which makes it suitable for any aspect ratio.
    However, as OpenGUI is drawn in a pixel matrix, there is no dynamic scaling for different resolutions, so if you're designing a UI that has to work on an extremely wide range of screens, say 480x320 to 1920x1080, OpenGUI does not support this yet, as I myself am just using this for PC development.
    I'll look into the options available, but I don't imagine implementing dynamic scaling will be trivial.
     
  41. RapRogue

    RapRogue

    Joined:
    Mar 17, 2014
    Posts:
    3
    Hi Mrzapp,
    Me again,

    I made it. I just want to share, if someone has the same problem.

    Skin Repeater
    Just add the script (C# :|) to the object you want make it repeat (just work for OGSlicedSprites)

    Here, some results.

    $before.png
    $after.png

    I've created 9 new styles, added them to the skin, created many objects and applied the proper new style. When the scale haven't fitted, I've created as many objects I could and I've done a little stretch to adjust.

    Unfortunately, I haven't made adjust on the run. I will make it soon as possible.

    :p
     
    Last edited: Mar 27, 2014
  42. mrzapp

    mrzapp

    Joined:
    May 26, 2013
    Posts:
    137
    Wow, this is really cool! I didn't even know this was what you had in mind. I have thought about it previously, but never got around to making it. Not even EZGUI or NGUI have this feature as far as I know.

    I should appropriate it into the OGSlicedSprite class, but for now I'll add your script to the wiki (here). Can I have your GitHub handle and make you a collaborator? Then you can update it yourself, should you need to do so :)

    EDIT: I've published a new package with your idea implemented into OGSlicedSprite as a simple tile x/y parameter, no extra styles needed now. Please have a look at it (perhaps in the updated example project) and let me know if anything is missing.

    Thanks a lot for your contribution, this was definitely missing from OpenGUI :)

    A note for you about developing widgets, though: Check out the OGDrawHelper class and this very rudimentary tutorial. It should save you some trouble by letting you interface directly with the low-level drawing methods.
     
    Last edited: Mar 26, 2014
  43. mrzapp

    mrzapp

    Joined:
    May 26, 2013
    Posts:
    137
    By the way, is anyone interested in drawing basic lines in your GUI? Right now OpenGUI does support it, you can check out this demonstration video from our project (it comes up around 0:50 in the conversation editor).

    The implementation is very rough though, but I could pay some more attention to it, if you guys are interested.
     
    Last edited: Mar 26, 2014
  44. im

    im

    Joined:
    Jan 17, 2013
    Posts:
    1,408
    nice thanks! :)
     
  45. RapRogue

    RapRogue

    Joined:
    Mar 17, 2014
    Posts:
    3
    Wonderful, you just put it in the project. I guess it's fine and better than my way.

    Thanks!
     
  46. mrzapp

    mrzapp

    Joined:
    May 26, 2013
    Posts:
    137
    I just committed changes to the latest release (v0.9-beta-6) trying to solve the serialisation issue. So far saving the OGSkin changes works for me, but please let me know if anyone is still having the same issues with it.
     
  47. faltugames

    faltugames

    Joined:
    Mar 20, 2014
    Posts:
    6
    Hello,
    Thanks for awesome framework. Tested on Android and it work well. Still exploring the way it can be use. Found one bug the button state doesn't get reset on device because Input.mousePosition give last touched position even when touch count is zero. I have put fix by changing OGWidget::CheckMouseOver ( rect : Rect ) to

    Code (csharp):
    1.  
    2.     public function CheckMouseOver ( rect : Rect ) : boolean {
    3.         var x : float = Input.mousePosition.x;
    4.         var y : float = Input.mousePosition.y;
    5.        
    6.         if(SystemInfo.deviceType == DeviceType.Handheld  Input.touchCount == 0)
    7.         {
    8.             return false;
    9.         }
    10.         return x > rect.x  y > rect.y  y < rect.y + rect.height  x < rect.x + rect.width;
    11.     }
    12.    
    13.  
    Hope it help.

    Thanks
     
  48. mrzapp

    mrzapp

    Joined:
    May 26, 2013
    Posts:
    137
    That is very helpful, thanks a bunch! I'll merge your code with the master branch, but would you like to join us on GitHub? Then you won't have to go through the forum when submitting fixes :) You can just PM me your handle, and I can add you to the repository as a collaborator.

    EDIT: Now implemented into the latest release (v0.9-beta-7 at the time writing)
     
    Last edited: Mar 30, 2014
  49. Lokkij

    Lokkij

    Joined:
    Aug 18, 2013
    Posts:
    22
    Thanks for the improvements to kerning! :)
    While there are still a few weird things with the vertical "stretching" of the text, it has improved massively, making the text more pleasing to read.
     
  50. mrzapp

    mrzapp

    Joined:
    May 26, 2013
    Posts:
    137
    No problem :) By vertical stretching do you mean when inside a scrollview?