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
2
Question by arkadsgames · Jan 10, 2018 at 04:52 PM · scriptable objecticons

Custom Icon on ScriptableObject

Hey guys, i doing some itens for my game make the development easer, i wish add custom icons to my itens, which are ScriptableObjects, how i can do this? i know the trick of put the icon on Gizmo folder with the same name as the script, but the icons should be different for different itens which have the same script

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
3

Answer by spilat12 · Feb 25, 2019 at 03:22 AM

Hi there @arkadsgames. You can do it without the Gizmos folder. Just select the ScriptableObject script (not the ScriptableObject asset!) and select its icon in the Inspector. That will change that script's icon as well as all icons of respective ScriptableObject assets!

Additionally, you can visit this thread for more info, it has lots of gold in it: https://forum.unity.com/threads/custom-scriptableobject-icons-thumbnail.256246/

Comment
Add comment · Show 5 · 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 dragon_script · Apr 26, 2020 at 10:05 PM 0
Share

Hi, i'm working on a cards game where there are different "roles". Every scriptable object needs to have a custom image. How do i do it?

avatar image spilat12 dragon_script · Apr 27, 2020 at 01:39 AM 0
Share

Hi there, my answer quite literally answers your question. Just click the icon in the Inspector and you will be able to set it just like that.

avatar image Reid_Taylor · May 14, 2020 at 12:25 AM 0
Share

Im not understanding this?

avatar image Skyunity · Oct 08, 2020 at 08:44 PM 0
Share

This works. However, existing instances of the ScriptableObject were not updated (i.e. it only applied to the ScriptableObject assets I created after changing the icon). Didn't try restarting Unity though, so that may fix that issue.

avatar image eskivor Skyunity · Apr 26, 2021 at 04:22 PM 0
Share

Yes, restarting Unity make it update the icon of the scriptable object instances (not just the script).

avatar image
-1

Answer by dragon_script · Apr 26, 2020 at 10:05 PM

Hi, i'm working on a cards game where there are different "roles". Every scriptable object needs to have a custom image. How do i do it?

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 dragon_script · Apr 26, 2021 at 06:20 PM 0
Share

Add an 'image' property. From your game, load it into the UI.

avatar image TustinJimberlake · Nov 03, 2021 at 01:31 AM 0
Share

Looks like there's a new API for this in 2021.2!

https://docs.unity.cn/2021.2/Documentation/ScriptReference/EditorGUIUtility.SetIconForObject.html

avatar image
0

Answer by TustinJimberlake · Nov 03, 2021 at 01:32 AM

There is a new API for this in 2021.2 that might do what you are looking for. It even tells you how to make it persistent across script reloads ;)

https://docs.unity.cn/2021.2/Documentation/ScriptReference/EditorGUIUtility.SetIconForObject.html

Edit: Okay so it turns out this is really really jank. As far as I can tell, Unity doesn't want you to instance these icons. On compile/load, all of the assets will be set to the same icon, even if you properly set each one individually. You have to inspect them by clicking on them individually to get them to update to their true icons. If anyone has a solution to this please let me know :/

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 BgBg · May 31 at 06:36 PM

Hi.
It's possible!
Short history:
I downloaded and explore this project: https://blog.unity.com/technology/isometric-2d-environments-with-tilemap
I noticed that in this project, icons from scriptable objects are displayed in the inspector: alt text
After, i found some editor script, and edited him for my project.
I don't understand how it works, but it works. =) alt text

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEditor;
 using System;
 using System.Reflection;
 using Object = UnityEngine.Object;
 
 [CustomEditor(typeof(item_so),true)]
 [CanEditMultipleObjects]
 public class ItemSOEditor : Editor
 {
     private item_so item { get { return (target as item_so); } }
 
     public override Texture2D RenderStaticPreview(string assetPath,Object[] subAssets,int width,int height)
     {
         if(item.standart_item_struct.item_icon!=null)
         {
             Type t = GetType("UnityEditor.SpriteUtility");
             if(t!=null)
             {
                 MethodInfo method = t.GetMethod("RenderStaticPreview",new Type[] { typeof(Sprite),typeof(Color),typeof(int),typeof(int) });
                 if(method!=null)
                 {
                     object ret = method.Invoke("RenderStaticPreview",new object[] { item.standart_item_struct.item_icon,Color.white,width,height });
                     if(ret is Texture2D)
                         return ret as Texture2D;
                 }
             }
         }
         return base.RenderStaticPreview(assetPath,subAssets,width,height);
     }
 
     private static Type GetType(string TypeName)
     {
         var type = Type.GetType(TypeName);
         if(type!=null)
             return type;
 
         if(TypeName.Contains("."))
         {
             var assemblyName = TypeName.Substring(0,TypeName.IndexOf('.'));
             var assembly = Assembly.Load(assemblyName);
             if(assembly==null)
                 return null;
             type=assembly.GetType(TypeName);
             if(type!=null)
                 return type;
         }
 
         var currentAssembly = Assembly.GetExecutingAssembly();
         var referencedAssemblies = currentAssembly.GetReferencedAssemblies();
         foreach(var assemblyName in referencedAssemblies)
         {
             var assembly = Assembly.Load(assemblyName);
             if(assembly!=null)
             {
                 type=assembly.GetType(TypeName);
                 if(type!=null)
                     return type;
             }
         }
         return null;
     }
 }



example-0.png (15.5 kB)
primer.png (7.0 kB)
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

80 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

Related Questions

importing from blender 1 Answer

Issues with mipmap icons 1 Answer

Hierarchy icons became low-res 0 Answers

Should I be using Scriptable Objects that only contain a method implementation? 1 Answer

Custom Inspector for Scriptable Object with multi dimensional array 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