Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
3
Question by sarahnorthway · Jan 07, 2020 at 11:28 PM · applicationversionplayersettings

Difference between Application.version and PlayerSettings.bundleVersion

I want to auto-increment the version number that appears as "App Version" in Unity Cloud Diagnostics every time I make a new PC build. I assume this is Application.version.

Application.version is read-only and can only be edited via Edit>Project Settings>Player>Version.

Enter PlayerSettings.bundleVersion. This field CAN be edited in code, and when I do (at least in the local editor on PC) it changes both Application.version and Edit>Project Settings>Player>Version. The docs say it is only used for Android and iOS builds (I have neither package and only care about PC).

So: is one just a reference to the other? Will they ever differ? Is it OK to use PlayerSettings.bundleVersion for a PC build? As usual the docs aren't helpful.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by darbotron · Sep 08, 2020 at 08:31 AM

We use PlayerSettings.bundleVersion (accessible only in editor) to set Application.version (also accessible in the player) for all platforms & we don't do mobile games we do PC / consoles...

(@sarahnorthway I assume you've worked this out by now :) )

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image sarahnorthway · Sep 08, 2020 at 04:32 PM 1
Share

I guess we're both doing the right thing. It makes sense for version to be read-only in the player, but the way it's set up (and not documented) is confusing af. For posterity, my class which auto-increments build version after each build:

 using UnityEngine;
 using UnityEditor;
 using UnityEditor.Callbacks;
 
 /// <summary>
 /// Automatically increment InternalSettingsInstance.versionBuild after an EXE is built.
 /// </summary>
 public class BuildPostprocessor {
     [PostProcessBuildAttribute(1)]
     public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject) {
         
         // to update major or $$anonymous$$or version, manually set it in Edit>Project Settings>Player>Other Settings>Version
         
         // this will also set Application.version which is readonly
         string[] versionParts = PlayerSettings.bundleVersion.Split('.');
         if (versionParts.Length != 3 || versionParts[2].ParseInt(-1) == -1) {
             Debug.LogError("BuildPostprocessor failed to update version " + PlayerSettings.bundleVersion);
             return;
         }
         // major-$$anonymous$$or-build
         versionParts[2] = (versionParts[2].ParseInt() + 1).ToString();
         PlayerSettings.bundleVersion = versionParts.Join(".");
     }
 }
avatar image darbotron · Sep 25, 2020 at 03:49 PM 0
Share

Here's another approach to almost the same thing (from https://twitter.com/martinpi/status/1309490503591886850)

If this gist set PlayerSettings.bundleVersion rather than PlayerSettings.iOS.buildNumber it would be the same as @sarahnorthway's but done before the exe is built. https://gist.github.com/martinpi/f4311512c443b8134bda3f268ae7abd3

avatar image AbsurdAndy · 5 days ago 0
Share

Everything in the answers above is still correct in 2021.3.4f1 -- I'll just add that changes to PlayerSettings.bundleVersion do not save if you are in Play mode, but are persistent if made in an editor script (including at build time). Writing to PlayerSettings.bundleVersion immediately changes the output of Application.version.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

120 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Can you access Project Settings -> Player -> Other Settings -> Version via script at runtime? 2 Answers

After upgrading project that was made with unity 5.6.3p4 to unity 2018.X and taking an android gradle build, the application version gets set to 1.0 even when version is 3.1.2 in android player settings 4 Answers

Unity Hub version 3 unusable 0 Answers

iOS application in the settings panel 3 Answers

Minimum API Level is set to 2.3.1 but Google Play says 4.1 and higher versions 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges