Skip to content

Instantly share code, notes, and snippets.

@sasame
Last active June 1, 2019 15:23
Show Gist options
  • Select an option

  • Save sasame/cb3ac1ace29cf42b8ccc460b0e790f0e to your computer and use it in GitHub Desktop.

Select an option

Save sasame/cb3ac1ace29cf42b8ccc460b0e790f0e to your computer and use it in GitHub Desktop.
using System.Text;
using UnityEngine;
using UnityEngine.UI;
[RequireComponent(typeof(Text))]
public class MaxGameObjects : MonoBehaviour {
string[] _units = new string[]{"","万","億","兆","京"};
int _num = 0;
int _createOneFrame = 100;
Text _text;
string getText(int n)
{
string s = "";
int unitIdx = 0;
while(n >= 10000)
{
s = ((n%10000) + _units[unitIdx]) + s;
++unitIdx;
n /= 10000;
}
s = ((n%10000) + _units[unitIdx]) + s;
++unitIdx;
return s;
}
// Use this for initialization
void Start () {
_text = GetComponent<Text>();
}
// Update is called once per frame
void Update () {
for(int i=0;i<_createOneFrame;++i)
{
var o = new GameObject("o" + _num);
++_num;
}
_text.text = getText(_num) + " objects";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment