public override void OnInspectorGUI() { currentObject = target as ISerializableObjectBase; if (currentObject == null) return; GUI.changed = false; if (GUILayout.Button("Reset")) OnReset(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Download")) DownloadFileFromServer(); if (GUILayout.Button("Delete From Server")) DeleteFileOnServer(); if (GUILayout.Button("Upload To Server")) UploadFileToServer(); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Read From Local")) ReadFromLocalFile(); if (GUILayout.Button("Save To Local")) SaveToLocalFile(); GUILayout.EndHorizontal(); base.OnInspectorGUI(); if (GUI.changed == true) EditorUtility.SetDirty((UnityEngine.Object)currentObject); }
void OnItemDownloadComplete(ISerializableObjectBase objectLoaded, bool wasLoadedSuccessfully, DownloadSource downloadSource) { if (didTimeOut == true || objectLoaded == null) return; for (int x = 0; x < downloadObjects.Length; x++) //go through all our download objects { if (downloadObjects[x].downloadObject.Equals(objectLoaded) == true) //if the finished object is one of them, set the values { decimal percentage = ((decimal)(x + 1) / (decimal)(downloadObjects.Length)) * (decimal)100.0; percentage = Math.Round(percentage, 0); DownloadGraphic.Show(percentage + "%"); downloadObjects[x].isFinished = true; downloadObjects[x].didDownloadSuccessfully = wasLoadedSuccessfully; downloadObjects[x].downloadSource = downloadSource; if (downloadObjects[x].didDownloadSuccessfully == true) //success downloading!! { if ((x + 1) < downloadObjects.Length) //if there is another object in the array, download it downloadObjects[x + 1].TryToDownload(OnItemDownloadComplete); else //we have downlaoded each object OnAllItemsDownloadedSuccessfully(); } else //fail!! try again { if (downloadObjects[x].downloadTries < failedDownloadRetries && downloadObjects[x].downloadObject.FileDoesExistOnServer == false) //try to redownload as many times as we need to downloadObjects[x].TryToDownload(OnItemDownloadComplete); else //if we tried more than the allowed number of times, call a failure event CantDownloadItem(downloadObjects[x]); } } } }