示例#1
0
 private void RemoteVersionDownloaderFailed(AssetVersion local)
 {
     if (remoteVersionDownloadFailed != null)
     {
         remoteVersionDownloadFailed(this, _localVersions.IndexOf(local));
     }
 }
示例#2
0
        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));
        }
示例#3
0
        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();
        }
示例#4
0
		private void RemoteVersionDownloaderFinished( AssetVersion local, AssetVersion remote)
		{
			_localToRemoteVersions[ local] = remote;

			if( remoteVersionDownloadFinished != null)
			{
				remoteVersionDownloadFinished( this, _localVersions.IndexOf( local));
			}
		}
示例#5
0
        private void RemoteVersionDownloaderFinished(AssetVersion local, AssetVersion remote)
        {
            _localToRemoteVersions[local] = remote;

            if (remoteVersionDownloadFinished != null)
            {
                remoteVersionDownloadFinished(this, _localVersions.IndexOf(local));
            }
        }
示例#6
0
        private void DownloadButtonPressed(GUIBase sender)
        {
            AssetVersion remoteVersion = AssetUpdater.Instance.GetRemoteVersion(sender.tag);

            if (remoteVersion != null)
            {
                Application.OpenURL(Uri.EscapeUriString(remoteVersion.packageURI.ToString()));
            }
        }
示例#7
0
        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");
            }
        }
示例#8
0
        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");
        }
示例#9
0
        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();
                }));
            }
        }
示例#11
0
        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);
        }
示例#12
0
        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);
        }
示例#13
0
        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);
        }
示例#14
0
        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);
        }
示例#15
0
		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;
		}
示例#16
0
		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);
         }
     }
 }
示例#19
0
		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();
 }
示例#21
0
        public void Add( AssetVersion local)
		{
			_queue.Add( local);
			AttemptNextDownload();
		}
示例#22
0
		private void RemoteVersionDownloaderFailed( AssetVersion local)
		{
			if( remoteVersionDownloadFailed != null)
			{
				remoteVersionDownloadFailed( this, _localVersions.IndexOf( local));
			}
		}
示例#23
0
		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;
		}