light mode / dark mode icons

I’m creating a kindof physics extension package and I have some gizmos with it. Mine are the 2 on the bottom.

7072606--840976--Screenshot 2021-04-24 141636.png
Looks great, except that this is in light mode Unity, and in modern times we like to use dark mode. So let’s switch:

7072606--840979--Screenshot 2021-04-24 141813.png
But now, my icons don’t look so great anymore.

7072606--840982--Screenshot 2021-04-24 142034.png
I’d like a way to have these script icons be light or dark mode specific without having to write some editor script that checks what mode Unity is on and meticulously swaps icons in the meta file. My assumption is that it would simply be an extra line in the meta file and that you can specify a light as well as a dark mode icon in the inspector.

Edit:
Nevermind, I found you can use “RigidbodyStuff icon” and “d_RigidbodyStuff Icon” in the Gizmos folder. To specify, this is what your folder structure should look like. Let’s say we have a class RigidbodyStuff inside the namespace My.Namespace

  • Gizmos
  • My
  • Namespace
  • RigidbodyStuff Icon ← Don’t forget the " Icon" afterwards.
  • d_RigidbodyStuff Icon

Note that this gives your scripts icons, but doesn’t actually create gizmos in the scene view. For that you should still assign an icon via the inspector.

4 Likes

Don’t delete the post, this is useful info for future googlers.

1 Like

Brilliant! Good work finding this out! @PraetorBlue is right.

I can confirm that this works when the Gizmos folder is in the Assets folder!

However, it doesn’t appear to work when the Gizmos folder is in a package, which is unfortunate.
Does anyone know why this might be the case?

1 Like

Sorry to revive, but did anyone find any solution to this? (specifically for components in Packages)

Hi Ciro (love your work), I have a custom script that copies a ~Gizmos folder in my package to a Gizmos folder in Assets on [InitializeOnLoad]. I will send it to you when I get home later this evening

1 Like

Hi Casey! Thanks a lot!

It’s an interesting solution. But this is for an Asset Store package, and I want to be as less disruptive as possible to the user. So importing files in their project just for an icon seems like a big ask. In the end, I might just keep the icon the same colour for both themes.

But thanks for the proposal!

Oh trust me, I WISH there was a better solution. Eventually I just caved.

If you want you can probably import these files as hidden in the Gizmos? That way they won’t show up in the project window but still be seen… hopefully? Haven’t tested if that actually works, really just thought of this now from the top of my head.

And annoyingly, having icons can really help with communication of your asset, so it may be worth the tradeoff.

Hey I remembered that this is on GitHub so I can send it right now.

https://github.com/CaseyHofland/2Dx/blob/master/Editor/Core/CopyGizmosToAssets.cs

You can see that it copies the Gizmos~ folder into Assets. This seemed the easiest way.

1 Like

Ah you mean using hideFlags? Hmm. That sounds a bit wonky…

Ah, in general I’m sorted because I assign the icon manually from the Inspector of the script. The problem being, I can only assign one, can’t differentiate between dark/bright mode.

1 Like