Hello Guest

Author Topic: How to change a sprite to grayscale in a atlas runtime ?  (Read 8804 times)

quangtu89

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 18
    • View Profile
How to change a sprite to grayscale in a atlas runtime ?
« 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 ?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: How to change a sprite to grayscale in a atlas runtime ?
« Reply #1 on: February 02, 2015, 06:01:11 pm »
Use a custom material on that sprite, assign a shader to it that draws in grayscale

quangtu89

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: How to change a sprite to grayscale in a atlas runtime ?
« Reply #2 on: February 03, 2015, 01:39:11 am »
can texture be load multi times if i use multiple material on a atlas.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: How to change a sprite to grayscale in a atlas runtime ?
« Reply #3 on: February 03, 2015, 09:28:25 am »
No its only loaded once

fsadeq

  • 2D Toolkit
  • Sr. Member
  • *
  • Posts: 353
    • View Profile
Re: How to change a sprite to grayscale in a atlas runtime ?
« Reply #4 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.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: How to change a sprite to grayscale in a atlas runtime ?
« Reply #5 on: February 03, 2015, 10:55:54 pm »
Are you using png textures?

fsadeq

  • 2D Toolkit
  • Sr. Member
  • *
  • Posts: 353
    • View Profile
Re: How to change a sprite to grayscale in a atlas runtime ?
« Reply #6 on: February 03, 2015, 11:02:07 pm »
Nope, Unity.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: How to change a sprite to grayscale in a atlas runtime ?
« Reply #7 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.

fsadeq

  • 2D Toolkit
  • Sr. Member
  • *
  • Posts: 353
    • View Profile
Re: How to change a sprite to grayscale in a atlas runtime ?
« Reply #8 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.

« Last Edit: February 04, 2015, 02:58:02 am by fsadeq »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: How to change a sprite to grayscale in a atlas runtime ?
« Reply #9 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?

fsadeq

  • 2D Toolkit
  • Sr. Member
  • *
  • Posts: 353
    • View Profile
Re: How to change a sprite to grayscale in a atlas runtime ?
« Reply #10 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.

fsadeq

  • 2D Toolkit
  • Sr. Member
  • *
  • Posts: 353
    • View Profile
Re: How to change a sprite to grayscale in a atlas runtime ?
« Reply #11 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?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: How to change a sprite to grayscale in a atlas runtime ?
« Reply #12 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.