unity3d - Get Texture2D of gameObject -


i'm having problem getting texture2d of gameobject.

my gameobject has sprite renderer contains texture type of advance read/write enabled checked.

here code:

spriterenderer go; void start () {      go = getcomponent<spriterenderer> ();  }  void update () {     print (go.material.maintexture.height); } 

i want display height, feel once can whatever want every pixel of it.

instead of taking texture material, remember spriterenderer component, therefore has sprite on it, not regular texture, try taking texture2d directly sprite.

print(go.sprite.texture.height); 

also if not work you, tell getting easier understand problem.


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -