Last active
June 1, 2019 15:23
-
-
Save sasame/cb3ac1ace29cf42b8ccc460b0e790f0e to your computer and use it in GitHub Desktop.
This file contains hidden or 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.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