- Home /
Manually changing between sprites in a spritesheet
I have a spritesheet with two sprites, the character facing forward and the character facing backward. I'm trying to get a direct reference to these two sprites and switch between them in-game.
I'm using the example here: http://answers.unity3d.com/questions/591677/how-to-get-child-sprites-from-a-multiple-sprite-te.html
But I can't get the top answer to work. I converted this to javascript but I'm not sure how to get the ".OfType()" part to work. The line below is my attempt, but there is no LoadAllAssetsAtPath Method that accepts two parameters.
characterSprites = AssetDatabase.LoadAllAssetsAtPath( "Assets/Textures/RedWizardSpriteSheet", Sprite ).ToArray();
If you know how to fix the above so the example works, or if you have a better suggestion for how to tackle the problem, it would be much appreciated.
@EClancy, you can use sprite-editor. By using sprite editor generate two different sprites from your spriteSheet. give the referance to this sprite from your script and than change the sprite in the coding.
yeah set the texture type to ui/sprite and mode to multipe, then slice the sprite as you like. I will then use an animator to control the change of sprite of different action if it is some complicated actions.
Your answer
Follow this Question
Related Questions
How to (de) serialize unity references at runtime? 3 Answers
In Unity 2d is it possible to change which sprite sheet a player is using? 0 Answers
Changing animation when moving horizontally without flipping sprite 0 Answers
How can I unload a single resource? 2 Answers
Load xml from resource folder after build(web player) 0 Answers