Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Unity UI is "open source"

Discussion in 'UGUI & TextMesh Pro' started by liortal, Feb 1, 2017.

  1. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,559
    CAUTION: rant post ahead...

    So, Unity UI was open sourced a while ago (Here's the announcement from 26/11/2014 - https://blogs.unity3d.com/2014/11/26/4-6-is-released-with-source-for-ui-system/)

    Awesome, you might think!! i got all teh c0dez now, i can play with the UI system and do whatever i want with it.

    ... but then you realize this is far from the truth:
    1. Only the C# framework is open sourced. The rest is not available for us to peek at.
    2. The code repository is updated so seldom, it would actually be faster to fly down to Unity HQ in Copenhagen to grab the latest code before it gets pushed to bitbucket.
    3. The code is available for major releases only. but what about minor releases? or patch releases ? no luck.
    4. Pull requests? there are 25 active ones. I personally submitted a few in the past. Took so long to receive a comment, and i'm not entirely sure they actually got merged in.
    5. Modifying UI code - let's say you want to make a change to the UI code. They made it so hard to override the UI DLLs with your own modified ones... you have to actually override the DLLs under the Unity installation .... Also, if i did overwrite the DLLs under the Unity installation, it would still be impossible to build under Unity cloud build (which we are using to build our game).
    6. Debugging ? forget about it. it is technically possible, but it's such a flaky process that i would really suggest most devs to not attempt it (for the sake of not f**ing up their own project).
    Open source? meh.. not really.

    My point is - what's the point of open sourcing a project, if you're not going all the way ??

    I'd really appreciate if someone from Unity could comment on this. I know you guys are all extremely busy, and i certainly don't mean to come across as too aggressive (actually i tried to make it funny, not sure it worked...) but still, i think this deserves some attention.
     
  2. eses

    eses

    Joined:
    Feb 26, 2013
    Posts:
    2,637
    @liortal - Not definitely working for unity, but for what it's worth here's my opinion, as I'm pretty noob to coding in general, I've checked unity UI source code only superficially, and to me it seems like most of the stuff is happening behind the scenes, and at least to me it seems it's pretty hard to change anything, it mostly feels just like having some item, let's say an ATM-machine in front of you, and then you can only inspect exterior and think how you could change / do something to it :)
     
  3. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,559
    Not entirely true, there are some parts you can actually change to make a difference, but as to points 4, 5 and 6 above, they don't seem to make your life easier when you want to do just that.
     
  4. eses

    eses

    Joined:
    Feb 26, 2013
    Posts:
    2,637
    @liortal - yep, as I said, "feels like" and remember, I'm nowhere near a pro coder - just my opinion :). I've done some minor hacks with UI code, that's all.
     
  5. alexeibabin

    alexeibabin

    Joined:
    Feb 8, 2016
    Posts:
    4
    It could be great if we could modify it locally, at the very least.
     
    liortal likes this.
  6. Saxi

    Saxi

    Joined:
    Jun 28, 2013
    Posts:
    381
    Unity doesn't give a damn about Open Source, they just threw that out for PR and had no plans to maintain it. They can't even maintain their non-open source code properly.
     
    liortal likes this.
  7. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,685
    I share your angst @liortal but this is more likely do to the way Unity advertise or talk about their Open source efforts. I do agree it's not "Open source" in the truest sense, simply because Unity actually don't accept PR's (only copy good ideas and use them internally). Members have talked about this on the UI forums, that the actual source for the UI system is embedded in their internal source control. What is on BitBucket is only a "Copy", so PR's cannot be traditionally merged, only "copied" back in.

    In fact, the BitBucket host is only really a way to publish the public parts of the UI framework that aren't implemented in C++ (you can see the same in their other projects), they aren't really meant for contribution.

    So the code is meant to give you an insight into how "they" build it, so you can build your own components more effectively or replace theirs (The replace part is key as I agree, the DLL system used by Unity does not like being "replaced")

    It's a one-way street which Unity has shot themselves in the foot calling it "open source", it's not "open source" but rather just a published API with source included.

    I do agree it really doesn't help with some of the inner workings still being hidden but, Unity hasn't ever shared those things (unless you a top tier subscription), so we do still have more than before.

    As to the update schedule, :D I wholeheartedly agree, in fact they even skip whole releases sometimes as "there haven't been any changes", but they never tell you that upfront so you are just left wondering WHY.

    Just some clarity from my experience with the UI system since it's inception. Best not to dwell on it really. Extend, not replace :D
     
    eses and zyzyx like this.
  8. UnSpotibleShadow

    UnSpotibleShadow

    Joined:
    Jan 14, 2015
    Posts:
    38
    I like the fact its open sourced, yes they may be slow in pulling in the pull requests. But if you need a fix for something in the UI and someone managed to fix it, just copy his code from the pull request and fix it before they pull it in, recompile in Mono and override the regular unity ones. Done, bug fixed before it even was patched by unity themselves
     
  9. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,559
    this overrides the Unity UI DLLs at the Unity installation level (not per project).
    Also - how are you debugging your fixes ? sure, for trivial things you can just 'assume' that whatever fixes you get from bitbucket will work, but for more involved fixes, you can't properly debug it.

    I want to fix it, not extend it. This whole post came as a result of an issue i saw this week. Under heavy load, some specific part in the UI code slowed down to a halt. I could fix it myself (and later found that someone sent a PR for this, ages ago). But the hassle of using this fix prevented me from actually using it (we are using cloud build, so i cannot "modify" the UI assemblies there).

    I really hope someone from Unity is reading this, and take this feedback internally to try and improve things.
     
    Last edited: Feb 3, 2017
    Recart and MrEsquire like this.
  10. UnSpotibleShadow

    UnSpotibleShadow

    Joined:
    Jan 14, 2015
    Posts:
    38
    I'm not debugging the fixes, if they work they'll work. if they don't they don't. and yes I override the installation ones, not extending them project based since "If the fix worked" I had to use the fix over multiple projects
     
  11. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,685
    Then my advice would be to copy the original component, rename it and use your local version instead of the UI version. And deploy that script with your project.
    Unlikely (especially if the PR has been around a while) that the changes have been accepted/adopted if the fix isn't in there by now.

    Out of curiosity, which PR / issue were you referring to?
     
  12. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,549
    What PR are you referring to?
     
  13. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,559
  14. Prodigga

    Prodigga

    Joined:
    Apr 13, 2011
    Posts:
    1,121
    What @SimonDarksideJ said is spot on. Though I wanted to say regarding pull requests - they will never accept them, but they explain why on the repositories home page. Since these repositories are only snapshots of released versions, it would be too hard to merge in changes from pull requests. (Conflicts and such). They go on to say that any pull requests that are accepted will be closed on BitBucket and the changes will be made internally.
     
  15. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,559
    i really don't care if they got my name in that repo next to a commit i made or not. I'm not really looking for my 15 minutes of fame... they should accept whatever fixes people submit that are appropriate and merge that so that future releases include that.
     
  16. Prodigga

    Prodigga

    Joined:
    Apr 13, 2011
    Posts:
    1,121
    Thats what i am saying.

    So they do "accept" pull requests.

    Though the communication could be muuuuuch better.. it would be nice to know the developers thoughts on pull requests. They could just leave a small comment to indicate whether it would be something they will "merge in" in the future or not.

    Regarding the pull request you've linked to - maybe unity is holding off on merging the change until the foreach garbage allocations are fixed?
     
  17. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,559
    The main thing about that PR is the usage of a HashSet instead of a List<T>. The foreach is just an extra thing (not sure why it was needed...)
     
  18. Prodigga

    Prodigga

    Joined:
    Apr 13, 2011
    Posts:
    1,121
    Because you cant iterate over a Hashset using a for loop like you can with a List. Since this optimisation replaced the list with a hashset, the author also needed to replace the for loops with foreach. Now the script generates garbage when before it didn't.
     
    liortal likes this.
  19. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,559
    Gotcha :) the UI system generates so much GC that i don't think this is the reason.. but who knows :)
     
  20. Prodigga

    Prodigga

    Joined:
    Apr 13, 2011
    Posts:
    1,121
    They certainly try hard - they even pool their List's internally so they dont allocate stuff at runtime. But you are right, it does generate a lot of garbage. I change a sliders value and it generates garbage to rebuild the slide image, its pretty silly. Ah well. Also, I don't know if the garbage thing is the reason they havnt replied/accepted that PL - I am just taking a guess. ;) We'd know if they replied, haha.
     
  21. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,685
    They have "accepted" PR's on the past @liortal However, with the restrictions @Prodigga mentions. The changes are reviewed and then consumed internally rather than through BitBucket.
    There is so much overlay between the 2D system and the UI system, I guess it's now becoming difficult to manage.
    I know your pain, which is why I generally create my own components rather than just replace theirs (even for something as simple as the Toggle, which we provide an alternate version in the UI Extensions project)

    I still only view practically everything in the UI source as an "Example" or "Starter for 10" as generally it's easier to write your own using their framework (thankfully the framework has settled now, that whole 4.6 -> 5.2 era pained me greatly)

    Maybe with the release of the new 2D system, we might see more plowed in to the UI framework and it's performance.

    Will look at that PR and see if there is anything we can offer in the UI Extensions project, we already have a shader based mask which is more performance than the Unity one, although it's a little limited for my liking a the mo.
     
  22. bdovaz

    bdovaz

    Joined:
    Dec 10, 2011
    Posts:
    1,016
    +1.

    I would like that Unity builds around a community like Microsoft has built open sourcing code around .NET Core. An example (see commits, issues, pullrequests rate per day):

    https://github.com/dotnet/corefx

    I would like to contribute to Unity on some areas to fix, get better and create new very small features that would improve our daily work. I know that Unity supports more than 20 platforms and it's not easy but community can help with some small areas that are not "important" enough for Unity.

    But as some of you have say, they have "open sourced" some features but with a clone repo that it's not the one Unity is working with. This one is outdated and it's not maintaned, they don't read or comment pull-requests...

    What they have achieved is that community doesn't get involved on improving Unity "open sourced" features.
     
  23. UnityFan18

    UnityFan18

    Joined:
    Jul 4, 2016
    Posts:
    62
    Would love to see Unity open source certain utility assets that they provide to allow the community to also contribute. I love Unity's ease of use. I can see Unity become hopefully a Open Source pioneer in the realm of game engines.