- Home /
Question by
vikingfabian-com · Nov 06, 2015 at 09:31 AM ·
guitexturespriteeditorguilayoutobjectfield
ObjectField Sprite picker: The texCoords size is always one, on Single Sprite textures
I have an editor where the user can pick a sprite to use for their tiles. When I pick from sprite sheet with multiple sprite the texCoords are correct, but when I pick a texture that is a Single Sprite, the textCoord size is always Width: 1 Height: 1
Sprite currentSprite = GraphicsExtensions.MaterialToSprite(material);
Sprite sprite = EditorGUILayout.ObjectField("Select sprite", currentSprite, typeof(Sprite), false) as Sprite;
if (sprite != null)
{
if (!GraphicsExtensions.IsEmpty(sprite))
{
selectedTileMat.SetMaterial(sprite);
saveChanges = true;
Debug.Log("Sprite sel: " + sprite.name + sprite.rect.ToString());
}
}
Output on multiple sprite texture example: "Sprite sel: Rectangle(x:0.00, y:0.00, width:32.00, height:32.00)"
Output on single sprite texture example: "Sprite sel: (x:0.00, y:0.00, width:1.00, height:1.00)"
Comment
Your answer
Follow this Question
Related Questions
Sprites and minmizing memory usage 1 Answer
Gui.Box - Sprite 0 Answers
How to create a GUI like Zombieville? 1 Answer
Gui Box - Texture - Spritesheet 0 Answers
Sprite editor and texture 1 Answer