2D Toolkit Forum

2D Toolkit => Support => Topic started by: quangtu89 on February 02, 2015, 05:54:21 pm

Title: How to change a sprite to grayscale in a atlas runtime ?
Post by: quangtu89 on February 02, 2015, 05:54:21 pm
I want change only a sprite in atlas to grayscale but dont affect to other sprites in this atlas . How to do this ?
Title: Re: How to change a sprite to grayscale in a atlas runtime ?
Post by: unikronsoftware on February 02, 2015, 06:01:11 pm
Use a custom material on that sprite, assign a shader to it that draws in grayscale
Title: Re: How to change a sprite to grayscale in a atlas runtime ?
Post by: quangtu89 on February 03, 2015, 01:39:11 am
can texture be load multi times if i use multiple material on a atlas.
Title: Re: How to change a sprite to grayscale in a atlas runtime ?
Post by: unikronsoftware on February 03, 2015, 09:28:25 am
No its only loaded once
Title: Re: How to change a sprite to grayscale in a atlas runtime ?
Post by: fsadeq on February 03, 2015, 10:13:00 pm
To add to this, any compelling reason my atlas textures are loaded multiple times (if using multiple materials) according to this tool: http://forum.unity3d.com/threads/resource-checker-free-list-texture-material-mesh-memory-use-in-scene.132008/

A lot of people I know use it and it's pretty awesome in showing you what textures/materials you have loaded in your scene, but unless I'm missing something obvious, why are my atlas textures loaded into memory multiple times? Thanks.
Title: Re: How to change a sprite to grayscale in a atlas runtime ?
Post by: unikronsoftware on February 03, 2015, 10:55:54 pm
Are you using png textures?
Title: Re: How to change a sprite to grayscale in a atlas runtime ?
Post by: fsadeq on February 03, 2015, 11:02:07 pm
Nope, Unity.
Title: Re: How to change a sprite to grayscale in a atlas runtime ?
Post by: unikronsoftware on February 03, 2015, 11:49:34 pm
It can't be right, Unity doesn't load an asset twice. You can't even make it do it, unless its deliberately instantiated multiple times but you'd have a "Clone" appended to the name.

I'd check in the unity profiler to be sure.
Title: Re: How to change a sprite to grayscale in a atlas runtime ?
Post by: fsadeq on February 04, 2015, 02:54:18 am
I'm getting similar results with the Unity profiler. I've attached two pictures, the first one is of the Resource Checker Util and the second is the Unity profiler. It seems I should only have 6 atlas textures loaded in, but Resource Checker is reporting 13, and Unity Profiler is saying 10. Thoughts? Many thanks.

Title: Re: How to change a sprite to grayscale in a atlas runtime ?
Post by: unikronsoftware on February 04, 2015, 10:32:29 am
What asset to each of those lead to when you click on it in the unity profiler?
Title: Re: How to change a sprite to grayscale in a atlas runtime ?
Post by: fsadeq on February 04, 2015, 12:23:42 pm
Very strange, must be a bad bug going on. I have some old atlases being loaded in that are supposedly referenced by some sprites - if I select the references in the profiler, they take me to the sprites that are clearly not using the atlas. Not sure what's going on here.
Title: Re: How to change a sprite to grayscale in a atlas runtime ?
Post by: fsadeq on February 04, 2015, 02:19:40 pm
My project started a long time ago and I've only slowly been working on it, but it's since become quite a mess and I'm always having odd issues - I think my best bet is to create a new project from scratch and then import only relevant assets. Do you have any recommendations for this process? I'd rather not have to re-create collections and animations, there should be no issues if I just export and import a package with all the sprite stuff, right?
Title: Re: How to change a sprite to grayscale in a atlas runtime ?
Post by: unikronsoftware on February 04, 2015, 10:31:17 pm
If you have visible meta files, you can simply copy the sprite collection + data + animation prefabs + data directly to the other project. But yes exporting and importing will work too.