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

Why the choice of custom XML and CSS instead of just XAML?

Discussion in 'UI Toolkit' started by Ramobo, Oct 13, 2019.

  1. Ramobo

    Ramobo

    Joined:
    Dec 26, 2018
    Posts:
    212
    To me it would make more sense to just have one language that can do both things well instead of using two completely different languages -- custom versions, as if that wasn't enough.
     
  2. uDamian

    uDamian

    Unity Technologies

    Joined:
    Dec 11, 2017
    Posts:
    1,231
    Simplified answers:
    1. We wanted something that works well _within_ Unity with full control over the format and implementation. This includes being able to run on all the 25+ platforms that Unity runs on.
    2. One of the main goals was to _separate_ the hierarchy from the styles (and from the code logic). Combining them into one format would defeat part of our goal.

    Of course, choices like this are rarely simple.

    That said, you _can_ embed USS inside UXML if you want to. Same applies if you want to implement everything in C#.
     
  3. Ramobo

    Ramobo

    Joined:
    Dec 26, 2018
    Posts:
    212
    The way I see it, a subset has less features than the parent language to keep the implementation simple. That's it. That being the case, you're still constrained by the specifications of the parent languages. Also, XAML is effectively XML for application development, so if for some mysterious reason there's no XAML parsers or whatever that can run on those 25+ platforms, you can always write your own. You didn't have any problems doing that with the indentation-based YAML. Let's be honest: generally speaking, if you can write a parser that has to guess statement terminations (indentation), you can write a parser that works with explicit statement termination (<>).
    In XAML you have Style tags, which can be stored in separate files. And even if it didn't, it's effectively XML. You could theoretically just do some linking.
     
  4. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,754
    CSS is convenient and easy to replace. Same applies in web designing. No need for replacing whole file. Just styles. Also easy to test on web.

    Either way, whatever Unity choose their solution, I don't think proposed approach is any deal braking, to satisfy one customer. It would only introduce much cost and amount of work, to redesign and test Interfaces.

    Personally I would prefer HTML5 tech as UI. But that wasn't a thing much, back decade ago. And now they a bit stuck, with what they got. So I don't expect it HTML5 either.
     
  5. runner78

    runner78

    Joined:
    Mar 14, 2015
    Posts:
    789
    XAML is also an custom XML.
    I have experimented with WPF in the past, and the XML-based styles... i don't like it.
    To define styles, css / uss is much easier for humans to write / read.

    I come from web, so it's also easier for me. And it's not only me, there are many other people with more experience in HTML/CSS than in XAML.

    I think, HTML5 it's to heavy for just a Game UI. Sometimes it's easier to write an new system specialized for a specific "Problem" than brute force a existing solution for a different "problem" to your "problem".
     
  6. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,754
    You can make it as light weight, as heavy weight. Depends which approach you take.
    But I can agree, that not all game would benefit from it. However many games uses it.
    Is just what I prefer.
    And don't think editors as Unity would suffer from it either. It just would add so much flexibility, specially when so many tools and utilities now are available for HTML5.
     
  7. runner78

    runner78

    Joined:
    Mar 14, 2015
    Posts:
    789
    Light weight HTML5 not exits, that would no longer be HTML5 ;) (by specification)

    XML has more freedom. Normally you can't nested (valid) HTML5 Files, and if you strip part of the specification, or only save part of a html-code in a file, you are completely out of any specification.

    However, I would have preferred if unity would put some things closer to HTML5. As example the #selector for "id" and not "name".
     
    Antypodish likes this.
  8. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,754
    Perhaps I phrased wrongly. What I mean is, you can use it to make simple form, or fancy shiny game :)

    Either way, Unity apparently did major revamp recently of their UI, so any fancy changes are out of scope. Even saying that, they still struggle with UI design.

    Using ready to use plugins and utilities of HTML5, or relevant, they would probably be able do much more and streamline things. At least my thought.
     
  9. runner78

    runner78

    Joined:
    Mar 14, 2015
    Posts:
    789
    Much more important than HTML5 is CSS/USS. That's the part where you are create fancy stuff. And i hope unity extends USS.
     
    Antypodish likes this.