public void FirstInitialization() { beginButton = GameObject.FindGameObjectWithTag("Begin").GetComponent <BeginButton>(); exitButton = GameObject.FindGameObjectWithTag("Quit").GetComponent <ExitButton>(); counter = GameObject.FindGameObjectWithTag("Counter").GetComponent <Text>(); win = GameObject.FindGameObjectWithTag("Win").GetComponent <Text>(); counter.enabled = false; win.enabled = false; }
private void UploadFilePartial(ProgressViewModel <System.IO.FileInfo> item, Action <long> uploadCompletedCallback, UploadFile us, long tl, byte[] hs, long offset) { var ms = new MemoryStream(us.GetBuffer()); //var offset = us.Stream.Position; BeginButton.SendFilePartial <long>(Commands.TestSendFilePartial, ms, r => { if (r.HasResult) { item.CurrentValue = r.Result; if (r.Result < tl) //不能使用 us.Stream.Length;因为当读取时有可能会返回异常。 { //传输中。 us.Read(r.Result); offset = r.Result; if (us.Cancelled || item.Cancelled) { //被用户取消。 us.Close(); } else { //继续传输。 //svr.UploadAsync(us.Storage,e.Result,us.GetBuffer());//使用流拷贝后不再使用。 UploadFilePartial(item, uploadCompletedCallback, us, tl, hs, offset); } } if (r.Result == item.Body.Length) { //传输完毕。 us.Close(); uploadCompletedCallback(r.Result); item.Completed = true; } //Jiuyong:完成文件不对时的处理(比如,因意外而导致的不是上传到同一个文件上的) } else { //失去响应。 us.Close(); item.Cancelled = true; } } , offset: offset //, //length: data.Length , totalLength: tl , hash: hs ); }