2D Sprite Swap -- HOW?!? (unity 4.3)

Guys… I have been at this for over 7 hours. I cannot, for the life of me, figure out how to swap out textures in the new 4.3 unity sprite editor.

It was super simple before when I had a script handling things, but I figured I would take advantage of the new 4.3 features, and literally redo my entire game. New system, new ways to do things, and therefor less resources to learn.

Does anybody know how to do… literally everything about this? I’m not looking for a “GetComponent(SpriteRenderer).sprite = newSprite;” response. That’s not gonna tell me anything.

If it’s even possible, please link me to something that shows me how this kind of thing is done.

Or list off:
“use this variable”
(IE: var theSpriteYouSwitchTo : SpriteRenderer;) (or whatever, seriously, I have no idea how to set up this new system)

“This script in the start function”

“This script in the update function”

“This script in the Trigger2D function”
(Because my character’s entire outfit changes (2D sprites) when the character gets a power up.)

I wanna ball into a corner and just die at this point. Why the hell are they making this thing so difficult. Do they NOT think people are going to have powerups in their 2D games?? Am I asking for too much to get an intuitive engine for simple functions? C’MON unity! jesus.

Okay. FIRST!

Gameobject go = Gameobject.FindWithTag(“The tag on the object you’re changing the sprite of”);

that just sets go to equal the gameobject you are tracing, next thing is.

Spriterenderer renderer = go.GetComponent(); //What this says is get the component “Spriterenderer” off of Gameobject “go” and set it to the “renderer” variable.

then you may access that. you may now put something like:

and then in your movement file you set a sprite array “public Sprite char1Up;”
and place all those sprites in it, and make a timer going down by deltaTime, every second it does “i++” or something, then you can do:


renderer.sprite = char1UP*;*
That says "if the W key is held the sprite well equal whatever picture is currently selected " thats why you do the timer, it changes the picture every second or something like that, and it runs threw all the sprites. you can then do something like
"if(i > 4){
i = 0;
which resets it, this is how i did my walking animations… Hope it helped! If not, maybe it helped you learn something new!