Exemplo n.º 1
0
        /// <summary>
        /// Downloads a PDB file from a specified URL.
        /// Shows a Message Dialog when an error occurs.
        /// </summary>
        /// <returns><c>true</c>, if molecule was imported properly, <c>false</c> otherwise.</returns>
        /// <param name="url">URL.</param>
        /// <param name="name">Name.</param>
        public bool DownloadFile(string url, string name)
        {
            WWW www = new WWW(url);

            while (!www.isDone)
            {
                EditorUtility.DisplayProgressBar("Download", "Downloading...", www.progress);
            }

            EditorUtility.ClearProgressBar();

            if (!string.IsNullOrEmpty(www.error))
            {
                EditorUtility.DisplayDialog("Error", www.error, "Close");
                return(false);
            }
            else
            {
                PdbParser p = PdbParser.FromString(url, www.text, name);
                Molecule  m = p.Parse();
                Create(m);

                return(true);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Shows an OpenFilePanel and lets the user select a pdb file.
        /// </summary>
        public void UserSelectFile()
        {
            string filename = EditorUtility.OpenFilePanel("PDB File", "", "pdb");

            if (!string.IsNullOrEmpty(filename))
            {
                PdbParser p = PdbParser.FromFile(filename);
                Molecule  m = p.Parse();
                Create(m);
            }
        }