Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 PsychoDuckArcade · May 31, 2019 at 06:45 PM · texture2diconget

How to get game icon via code?

Something like, Application.productIcon.

I want to do something like

 Texture2D myTexture2D = Application.productIcon;

In player settings, the Default Icon field IS a Texture2D, I just don't know how to get it through code.

Thanks.

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by NoCandyIncluded · Jun 01, 2019 at 04:19 AM

Try importing the texture you're using as the icon into the Assets of the editor. Then in code, make a field, public Texture2D tex; Go back into the editor, and in your script component you should be able to select any Texture2D in your assets.

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class teas : MonoBehaviour
 {
 
     public Texture2D tex;
 
     // Start is called before the first frame update
     void Start()
     {
         
     }
 
     // Update is called once per frame
     void Update()
     {
         
     }
 }
 

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 PsychoDuckArcade · Jun 01, 2019 at 07:06 AM 0
Share

Not sure if I'm understanding you correctly. I know I can get any Texture2D in my assets, what I want is to get specifically the Texture2D used as the game's icon programmatically, not manually. So whatever the game icon is, or whatever I change it to, the Texture2D in code will automatically update accordingly. This is for a tool kit I'm making where I want an image to be, by default, the icon your using for your game.

For example:

 DefaultImage = Application.Icon;

avatar image
0

Answer by Bunny83 · Jun 01, 2019 at 09:36 AM

You should have mentioned that you're looking for an editor script solution because at runtime / in a build you can't access the applications icon as Texture2d since depending on the platform the icon might have a different format and usually is not part of the game assets.


However in the editor you should be able to use PlayerSettings.GetPlatformIcons to get the associated PlatformIcons that has been setup for a particular target platform. Each PlatformIcon has a GetTexture (and GetTextures) method.


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 PsychoDuckArcade · Jun 02, 2019 at 02:02 PM 0
Share

No, I don't want an editor script. The only reason I think I can get the icon at runtime, is that in player settings there IS a Texture2D variable for the icon which is used to set it. I'm thinking THAT is possible to grab at runtime. I know some other settings are.

avatar image Bunny83 PsychoDuckArcade · Jun 02, 2019 at 02:12 PM 0
Share

Why should Unity include a texture that is ultimately used only outside the game (as native resource, as ico resource, ...) in your game assets? Of course it's a Texture2D inside the editor since any image resource is just a Texture2D. However that means it's automatically part of the asset database. Furthermore the assetdatabase only includes assets in a build that are actually referenced by a scene (directly or indirectly) or placed in a resources folder. The application icons are just referenced by the editor settings and used by the build process.

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

113 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

Related Questions

Populate inventory with item icons 1 Answer

Resize texture from prefab? 1 Answer

How to load a large texture at runtime without blocking the pipeline? 1 Answer

Can't seem to use GetPixels on a square texture in Unity 3.0 Iphone 0 Answers

Texture2D scale - iTween 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