Advertisement
SizilStank

Untitled

Oct 16th, 2022
785
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.84 KB | Gaming | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEditor.Animations;
  4. using UnityEngine;
  5.  
  6.  
  7. public class LoadCharacter : MonoBehaviour
  8. {
  9.     public List<AnimatorController> skins = new List<AnimatorController>();
  10.     public GameObject selectedSkin;
  11.     public GameObject player;
  12.  
  13.     public Animator selectedAnimator;
  14.  
  15.     void Start()
  16.     {
  17.         int selectedCharacter = PlayerPrefs.GetInt("selectedCharacter");
  18.         selectedAnimator.runtimeAnimatorController = skins[selectedCharacter];
  19.         selectedAnimator = selectedSkin.GetComponent<Animator>();
  20.  
  21.         player.GetComponent<Animator>().runtimeAnimatorController = skins[selectedCharacter];
  22.  
  23.         //PlayerPrefs.GetInt("selectedCharacter");
  24.         Debug.Log("Loaded " + PlayerPrefs.GetInt("selectedCharacter"));
  25.  
  26.         //label.text = prefab.name;*/
  27.     }
  28. }
  29.  
Tags: unity2d
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement