Created
June 19, 2017 13:14
-
-
Save tsubaki/13c8109014e40b5558fd3c3a6033a147 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
[CreateAssetMenu] | |
public class ClickCount : ScriptableObject | |
{ | |
public int count; | |
public void Add() | |
{ | |
count ++; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
[RequireComponent(typeof(UnityEngine.UI.Text))] | |
public class ClickCountUpdater : MonoBehaviour { | |
[SerializeField] ClickCount clickCount = null; | |
static System.Text.StringBuilder builder = new System.Text.StringBuilder(2); | |
UnityEngine.UI.Text label; | |
void Awake() | |
{ | |
label = GetComponent<UnityEngine.UI.Text> (); | |
} | |
void Update () | |
{ | |
builder.Length = 0; | |
builder.AppendFormat ("{0:D2}", clickCount.count); | |
label.text = builder.ToString (); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment