private void RemoteVersionDownloaderFailed(AssetVersion local) { if (remoteVersionDownloadFailed != null) { remoteVersionDownloadFailed(this, _localVersions.IndexOf(local)); } }
private void CreateGUI() { AssetUpdater updater = AssetUpdater.Instance; _gui = new GUIVertical(); GUIScrollView scrollView = _gui.Add(new GUIScrollView()) as GUIScrollView; scrollView.Add(new GUILabel(new GUIContent("Installed Assets"))); GUIStyle style = CreateBackgroundStyle(55, 70); _assetUpdateLabels = new List <GUILabel>(); _assetUpdateButtonContainers = new List <GUIHorizontal>(); GUIStyle statusStyle = new GUIStyle(); statusStyle.margin = new RectOffset(2, 4, 2, 2); statusStyle.normal.textColor = new Color(0.7f, 0.7f, 0.7f); statusStyle.alignment = TextAnchor.MiddleRight; int count = updater.AssetCount; for (int i = 0; i < count; i++) { AssetVersion localVersion = updater.GetLocalVersion(i); AssetVersion remoteVersion = updater.GetRemoteVersion(i); GUIHorizontal bar = scrollView.Add(new GUIHorizontal(style)) as GUIHorizontal; GUIVertical infoContainer = bar.Add(new GUIVertical()) as GUIVertical; infoContainer.Add(new GUILabel(new GUIContent(localVersion.Name + " (" + localVersion.Version + ")"))); infoContainer.Add(new GUILabel(new GUIContent(localVersion.Author))); string labelText = UpdateTextForVersion(localVersion, remoteVersion); GUIVertical updateContainer = bar.Add(new GUIVertical()) as GUIVertical; GUILabel label = updateContainer.Add(new GUILabel(new GUIContent(labelText))) as GUILabel; label.style = statusStyle; GUIHorizontal buttonsContainer = updateContainer.Add(new GUIHorizontal()) as GUIHorizontal; GUIButton button = buttonsContainer.Add(new GUIButton(new GUIContent("Release Notes"), ReleaseNotesButtonPressed)) as GUIButton; button.tag = i; button = buttonsContainer.Add(new GUIButton(new GUIContent("Download"), DownloadButtonPressed)) as GUIButton; button.tag = i; buttonsContainer.isHidden = remoteVersion == null || (localVersion.Version < remoteVersion.Version) == false; _assetUpdateLabels.Add(label); _assetUpdateButtonContainers.Add(buttonsContainer); } GUIHorizontal refreshContainer = scrollView.Add(new GUIHorizontal()) as GUIHorizontal; refreshContainer.Add(new GUISpace(true)); refreshContainer.Add(new GUIButton(new GUIContent("Refresh"), RefreshButtonPressed)); }
private void RemoteVersionDownloadFinished(AssetUpdater updater, int assetIndex) { AssetVersion local = AssetUpdater.Instance.GetLocalVersion(assetIndex); AssetVersion remote = AssetUpdater.Instance.GetRemoteVersion(assetIndex); _assetUpdateLabels[assetIndex].content.text = UpdateTextForVersion(local, remote); _downloadButtons[assetIndex].isHidden = (local.Version < remote.Version) == false; Repaint(); }
private void RemoteVersionDownloaderFinished( AssetVersion local, AssetVersion remote) { _localToRemoteVersions[ local] = remote; if( remoteVersionDownloadFinished != null) { remoteVersionDownloadFinished( this, _localVersions.IndexOf( local)); } }
private void RemoteVersionDownloaderFinished(AssetVersion local, AssetVersion remote) { _localToRemoteVersions[local] = remote; if (remoteVersionDownloadFinished != null) { remoteVersionDownloadFinished(this, _localVersions.IndexOf(local)); } }
private void DownloadButtonPressed(GUIBase sender) { AssetVersion remoteVersion = AssetUpdater.Instance.GetRemoteVersion(sender.tag); if (remoteVersion != null) { Application.OpenURL(Uri.EscapeUriString(remoteVersion.packageURI.ToString())); } }
private void ReleaseNotesButtonPressed(GUIBase sender) { AssetVersion remoteVersion = AssetUpdater.Instance.GetRemoteVersion(sender.tag); if (remoteVersion != null) { string title = remoteVersion.Name + " (" + remoteVersion.Version + ") Release Notes"; EditorUtility.DisplayDialog(title, remoteVersion.Notes, "OK"); } }
private void ReleaseNotesButtonPressed(GUIBase sender) { AssetVersion localVersion = AssetUpdater.Instance.GetLocalVersion(sender.tag); AssetVersion remoteVersion = AssetUpdater.Instance.GetRemoteVersion(sender.tag); AssetVersion version = remoteVersion != null && localVersion.Version < remoteVersion.Version ? remoteVersion : localVersion; string title = version.Name + " (" + version.Version + ") Release Notes"; EditorUtility.DisplayDialog(title, version.Notes, "OK"); }
public AssetVersion GetRemoteVersion(int index) { AssetVersion localVersion = GetLocalVersion(index); if (_localToRemoteVersions.ContainsKey(localVersion)) { return(_localToRemoteVersions[localVersion]); } return(null); }
private void HandleFailedDownload() { if (remoteVersionDownloadFailed != null) { _mainThreadDelegates.Add(new Action(() => { remoteVersionDownloadFailed(_currentLocalVersion); _currentLocalVersion = null; _webClient = null; AttemptNextDownload(); })); } }
private void DownloadDone() { dlDone = false; AssetVersion remote = AssetUpdater.Instance.GetRemoteVersion(0); WWWForm form = new WWWForm(); form.AddField("hash", DatabaseInterface.hash); form.AddField("type", "dlStat"); form.AddField("version", remote.Version.ToString()); DatabaseInterface.DbRequestNoResponse(form); AssetDatabase.ImportPackage(filePath, true); }
private string UpdateTextForVersion(AssetVersion local, AssetVersion remote) { string text = "Checking for Updates..."; if (remote != null) { if (remote.Version > local.Version) { text = "Update Available: " + remote.Version; } else { text = "Installed Version is Latest"; } } return(text); }
public static AssetVersion ParseXML(string xmlString) { XmlDocument xml = new XmlDocument(); try { xml.LoadXml(xmlString); } catch (XmlException) { return(null); } XmlNode name = xml.SelectSingleNode("asset/name"); XmlNode author = xml.SelectSingleNode("asset/author"); XmlNode version = xml.SelectSingleNode("asset/version"); XmlNode notes = xml.SelectSingleNode("asset/notes"); XmlNode packageURI = xml.SelectSingleNode("asset/package-uri"); XmlNode versionURI = xml.SelectSingleNode("asset/version-uri"); if (name == null || author == null || version == null || notes == null || packageURI == null || versionURI == null) { Debug.Log("Error parsing Asset Version XML"); return(null); } SemanticVersion semanticVersion = SemanticVersion.Parse(version.InnerText); if (semanticVersion == null) { Debug.Log("Error parsing Semantic Version"); return(null); } AssetVersion assetVersion = new AssetVersion(); assetVersion.Name = name.InnerText; assetVersion.Author = author.InnerText; assetVersion.Version = semanticVersion; assetVersion.Notes = notes.InnerText; assetVersion.packageURI = new Uri(packageURI.InnerText); assetVersion.versionURI = new Uri(versionURI.InnerText); return(assetVersion); }
private List <AssetVersion> FindLocalVersions() { List <AssetVersion> versions = new List <AssetVersion>(); string[] paths = Directory.GetFiles(Application.dataPath, "AssetVersion.xml", SearchOption.AllDirectories); foreach (string path in paths) { string localXML = File.ReadAllText(path); AssetVersion version = AssetVersion.ParseXML(localXML); if (version != null) { versions.Add(version); } } return(versions); }
public static AssetVersion ParseXML( string xmlString) { XmlDocument xml = new XmlDocument(); try { xml.LoadXml( xmlString); } catch( XmlException) { return null; } XmlNode name = xml.SelectSingleNode( "asset/name"); XmlNode author = xml.SelectSingleNode( "asset/author"); XmlNode version = xml.SelectSingleNode( "asset/version"); XmlNode notes = xml.SelectSingleNode( "asset/notes"); XmlNode packageURI = xml.SelectSingleNode( "asset/package-uri"); XmlNode versionURI = xml.SelectSingleNode( "asset/version-uri"); if( name == null || author == null || version == null || notes == null || packageURI == null || versionURI == null) { Debug.Log( "Error parsing Asset Version XML"); return null; } SemanticVersion semanticVersion = SemanticVersion.Parse( version.InnerText); if( semanticVersion == null) { Debug.Log( "Error parsing Semantic Version"); return null; } AssetVersion assetVersion = new AssetVersion(); assetVersion.Name = name.InnerText; assetVersion.Author = author.InnerText; assetVersion.Version = semanticVersion; assetVersion.Notes = notes.InnerText; assetVersion.packageURI = new Uri( packageURI.InnerText); assetVersion.versionURI = new Uri( versionURI.InnerText); return assetVersion; }
private void AttemptNextDownload() { if( _webClient == null && _queue.Count > 0) { _currentLocalVersion = _queue[0]; _queue.RemoveAt( 0); using( _webClient = new WebClient()) { _webClient.DownloadStringCompleted += WebClientCompleted; try { _webClient.DownloadStringAsync( _currentLocalVersion.versionURI); } catch( Exception e) { Debug.Log("dl exception: " + e); HandleFailedDownload(); } } } }
private void AttemptNextDownload() { if (_webClient == null && _queue.Count > 0) { _currentLocalVersion = _queue[0]; _queue.RemoveAt(0); using (_webClient = new WebClient()) { _webClient.DownloadStringCompleted += WebClientCompleted; try { _webClient.DownloadStringAsync(_currentLocalVersion.versionURI); } catch (Exception e) { Debug.Log("dl exception: " + e); HandleFailedDownload(); } } } }
private void WebClientCompleted(object sender, DownloadStringCompletedEventArgs e) { if (e.Cancelled || e.Error != null) { if (e.Error != null) { Debug.Log("dl complete error: " + e.Error); } HandleFailedDownload(); } else { AssetVersion remote = AssetVersion.ParseXML(e.Result); if (remote == null) { HandleFailedDownload(); } else { HandleFinishedDownload(remote); } } }
private void HandleFailedDownload() { if( remoteVersionDownloadFailed != null) { _mainThreadDelegates.Add( new Action( () => { remoteVersionDownloadFailed( _currentLocalVersion); _currentLocalVersion = null; _webClient = null; AttemptNextDownload(); })); } }
public void Add(AssetVersion local) { _queue.Add(local); AttemptNextDownload(); }
public void Add( AssetVersion local) { _queue.Add( local); AttemptNextDownload(); }
private void RemoteVersionDownloaderFailed( AssetVersion local) { if( remoteVersionDownloadFailed != null) { remoteVersionDownloadFailed( this, _localVersions.IndexOf( local)); } }
private string UpdateTextForVersion( AssetVersion local, AssetVersion remote) { string text = "Checking for Updates..."; if( remote != null) { if( remote.Version > local.Version) { text = "Update Available: " + remote.Version; } else { text = "Installed Version is Latest"; } } return text; }