private IEnumerator downloadPaletteCoroutine() { m_textInfo.text = "Downloading palette..."; yield return(null); ColorPalette colorPalette = null; try { Uri uri = new Uri(m_inputURL.text); if (uri.Host.EndsWith("colourlovers.com")) { colorPalette = ColourLoversWebsiteImporter.Import(uri); } else if (uri.Host.EndsWith("dribbble.com")) { colorPalette = DribbbleWebsiteImporter.Import(uri); } else if (uri.Host.EndsWith("colorcombos.com")) { colorPalette = ColorCombosWebsiteImporter.Import(uri); } else { m_textInfo.text = "Sorry we do not support downloading palettes from the website " + uri.Host + " for now."; } } catch (Exception e) { m_textInfo.text = "Sorry an error occured: " + e.Message; } if (colorPalette != null) { m_textInfo.text = "Palette downloaded (found " + colorPalette.colorInfoList.Count + " colors)."; applyColorPaletteToCubes(colorPalette); } }
private void importPaletteFromURL(string url) { EditorUtility.DisplayProgressBar("Downloading palette", url, 0.5f); Uri uri = new Uri(url); try { if (uri.Host.EndsWith("colourlovers.com")) { m_paletteData.colorPaletteList.Add(ColourLoversWebsiteImporter.Import(uri)); } else if (uri.Host.EndsWith("dribbble.com")) { m_paletteData.colorPaletteList.Add(DribbbleWebsiteImporter.Import(uri)); } else if (uri.Host.EndsWith("colorcombos.com")) { m_paletteData.colorPaletteList.Add(ColorCombosWebsiteImporter.Import(uri)); } else if (uri.Host.EndsWith("colrd.com")) { m_paletteData.colorPaletteList.Add(ColrdWebsiteImporter.Import(uri)); } else { throw new UnityException("Sorry we do not support downloading palettes from the website " + uri.Host + " for now. Please contact us at [email protected] and we'll add support for whatever you want :D"); } } catch (Exception e) { EditorUtility.ClearProgressBar(); throw new UnityException(e.Message); } PaletteUtils.SavePalettes(m_paletteData); EditorUtility.ClearProgressBar(); }