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
0
Question by artman_12 · Aug 13, 2014 at 01:19 PM · editoreditor-scriptingicons

Updating Player Settings with code

Hi everyone! I have a trouble with updatings player settings with my editor script. I have 4 versions of my game with different settings (Android free, android paid, iOS free, iOS paid) All versions have different Product names, bundle ids and icons. The problem is that when I update icons with my code and try to build a game, the icons appear to be unassigned, even though all icons are correclty set in editor after script execution.

Here's the code that changes the icons:

 static void SetApplicationIcon(BuildTargetGroup platform, bool isPaid)
     {
         Texture2D[] iconSet;
         int[] num ;
         if (platform == BuildTargetGroup.Android) {
             iconSet = new Texture2D[5];
             num = new int[] {144, 96, 72, 48, 36};
 
         } else if (platform == BuildTargetGroup.iPhone) {
             iconSet = new Texture2D[7];
             num = new int[] {152, 144, 120, 114, 76, 72, 57};
             
         } else {
             Debug.LogError("Switch to ANDROID or IOS platform");
             return;
         }
 
         for (int i = 0; i < num.Length; i++) {
             int n = num[i];
             if (isPaid) {
                 Texture2D icon = new Texture2D(n, n);
                 icon.LoadImage(File.ReadAllBytes(Application.dataPath + "/Icon/Icon_" + n.ToString() + ".png"));
                 iconSet[i] = icon;
             } else {
                 Texture2D icon = new Texture2D(n, n);
                 icon.LoadImage(File.ReadAllBytes(Application.dataPath + "/Icon/Free/Icon_" + n.ToString() + ".png"));
                 iconSet[i] = icon;
             }
         }
         PlayerSettings.SetIconsForTargetGroup(platform, iconSet); 
     }
 

I've found out that when I press "Build" button and then cancel it right away, the icons are already unassigned in Player settings.

If I set icons with mouse by drag'n'dropping, then the icons are set properly.

How to tell Editor to remember the icons? Thanks in advance!

Comment
Add comment · Show 2
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 smoggach · Aug 13, 2014 at 01:44 PM 0
Share

Are you using a pro license?

avatar image artman_12 · Aug 13, 2014 at 02:18 PM 0
Share

Yes, I am.

2 Replies

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

Answer by artman_12 · Aug 13, 2014 at 03:16 PM

I've fixed it by moving icons into the Resources folder and loading them with

 icon = Resources.Load("Icon/Icon_" + n.ToString()) as Texture2D;

instead of

 icon.LoadImage(File.ReadAllBytes(Application.dataPath + "/Icon/Free/Icon_" + n.ToString() + ".png"));


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
0

Answer by digitspro · Sep 09, 2020 at 09:23 PM

I had the same issue. I was loading the Texture2D by reading the file bytes myself into a new Texture2D. I fixed it by simply loading the Texture2D using AssetDatabase.LoadAssetAtPath. I did not want to solve it by using Resources.Load because I am worried that putting the icons there will increase the size of the final build file (I build for Android).

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Gizmos icons 0 Answers

How to set ProjectSettings via script 1 Answer

Undo.RecordObject isn't working. 7 Answers

Can you run custom code when changing scene perspective? 1 Answer

Event for loading component in the editor 2 Answers


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