Adding an Automatic Build Version in Unity

Поділитися
Вставка
  • Опубліковано 26 жов 2024

КОМЕНТАРІ • 52

  • @heybishop
    @heybishop 3 роки тому +4

    This is super! I had something similar for my project - but mine doesn't update the version and date automatically. I'll be updating mine today!

  • @DevDunkStudio
    @DevDunkStudio 3 роки тому

    Used this to change materials per platform, thanks!

  • @HAIRGROW
    @HAIRGROW 3 роки тому

    Thanks for providing this information. I had been wondering how to implement something like this. Now I know.

  • @mihainegrisan
    @mihainegrisan Рік тому

    I get an error when building the project as a Google Play App Bundle. "Could not find a part of the path 'GameName-Version [1.1] - 7\18\2023-v4-IL2CPP.symbols.zip'." Any idea on how to solve this?

  • @koremeltdown7258
    @koremeltdown7258 2 роки тому

    Thanks for the info bud. much appreciated

  • @pablo17349
    @pablo17349 Рік тому

    I get the following error at build time:
    The type or namespace name 'Build' does not exist in the namespace 'UnityEditor' (are you missing an assembly reference?)
    Any help?

    • @VRwithAndrew
      @VRwithAndrew  Рік тому +1

      Did you put the script in a folder named "Editor"? This should prevent it from being included in the build.

    • @pablo17349
      @pablo17349 Рік тому

      @@VRwithAndrew right, that was it, thanks!

  • @johnanthony44
    @johnanthony44 3 роки тому +2

    Can you automate it so the build file name appends the version number?

    • @VRwithAndrew
      @VRwithAndrew  3 роки тому

      I'm not sure, it's possible but I don't personally have a way to do it.

  • @danielhasi6974
    @danielhasi6974 4 місяці тому

    greate video. by the way. which font are you using?

    • @VRwithAndrew
      @VRwithAndrew  4 місяці тому

      I believe it's "The Next" or "Next" font

  • @nasti7018
    @nasti7018 2 роки тому

    Can't find out what's wrong, it always shows just 0.1((

  • @RiverExplorerGames
    @RiverExplorerGames 5 місяців тому

    Thanks, but it only works up to build 0.99. Example if the build is 0.111, the next build is 0.121 and not 0.112. ! Minor tweak to fix.

  • @stormhardt
    @stormhardt Рік тому

    Heads up you can also call the variables directly in strings which i personally find a little easier to read `PlayerSettings.bundleVersion = $"[{newVersion}] {date}";`

  • @barthaszabolcs-gamedevjour1098
    @barthaszabolcs-gamedevjour1098 2 роки тому

    Just what I needed! :d
    Thanks!

  • @micaiahstevens8840
    @micaiahstevens8840 3 роки тому +1

    Thanks been wondering how to do this FOREVER.
    I think some improvements, could be using a 0.01 or something to include a version for each play in the editor. I don't tend to build often, as I am just developing, BUT every so often do versioning in the saving and backing up of files.

    • @VRwithAndrew
      @VRwithAndrew  3 роки тому

      Yeah, I kept the versioning real simple to understand. You could most likely do that by tracking the Editor events for entering/exiting play.

  • @sadbuttrue666
    @sadbuttrue666 Рік тому

    Nice one. Thank you very much.

    • @VRwithAndrew
      @VRwithAndrew  Рік тому

      You're very welcome!

    • @sadbuttrue666
      @sadbuttrue666 Рік тому

      @@VRwithAndrew but sadly I found out it's not working with CI builds with GameCI. Its always starting with the first increment, because it's Player depending. I need something that's able to display the version in the final deployed build.

  • @recore67onload
    @recore67onload Рік тому

    I've been using this for awhile and it worked fine, but ever since i switched build platforms to Linux(presumably the cause) the incrementing doesn't seem to work anymore. I'm not sure what the issue is, it would just give me the same application.version of the previous build instead of continuously incrementing it. any suggestions would be appreciated.

    • @VRwithAndrew
      @VRwithAndrew  Рік тому

      Hmmm, within the UpdateVersion function, try and put a print statement within the TryParse to see if it's actually able to add to split the version string properly and find a usable number.

    • @recore67onload
      @recore67onload Рік тому

      @@VRwithAndrew Ok it seems like the issue was indeed from the splitting part and had nothing to do with switching build platforms, I just had the "[ ]" missing when formatting the string at the end. Thanks!

  • @pietro6093
    @pietro6093 2 роки тому

    that's great but that wouldn't work if you are using Unity could build unless you commit the PlayerSettings change to version control. Do you have an example for that?

    • @VRwithAndrew
      @VRwithAndrew  2 роки тому

      This is more for solo devs, there are a lot of questions/potential resources online for using Github tags or commits.

  • @oscarmelchorgalan3092
    @oscarmelchorgalan3092 2 роки тому

    Fantastic, thanks

  • @171694
    @171694 3 роки тому

    Awesome! Thank you!

  • @ProjectNullTheGame
    @ProjectNullTheGame Рік тому

    Is there any way to check we play the released version of the game? So click in the exe.

    • @VRwithAndrew
      @VRwithAndrew  Рік тому

      Yeah, you should be able to show the build number via a UI text.

  • @philhinkle7908
    @philhinkle7908 Рік тому

    Thank you for the tutorial. It was easy to follow for my beginner's brain. I'm curious about modifying the version format from "0.0" to "000.000.000" I tried a couple of ways, just poking around, but they didn't work. If anyone has a sec and knows a solution, I'd appreciate it.

  • @theGabe87
    @theGabe87 3 роки тому +1

    AFAIK this will not work when you push your binaries to apple appstore or google play store, they require the format to be for example 0.0.1

    • @micaiahstevens8840
      @micaiahstevens8840 3 роки тому

      Thankfully you can change the format, just a nice showcase of how to do this.
      [Personally know very little about apple myself.]
      But the variables and version numbers can be tweaked to fit your needs.

    • @VRwithAndrew
      @VRwithAndrew  3 роки тому +1

      Yes, I believe you're correct!

    • @EddieCaplan
      @EddieCaplan 2 роки тому

      bummer. But now I'm using version numbers in the format YYYY.MMdd.build, e.g. 2022.0618.314159

  • @hollowworldgames8786
    @hollowworldgames8786 3 роки тому

    Why didn't you make this video several years ago. I have been manually setting versions for way too long!

    • @micaiahstevens8840
      @micaiahstevens8840 3 роки тому

      Totally agree, same myself hehe! [Sorta, just never had an automated way of doing it.]

    • @VRwithAndrew
      @VRwithAndrew  3 роки тому

      I wish I had figured it out years ago. :)

    • @hollowworldgames8786
      @hollowworldgames8786 3 роки тому

      @@VRwithAndrew yes now I am figuring out how to make it work off a scriptable and add increment major and minor editor functions. Just haven't gotten it to work without opening the scriptable in the editor after starting the editor.

  • @nsb_tv5820
    @nsb_tv5820 3 роки тому

    third ;D

  • @alexxkrehmen772
    @alexxkrehmen772 2 роки тому +1

    Hi,
    To get it working on French system, where the decimal separator is a comma instead of a point, you should use this in the BuildVersionProcessor script :
    CultureInfo cInfo = new CultureInfo("en-EN");
    if (float.TryParse(version, NumberStyles.Any, cInfo, out float versionNumber))
    {
    float newVersion = versionNumber + 0.01f;
    string date = DateTime.Now.ToString("d");
    PlayerSettings.bundleVersion = string.Format("Version [{0}] - {1}" , newVersion.ToString("f2", cInfo) , date);
    }

    • @banjolasse6169
      @banjolasse6169 2 роки тому

      Thanks! Was wondering why it wouldn't parse

  • @manofapocalypse
    @manofapocalypse Рік тому

    it dont work for me Unity 2021.3.12f1, any debug.log dont trigger
    using System;
    using UnityEngine;
    using UnityEditor;
    using UnityEditor.Build;
    using UnityEditor.Build.Reporting;
    using System.Globalization;
    public class BuildVersionProcessor : IPreprocessBuildWithReport
    {
    public int callbackOrder => 0;
    private const string initialVersion = "0.0";
    public void OnPreprocessBuild(BuildReport report)
    {
    string currentVersion = FindCurrentVersion();
    UpdateVersion(currentVersion);
    Debug.Log("Here1");
    }
    private string FindCurrentVersion()
    {
    string[] currentVersion = PlayerSettings.bundleVersion.Split('[', ']');
    Debug.Log("Here2");
    return currentVersion.Length == 1 ? initialVersion : currentVersion[1];
    }
    private void UpdateVersion(string version)
    {
    CultureInfo cInfo = new CultureInfo("en-EN");
    if (float.TryParse(version, NumberStyles.Any, cInfo, out float versionNumber))
    {
    float newVersion = versionNumber + 0.01f;
    string date = DateTime.Now.ToString("d");
    PlayerSettings.bundleVersion = string.Format("Version [{0}] - {1}", newVersion.ToString("f2", cInfo), date);
    Debug.Log("Here3");
    }
    }
    }

  • @EddieCaplan
    @EddieCaplan 2 роки тому +2

    This was a big help. Kudos to the presentation as well. I appreciate how clearly you gave the context up front as to what problem this solves. Bummer that Apple and Google require a simple version format. But I was able to do what I needed by using a version number in the format: YYYY.MMdd.build, e.g. 2022.0618.314159

    • @VRwithAndrew
      @VRwithAndrew  2 роки тому +1

      Happy to be of assistance, Eddie