Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using UnityEngine.UI;
- public class CharacterPresentation : MonoBehaviour {
- GameObject[] array;
- [HideInInspector]
- public GameObject actual;
- public Store reference;
- int i;
- bool showing = false;
- Color col;
- void Awake() {
- col.r = 255;
- col.g = 255;
- col.b = 255;
- col.a = reference.main.GetComponentInChildren<Text>().color.a;
- }
- void Start () {
- array = GameObject.FindGameObjectsWithTag("Player");
- string actualName = PlayerPrefs.GetString("skinName");
- //print(actualName);
- actual = GameObject.Find(actualName);
- foreach (Transform skin in transform) {
- if (skin.name != actual.name)
- skin.gameObject.SetActive(false);
- }
- i = 0;
- reference.main.GetComponentInChildren<Text>().text = actual.name;
- showing = true;
- }
- void Update () {
- transform.RotateAround(transform.position, new Vector3(0, 90, -0), Time.deltaTime * 90f);
- if (showing) {
- col.a -= 0.5f * Time.deltaTime;
- reference.main.GetComponentInChildren<Text>().color = col;
- if (col.a < 0.005) {
- showing = false;
- }
- }
- }
- public void ChangeLeft() {
- for (int j = 0; j < array.Length; j++) {
- if (array[j].name == actual.name) {
- i = j;
- }
- }
- //print(i);
- if (--i >= 0) {
- //print(i);
- actual.SetActive(false);
- array[i].SetActive(true);
- actual = array[i];
- col.a = 1;
- }
- reference.main.GetComponentInChildren<Text>().text = actual.name;
- showing = true;
- }
- public void ChangeRight() {
- for (int j = 0; j < array.Length; j++) {
- if (array[j].name == actual.name) {
- i = j;
- }
- }
- //print(i);
- if (++i < array.Length) {
- //print(i);
- actual.SetActive(false);
- array[i].SetActive(true);
- actual = array[i];
- col.a = 1;
- }
- reference.main.GetComponentInChildren<Text>().text = actual.name;
- showing = true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement