OnClick change Animator & Sprite Renderer

In the menu of my game, have an option to change the skin.

How do I, so that when the user clicks on “change,” and whe he enter the game the “Controller Animator” and “Sprite Renderer” is changed?

Animators: Bee, Bee1, Bee2, Bee3, and Bee4

Spriter rederers: Bee_0, Bee1_0, Bee2_0, Bee3_0 and Bee4_0

It’s possible “OnClick” change Controller “Bee” to “Bee1” & Sprite Renderer “Bee_0” to “Bee1_0” ?

My “Bee” (PLAYER) script

using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityStandardAssets.CrossPlatformInput;

public class Bee : MonoBehaviour {

	public float moveSpeed;

	public Transform bee;
	private Animator animator;

	public bool isGrounded = true;
	public float force;

	public float jumpTime = 0.1f;
	public float jumpDelay = 0.1f;
	public bool jumped = false;
	public Transform ground;

	// Use this for initialization
	void Start ()
		animator = bee.GetComponent<Animator> ();
	void Update ()
		Move ();

	void Move ()

		isGrounded = Physics2D.Linecast (this.transform.position, ground.position, 1 << LayerMask.NameToLayer ("Floor"));
		animator.SetFloat ("runB", Mathf.Abs (CrossPlatformInputManager.GetAxis ("Horizontal")));
		if (CrossPlatformInputManager.GetAxisRaw ("Horizontal") > 0) {

			transform.Translate (Vector2.right * moveSpeed * Time.deltaTime);
			transform.eulerAngles = new Vector2 (0, 0);
		if (CrossPlatformInputManager.GetAxisRaw ("Horizontal") < 0) {

			transform.Translate (Vector2.right * moveSpeed * Time.deltaTime);
			transform.eulerAngles = new Vector2 (0, 180);

		if (CrossPlatformInputManager.GetButtonDown ("Vertical") && isGrounded && !jumped) {

			//  rigidbody2D.AddForce (transform.up * force);
			GetComponent<Rigidbody2D> ().AddForce (transform.up * force);
			jumpTime = jumpDelay;
			animator.SetTrigger ("jumpB");
			jumped = true;

		jumpTime -= Time.deltaTime;

		if (jumpTime <= 0 && isGrounded && jumped) {

			animator.SetTrigger ("groundB");
			jumped = false;




You have to Options
I. Make a few Prefabs the Player can chose from

II. Write a Method like this and attach it to your Button OnClick() Event:

    puplic RuntimeAnimatorController anim;
        puplic void ChangeAnimator() {
              Animator animator = playerTransform.gameObject.GetComponent<Animator>();
              animator.runtimeAnimatorController = anim;

Look how going my project.

At MenuShopCanvas, I have attached “Choice” script on the button

Imagens: Imgur: The magic of the Internet

using UnityEngine; using System.Collections;

public class Choice : MonoBehaviour {

	public RuntimeAnimatorController anim;
	public Transform bee;

	public void ChangeAnimator() {
		Animator animator = bee.gameObject.GetComponent<Animator>();
		animator.runtimeAnimatorController = anim;

But when i click “Choice” or “Default” nothing happens.

I put the “Controller Animator” which was created for each prefab, correct?

What am I doing wrong? When I click “Play” no prefab is instantiated.