Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Discussion Unity requires a data structure for the Unity version

Discussion in '2022.2 Beta' started by Rowlan, Oct 24, 2022.

  1. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,293
    The latest Unity LTS crashes on Undo for months now and Unity didn't deliver a fix so far. That's unacceptable as this is a highly critical bug.

    In order to disable Undo code for a range of Minor versions the checking for the Unity version with Application.unityVersion isn't helping because that's just some random string that doesn't have a defined format one can rely on.

    In order to be able to check for the proper major/minor/whatever version in the future I suggest do provide a proper data structure rather than a meaningless string.
     
  2. Armynator

    Armynator

    Joined:
    Feb 15, 2013
    Posts:
    67
    Maybe I'm missing something here, but calling it "meaningless" or "just some random string" is simply wrong. The format is pretty clear and logical.

    Let's take 2022.1.0f1 for example:
    2022 - the year, higher = newer
    1 - sub-release of that year, 2017-2019 the LTS version was 4, since 2020 LTS version is 3, higher = newer
    0 - patch release of that version, higher = newer
    f - full release, can also be a for alpha or b for beta, f > b, b > a (in 2017 we also had p > f iirc)
    1 - minor version of that release, used for very small fixes on f versions (quite rare) or breaking changes for new alpha/beta versions, higher = newer

    That last part might be a bit confusing at first, but as far as I can remember it always followed the same pattern. f is higher than b, b is higher than a. While in f versions the last number rarely changes and is only used for minor fixes, it changes almost weekly in alpha/beta versions and often has breaking changes.

    xxxx.x.0f1 is higher than xxxx.x.0b13
    xxxx.x.0b13 is higher than xxxx.x.0a20

    Following this, xxxx.x.1a3 is in theory higher than xxxx.x.0f1, but I don't think there ever was any alpha/beta version higher than xxxx.x.0, so this doesn't really matter.

    Before Unity 2017 (Unity 4/5) the versioning was different and also had a p letter, standing for patch releases. I don't remember the exact rules there, but I think the p letter meant it was higher than f. (The p letter was also used in 2017 versions)

    So yeah, as long as Application.unityVersion reliably returns the current version, you can easily create your own data structure using it, except if it's broken or if I'm not understanding your request correctly.
     
    cxode and Spy-Master like this.
  3. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,293
    That's an obvious yet undefined pattern nobody can rely on and can change at any time. It's not an API. And why should everyone have to write their own parser for that? Unity may as well add a parser as editor utility. On that one can rely on.
     
    Last edited: Oct 25, 2022
  4. Spy-Master

    Spy-Master

    Joined:
    Aug 4, 2022
    Posts:
    625
    @Armynator side note, there's also the version numbers used in China, which as far as I know amounts to "c1" tacked on to the end.

    @Rowlan
    Recognizing that doing the following for a wide spread of editor patch versions is excessive, you can still use C# #if directives, for example UNITY_2019_4_14. Chain together editor versions that are safe or broken that way. That's for the granularity of patch. UNITY_X_Y_OR_NEWER is a thing as well. This is generally the best way to design against different editor versions. Failing that, there's always the option of a regex in your code and never looking back because it's highly unlikely anything will change, and getting the version pieces specifically seems like such a niche use case that it shouldn't warrant needing to put something in the class library for it.
     
  5. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,293
    I thought of that, but all I see is this:

    upload_2022-10-25_14-26-44.png

    No minor version.
     
  6. Spy-Master

    Spy-Master

    Joined:
    Aug 4, 2022
    Posts:
    625
    My logs (2022.2.0b12) indicate otherwise.
    upload_2022-10-25_5-45-33.png
     
  7. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,293
    There's no way you can limit 2021.3.9 to 2021.3.11 with these, ie those are the versions where eg Undo needs to be disabled in code because it hard-crashes Unity when you press ctrl+z. It's supposed to be fixed in 2021.3.12
     
  8. Spy-Master

    Spy-Master

    Joined:
    Aug 4, 2022
    Posts:
    625
    Code (CSharp):
    1. #if !(UNITY_2021_3_9 || UNITY_2021_3_10 || UNITY_2021_3_11)
    2. // Why not?
    3. #endif
     
  9. TJHeuvel-net

    TJHeuvel-net

    Joined:
    Jul 31, 2012
    Posts:
    838
    Sidenote, do you know if there is a bugreport about this undo crash? Id give all my votes in an issuetracker.
     
  10. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,293
    TJHeuvel-net likes this.
  11. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,293
    Found a way that is acceptable for me. The versioning in the assembly definitions follows a strict defined pattern.

    Assembly definition file:

    upload_2022-10-29_9-3-6.png

    Code:
    Code (CSharp):
    1. #if UNDO_DISABLED
    2. ...
    3. #endif
     
    Yuchen_Chang and Spy-Master like this.