I have 64x64 texture of tree :
but output gives me this (black messed object is my tree)
If i drag sprite into editor, its rendered as meant to be(with new gameobject created). But im accesing it through script :
public Sprite treesIcon;
SpriteRenderer sr;
TileTypeHandler typeHandler;
void Start () {
sr = GetComponent<SpriteRenderer>();
}
void Update () {
switch(typeHandler.tileType) /// nevermind enum, its edited
{
case TileType.Woods:
{
sr.sprite = treesIcon;
break;
}
}
}
point is to dynamically change textures.
Can anyone explain me this behaviour? Is there somethin I am missing about sprites and textures? How can i fix it?
The result looks like the SpriteRenderer
is using the wrong shader
, change the Material to Sprites-Default
, and it should work.
Would you have colored images, you immediately would see that there is something wrong, because they would also appear black.