Advertisement
Guest User

Untitled

a guest
Dec 2nd, 2015
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.29 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using UnityEngine.UI;
  4.  
  5. public class CharacterPresentation : MonoBehaviour {
  6.  
  7.     GameObject[] array;
  8.     [HideInInspector]
  9.     public GameObject actual;
  10.     public Store reference;
  11.     int i;
  12.     bool showing = false;
  13.     Color col;
  14.  
  15.     void Awake() {
  16.         col.r = 255;
  17.         col.g = 255;
  18.         col.b = 255;
  19.         col.a = reference.main.GetComponentInChildren<Text>().color.a;
  20.  
  21.     }
  22.  
  23.     void Start () {
  24.         array = GameObject.FindGameObjectsWithTag("Player");
  25.         string actualName = PlayerPrefs.GetString("skinName");
  26.         //print(actualName);
  27.         actual = GameObject.Find(actualName);
  28.         foreach (Transform skin in transform) {
  29.             if (skin.name != actual.name)
  30.                 skin.gameObject.SetActive(false);
  31.         }
  32.         i = 0;
  33.         reference.main.GetComponentInChildren<Text>().text = actual.name;
  34.         showing = true;
  35.     }
  36.    
  37.     void Update () {
  38.         transform.RotateAround(transform.position, new Vector3(0, 90, -0), Time.deltaTime * 90f);
  39.         if (showing) {
  40.             col.a -= 0.5f * Time.deltaTime;
  41.             reference.main.GetComponentInChildren<Text>().color = col;
  42.             if (col.a < 0.005) {
  43.                 showing = false;
  44.             }
  45.         }
  46.     }
  47.  
  48.     public void ChangeLeft() {
  49.         for (int j = 0; j < array.Length; j++) {
  50.             if (array[j].name == actual.name) {
  51.                 i = j;
  52.             }
  53.         }
  54.         //print(i);
  55.         if (--i >= 0) {
  56.             //print(i);
  57.             actual.SetActive(false);
  58.             array[i].SetActive(true);
  59.             actual = array[i];
  60.             col.a = 1;
  61.         }
  62.         reference.main.GetComponentInChildren<Text>().text = actual.name;
  63.         showing = true;
  64.     }
  65.  
  66.     public void ChangeRight() {
  67.         for (int j = 0; j < array.Length; j++) {
  68.             if (array[j].name == actual.name) {
  69.                 i = j;
  70.             }
  71.         }
  72.         //print(i);
  73.         if (++i < array.Length) {
  74.             //print(i);
  75.             actual.SetActive(false);
  76.             array[i].SetActive(true);
  77.             actual = array[i];
  78.             col.a = 1;
  79.         }
  80.         reference.main.GetComponentInChildren<Text>().text = actual.name;
  81.         showing = true;
  82.     }
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement