Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 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
1
Question by SirGive · Apr 04, 2012 at 04:10 PM · editor-scripting

Programmatically set default icon for mobile

Is there a way to do this? I see PlayerSettings.SetIconsForTargetGroup() but it would much easier to reset the default icon.

There doesn't seem to be a way to set the splash screen either.

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

4 Replies

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

Answer by kromenak · Apr 04, 2012 at 06:30 PM

It would be great if Unity provided variables for these elements, but as it stands I don't think you can change the icon in that way.

What we do is, say, have a folder named "Device/Icons" and "Device/Splash" where we have the icons and splash screen images. You can then drag these elements in the inspector to assign them as appropriate. You can then use the AssetDatabase.Copy command to overwrite these assets with other assets based on the particular build you are trying to create. For example, if you are using splash.png for your splash screen, you might do

 AssetDatabase.CopyAsset("Assets/Christmas/Splash/splash.png", "Assets/Device/Splash/splash.png");

if you were creating a Christmas build. This doesn't change the asset assigned in the inspector, but it effectively modifies the existing asset to change it.

EDIT: As mentioned in comments, this copy method could avoid some asset database confusion:

 FileUtil.CopyFileOrDirectory("Assets/Christmas/Splash/splash.png", "Assets/Device/Splash/splash.png");
 AssetDatabase.Refresh();
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 SirGive · Apr 05, 2012 at 12:40 PM 0
Share

That sucks. The main thing I was trying to achieve was building various versions of the app with one click. (We have a flash card app with like 5 different sets). That might work, though. Just using a generic splash.png/icon.png and replacing them and then building.

avatar image SirGive · Apr 05, 2012 at 05:30 PM 0
Share

Unfortunately copying over an existing file deselects it from the inspector. Any other work arounds?

avatar image SirGive · Apr 05, 2012 at 05:52 PM 1
Share

FileUtil.CopyFileOrDirectory() and then AssetDatabase.Refresh() is the correct way to do this. The asset database seems confused otherwise. You should modify your answer :)

avatar image
8

Answer by The-Bacon-Baron · Dec 16, 2012 at 11:55 PM

You can do this! Use this:

 PlayerSettings.SetIconsForTargetGroup(BuildTargetGroup.Unknown, theTexture2DArray);

Where theTexture2DArray is an array of the Texture2D asset you want to be the icon.

This will set the default icon from the player settings, and if there aren't overrides for the platform icons, those will change also.

Hope this helps!

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 SirGive · Dec 18, 2012 at 01:46 AM 0
Share

Glad to know this works now. Back when I asked this question it did not.

avatar image kromenak · Dec 19, 2012 at 11:59 PM 0
Share

Cool, good to see the functionality there now.

avatar image TheGering · Jul 03, 2015 at 10:50 AM 0
Share

This will set the default Icon as wanted.

avatar image
2

Answer by cowlinator · Feb 05, 2014 at 12:32 AM

I don't believe there is a way to change the default icon through script, but this is what i do.

 Texture2D icon = Resources.Load(iconName) as Texture2D;
 Texture2D[] icons = new Texture2D[]{icon, icon, icon, icon};
 
 if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android)
     PlayerSettings.SetIconsForTargetGroup(BuildTargetGroup.Android, icons);
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
1

Answer by sama-van · Dec 12, 2019 at 09:27 AM

However the FileUtil.CopyFileOrDirectory() log an error if the file already exists. Also better the assets path to be absolute :

Here is what I do :

 string _defaultPath = "/_MyAppFolder/Res/UI/_Common/Texture/Default_AppIcon.png";
 string iconPath= "/_MyOtherAppFolder/Res/UI/_Common/Texture/OtherAppIcon.png";

 FileUtil.DeleteFileOrDirectory(Application.dataPath + _defaultPath);
 FileUtil.CopyFileOrDirectory(Application.dataPath + iconPath, Application.dataPath + _defaultPatht);
 AssetDatabase.Refresh();



Comment
Add comment · Show 1 · 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 cmersereau · Apr 11 at 08:55 PM 0
Share

FileUtil.Replace(source, destination) is a simpler way of doing that

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

8 People are following this question.

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

Related Questions

Material.mainTexture not working outside of runtime? 1 Answer

How do I get an array of names of all the sprites in a project, with an editor script? 2 Answers

Unity API for checking if an object was modified 3 Answers

How to minimize the main editor Window by script 1 Answer

Why would editor script be slow on first compilation? 0 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