Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
4
Question by FHRaph · Feb 06, 2013 at 06:00 PM · androideditorbuildplayersettings

Set Bundle Version Code through editor script

Hi there, I was wondering if it was possible to set the BundleVersionCode through a custom editor script. I am making a simple build panel for an android project with the BundleVersion set to match my company's version naming convention. I would like to set the BundleVersionCode with this same convention (minus the "."s) but cant seem to find an access point.

Is there really no way to access/ mutate that data at build time? And if not, why? It doesn't seem like bad form to do this but maybe I'm wrong.

Thanks in advance,

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

3 Replies

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

Answer by FHRaph · Feb 06, 2013 at 09:33 PM

And I answered my own question 3 minutes after I asked it. While the BundleIdentifier and BundleVersion values are shared between platforms (marked clearly in the inspector with a *) the BundleVersionCode is not. That means it can be found in PlayerSettings.Android.bundleVersionCode.

Next time I'll dig a little deeper before asking here.

Comment
Add comment · 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
2

Answer by GerryM · Feb 06, 2013 at 08:48 PM

You can easily change the bundle version (it's a string) to anything you like with an editor script:

 [MenuItem("Test/Set Bundle Version")]    
 static void SetBundle()
 {
     PlayerSettings.bundleVersion = "1-1";    
 }    


Also, check the scripting reference for all settings.

Comment
Add comment · Show 2 · 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 FHRaph · Feb 06, 2013 at 09:15 PM 0
Share

I was actually referring to the BundleVersionCode which is an android specific value. I just didn't think to look at PlayerSettings.Android.BundleVersionCode. Thanks though.

avatar image GerryM · Feb 07, 2013 at 09:37 PM 2
Share

True, my bad, BundleVersionCode is kind of hidden:

 PlayerSettings.Android.bundleVersionCode  = 1;

avatar image
0

Answer by obi_juan_ · Mar 10, 2015 at 02:39 PM

Basically, my problem was version conflict when you compile for IOS. The new iTunes TestFlight does not allow same version number as the old TestFlight. I solved writing an editor script that rewrite every editor update the bundle version with a fixed string like i.e. "1.202." followed by month+day+hour+minute. So I can now forget about to change bundle version when I'm gonna build any bundle.

 using UnityEngine; 
 using System.Collections;
 using UnityEditor;
 using System;

 [InitializeOnLoad]
 public class bundleVersion  {


 static bundleVersion ()
 {

     EditorApplication.update += Update;


 }
 
 static void Update ()
 {
     string month;

     if (System.DateTime.Now.Month<=9) {
         month="0"+System.DateTime.Now.Month;
     }
     else{
         month=System.DateTime.Now.Month.ToString();
     }

     string day;
     
     if (System.DateTime.Now.Day<=9) {
         day="0"+System.DateTime.Now.Day;
     }
     else{
         day=System.DateTime.Now.Day.ToString();
     }

     string hour;
     if (System.DateTime.Now.Hour<=9) {
         hour="0"+System.DateTime.Now.Hour;
     }
     else{
         hour=System.DateTime.Now.Hour.ToString();
     }
     string minute;
     if (System.DateTime.Now.Minute<=9) {
         minute="0"+System.DateTime.Now.Minute;
     }
     else{
         minute=System.DateTime.Now.Minute.ToString();
     }

     PlayerSettings.bundleVersion = "1.202."+month+day+hour+minute;


 }
 

 } 



put this in a file called "bundleVersion.cs" inside /Assets/Editor folder.

Comment
Add comment · 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

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

11 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

Related Questions

Automate exclusion of specific Android plugin from build? 0 Answers

Changing Build Settings by code 1 Answer

BCE0044 erro only shows when trying to build .apk 0 Answers

How to fix bugs that only appear in the build? 0 Answers

Script works in editor, but does not work in build (Android) 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