示例#1
0
    public static IEnumerator LoadBinHeader(string filename, PatchDataLoadedCallback <GridData> callback)
    {
#if UNITY_WEBGL
        callback(ParseBinHeader(PatchDataIO.brHeaders));
        yield break;
#else
        yield return(FileRequest.GetBinary(filename, (br) => callback(ParseBinHeader(br))));
#endif
    }
示例#2
0
    public static IEnumerator ParseAsync <T>(StreamReader sr, string filename, ParseTask task, PatchDataLoadedCallback <T> callback) where T : PatchData
    {
        if (parseThread == null)
        {
            taskData = new ParseTaskData();

            parseThread = new Thread(ParseThread)
            {
                Name     = "ParseThread",
                Priority = ThreadPriority.Highest,
            };
            parseThread.Start();
        }

        lock (_lock)
        {
            taskData.sr       = sr;
            taskData.filename = filename;
            taskData.task     = task;

            blockParser = false;
            Monitor.Pulse(_lock);
        }

        while (!blockParser)
        {
            yield return(IEnumeratorExtensions.AvoidRunThru);
        }

        callback(taskData.patch as T);

        // Clear task data
        taskData.Clear();
    }
示例#3
0
 public static IEnumerator LoadBin(this GridData grid, string filename, PatchDataLoadedCallback <GridData> callback)
 {
     yield return(FileRequest.GetBinary(filename, (br) => callback(ParseBin(br, grid))));
 }
示例#4
0
 public static IEnumerator LoadCsv(string filename, PatchDataLoadedCallback <GridData> callback)
 {
     yield return(FileRequest.GetText(filename, (sr) => callback(ParseCsv(sr, filename))));
 }
示例#5
0
 public static IEnumerator LoadCsv(string filename, PatchDataLoadedCallback <MultiGridData> callback)
 {
     yield return(FileRequest.GetText(filename, (sr) => PatchDataIO.ParseAsync(sr, filename, ParseCsv, callback)));
 }
示例#6
0
 public static IEnumerator LoadBin(this PointData pointData, string filename, PatchDataLoadedCallback <PointData> callback)
 {
     yield return(FileRequest.GetBinary(filename, (br) => callback(ParseBin(br, filename, pointData))));
 }