123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- using System;
- using UnityEngine;
- public class FpsCounter : MonoBehaviour
- {
- public void Awake()
- {
- if (this.num_sprite_array_ == null)
- {
- this.num_sprite_array_ = new UISprite[3];
- for (int i = 0; i < this.num_sprite_array_.Length; i++)
- {
- this.num_sprite_array_[i] = UTY.GetChildObject(base.gameObject, "Grid/keta" + i.ToString(), false).GetComponent<UISprite>();
- }
- }
- }
- public void Start()
- {
- this.Awake();
- for (int i = 1; i < this.num_sprite_array_.Length; i++)
- {
- this.num_sprite_array_[i].spriteName = this.GetSpriteName(0);
- this.num_sprite_array_[i].gameObject.SetActive(false);
- }
- this.back_time_ = Time.realtimeSinceStartup;
- }
- public void Update()
- {
- this.count_++;
- float realtimeSinceStartup = Time.realtimeSinceStartup;
- if (1f < realtimeSinceStartup - this.back_time_)
- {
- char[] array = this.count_.ToString().ToCharArray();
- Array.Reverse(array);
- for (int i = 0; i < this.num_sprite_array_.Length; i++)
- {
- if (array.Length <= i)
- {
- this.num_sprite_array_[i].gameObject.SetActive(false);
- }
- else
- {
- this.num_sprite_array_[i].spriteName = this.GetSpriteName(array[i]);
- this.num_sprite_array_[i].gameObject.SetActive(true);
- }
- }
- this.count_ = 0;
- this.back_time_ = realtimeSinceStartup;
- }
- }
- public string GetSpriteName(int num)
- {
- return "cmd2_fps_number" + num.ToString();
- }
- public string GetSpriteName(char num)
- {
- return "cmd2_fps_number" + num.ToString();
- }
- private UISprite[] num_sprite_array_;
- private float back_time_;
- private int count_;
- }
|