Beispiel #1
0
        public async void OnClickGenerateFiles()
        {
            generateFilesButton.interactable = false;
            _i_file = 0;

            await Task.Run(() =>
            {
                var encoding  = _encodingList[dropdownEncoding.value];
                var data_size = _dataSizeList[dropdownDataSize.value];

                _write_file_time = 0;
                for (int i = 0; i < n_files; i++)
                {
                    _generator.SetPath(_loader.GetFilePath(i));
                    _generator.Generate(encoding, data_size, i + 1, 0.1f);

                    _write_file_time += _generator.ElapsedMilliseconds;
                    _i_file++;
                }
            });

            generateFilesButton.interactable = true;
        }
Beispiel #2
0
    // Start is called before the first frame update
    void Start()
    {
#if UNITY_EDITOR
        NativeLeakDetection.Mode = NativeLeakDetectionMode.EnabledWithStackTrace;
        _path = Application.dataPath + "/../Assets/NativeStringCollections/Samples/Temp/";
#else
        _path = Application.dataPath + "/Demo/";
#endif
        NativeStringCollections.Demo.DirectoryUtil.SafeCreateDirectory(_path);
        _path += "sample_demo.tsv";

        _encodingList = new List <Encoding>();
        _encodingList.Clear();

        // default Unity doesn't have some japanese local text encodings for standalone build.
        // ref: https://helpdesk.unity3d.co.jp/hc/ja/articles/204694010-System-Text-Encoding-%E3%81%A7-Shift-JIS-%E3%82%92%E4%BD%BF%E3%81%84%E3%81%9F%E3%81%84
        _encodingList.Add(Encoding.UTF8);
        _encodingList.Add(Encoding.UTF32);
        _encodingList.Add(Encoding.Unicode);
        //_encodingList.Add(Encoding.GetEncoding("shift_jis"));
        //_encodingList.Add(Encoding.GetEncoding("euc-jp"));
        //_encodingList.Add(Encoding.GetEncoding("iso-2022-jp"));

        if (_dropdownEncoding)
        {
            _dropdownEncoding.ClearOptions();

            var drop_menu = new List <string>();
            foreach (var e in _encodingList)
            {
                drop_menu.Add(e.EncodingName);
            }

            _dropdownEncoding.AddOptions(drop_menu);
            _dropdownEncoding.value = 0;
        }

        _dataSizeList = new List <int>
        {
            1024, 4096, 16384, 32768,
            125000, 250000, 500000, 1000000,
        };

        if (_dropdownDataSize)
        {
            _dropdownDataSize.ClearOptions();

            var drop_menu = new List <string>();
            foreach (var s in _dataSizeList)
            {
                drop_menu.Add(s.ToString());
            }
            _dropdownDataSize.AddOptions(drop_menu);
            _dropdownDataSize.value = 1;
        }

        _idIntervalList = new List <int>
        {
            1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
            11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
            21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
        };
        if (_dropdownIDInterval)
        {
            _dropdownIDInterval.ClearOptions();

            var drop_menu = new List <string>();
            foreach (var s in _idIntervalList)
            {
                drop_menu.Add(s.ToString());
            }
            _dropdownIDInterval.AddOptions(drop_menu);
            _dropdownIDInterval.value = 0;
        }

        _generateInCurrentProc = false;
        _generateProgress      = 0.0f;
        _loadProgress          = 0.0f;

        _generator = new Demo.CharaDataGenerator();
        _generator.SetPath(_path);
        _generatorPrevState = _generator.IsStandby;

        _loadAction = false;

        _generateButtonText = _generateButton.GetComponentInChildren <TMP_Text>();
        _loadButtonText     = _loadButton.GetComponentInChildren <TMP_Text>();

        _reader = new CharaDataParser_Standard();
    }