public async void LoadCode() { string[] selectedFiles = SFB.StandaloneFileBrowser.OpenFilePanel("Robot Code Executable", "C:\\", "", false); if (selectedFiles.Length != 1) { AnalyticsManager.GlobalInstance.LogEventAsync(AnalyticsLedger.EventCatagory.EmulationTab, AnalyticsLedger.EventAction.CodeType, "No Code", AnalyticsLedger.getMilliseconds().ToString()); } else { UserProgram userProgram = new UserProgram(selectedFiles[0]); if (userProgram.ProgramType == UserProgram.Type.INVALID) { UserMessageManager.Dispatch("Invalid user program type", EmulationWarnings.WARNING_DURATION); } else if (userProgram.Size > EmulatorManager.MAX_FILE_SIZE) { UserMessageManager.Dispatch(Math.Round((double)userProgram.Size / (1024 * 1024), 2) + " MB user program is too large (capacity is " + Math.Round((double)EmulatorManager.MAX_FILE_SIZE / (1024 * 1024), 2) + " MB)", EmulationWarnings.WARNING_DURATION); } else { if (userProgram.Size > EmulatorManager.WARNING_FILE_SIZE) { UserMessageManager.Dispatch("Uploading large, " + Math.Round((double)userProgram.Size / (1024 * 1024), 2) + " MB user program. Upload may take a while.", EmulationWarnings.WARNING_DURATION); } PlayerPrefs.SetString("UserProgramType", userProgram.ProgramType.ToString()); AnalyticsManager.GlobalInstance.LogEventAsync(AnalyticsLedger.EventCatagory.EmulationTab, AnalyticsLedger.EventAction.CodeType, userProgram.ProgramType.ToString(), AnalyticsLedger.getMilliseconds().ToString()); loadingPanel.SetActive(true); uploadSuccess = await EmulatorManager.SCPFileSender(userProgram); uploadFinished = true; } } }