/// <summary> /// Loads the documentation image. Output will be saved in DocumentationImage_Cache /// Process is Asynchrone /// </summary> IEnumerator LoadDocumentationImage() { if (string.IsNullOrEmpty(DocumentationImageUrl)) { string screenshotFileName; string skin = EditorGUIUtility.isProSkin?"Dark":"Light"; if (_Type == ItemTypes.Action) { screenshotFileName = _Name.Replace(".cs", ".png"); DocumentationImageUrl = string.Format(__ActionScreenShotUrlFormat__, _RepositoryFullNamePath, skin, screenshotFileName); } else { screenshotFileName = _Name.Replace("." + _Type.ToString().ToLower() + ".txt", ".png"); DocumentationImageUrl = string.Format(__PackageScreenShotUrlFormat__, _RepositoryFullNamePath, _FolderPath, skin, screenshotFileName); } DocumentationImageUrl = DocumentationImageUrl.Replace(" ", "%20"); //Debug.Log(DocumentationImageUrl); } Debug.Log(_RepositoryFullNamePath); if (EcosystemBrowser.IsDebugOn) { Debug.Log("LoadDocumentation for <" + Name + "> url:" + DocumentationImageUrl); } DocumentationImageStatus = AsynchContentStatus.Downloading; WWW _www = new WWW(DocumentationImageUrl); while (!_www.isDone) { yield return(null); } if (string.IsNullOrEmpty(_www.error)) { DocumentationImageStatus = AsynchContentStatus.Available; Texture2D _t2d = new Texture2D(2, 2); _www.LoadImageIntoTexture(_t2d); DocumentationImage_Cache[DocumentationImageUrl] = _t2d as Texture; } else { if (EcosystemBrowser.IsDebugOn) { Debug.LogError("LoadDocumentation error for " + Name + " : " + _www.error); } DocumentationImageStatus = AsynchContentStatus.Unavailable; } yield break; }
/// <summary> /// Loads the meta data. output will be in json within the item raw data or the metadata property. /// Process is Asynchrone /// </summary> IEnumerator LoadMetaData() { if (EcosystemBrowser.IsDebugOn) { Debug.Log("LoadMetaData for <" + Name + ">"); } string url = GetUrl(urltypes.GithubRaw); MetaDataStatus = AsynchContentStatus.Downloading; WWW _www = new WWW(url); while (!_www.isDone) { yield return(null); } if (string.IsNullOrEmpty(_www.error)) { MetaDataStatus = AsynchContentStatus.Available; string jsonString = _www.text; bool canDecode = true; if (Type == ItemTypes.Action) { // we have to find the meta data within the script Match match = Regex.Match(jsonString, @"(?<=EcoMetaStart)[^>]*(?=EcoMetaEnd)", RegexOptions.IgnoreCase); // Here we check the Match instance. if (match.Success) { // Debug.Log("we have meta data :" + match.Value); jsonString = match.Value; } else { canDecode = false; MetaDataStatus = AsynchContentStatus.Unavailable; } } if (canDecode) { if (EcosystemBrowser.IsDebugOn) { Debug.Log("decode attempt for item" + Name + " from url <" + url + "> content:" + jsonString); } try{ Hashtable _meta = (Hashtable)JSON.JsonDecode(jsonString); RawData["metaData"] = _meta; ProcessMetaData(); }catch (Exception e) { MetaDataStatus = AsynchContentStatus.Unavailable; if (EcosystemBrowser.IsDebugOn) { Debug.LogError(e); } if (EcosystemBrowser.IsDebugOn) { Debug.LogError("could not decode json string for item" + Name + " from url <" + url + "> content:" + jsonString); } } } } else { if (EcosystemBrowser.IsDebugOn) { Debug.LogError("LoadMetaData error for " + Name + " with url <" + url + "> : " + _www.error); } MetaDataStatus = AsynchContentStatus.Unavailable; } yield break; }
/// <summary> /// Loads the documentation image. Output will be saved in DocumentationImage_Cache /// Process is Asynchrone /// </summary> IEnumerator LoadDocumentationImage() { if (string.IsNullOrEmpty(DocumentationImageUrl)) { string screenshotFileName; string skin = EditorGUIUtility.isProSkin?"Dark":"Light"; if (_Type == ItemTypes.Action) { screenshotFileName = _Name.Replace(".cs",".png"); DocumentationImageUrl = string.Format(__ActionScreenShotUrlFormat__,_RepositoryFullNamePath,skin,screenshotFileName); }else{ screenshotFileName = _Name.Replace("."+_Type.ToString().ToLower()+".txt",".png"); DocumentationImageUrl = string.Format(__PackageScreenShotUrlFormat__,_RepositoryFullNamePath,_FolderPath,skin,screenshotFileName); } DocumentationImageUrl = DocumentationImageUrl.Replace(" ","%20"); //Debug.Log(DocumentationImageUrl); } Debug.Log(_RepositoryFullNamePath); if (EcosystemBrowser.IsDebugOn) Debug.Log("LoadDocumentation for <"+Name+"> url:"+DocumentationImageUrl); DocumentationImageStatus = AsynchContentStatus.Downloading; WWW _www = new WWW(DocumentationImageUrl); while (!_www.isDone) yield return null; if (string.IsNullOrEmpty(_www.error)) { DocumentationImageStatus = AsynchContentStatus.Available; Texture2D _t2d= new Texture2D(2,2); _www.LoadImageIntoTexture(_t2d); DocumentationImage_Cache[DocumentationImageUrl] = _t2d as Texture; }else{ if (EcosystemBrowser.IsDebugOn) Debug.LogError("LoadDocumentation error for "+Name+" : "+_www.error); DocumentationImageStatus = AsynchContentStatus.Unavailable; } yield break; }
/// <summary> /// Loads the meta data. output will be in json within the item raw data or the metadata property. /// Process is Asynchrone /// </summary> IEnumerator LoadMetaData() { if (EcosystemBrowser.IsDebugOn) Debug.Log("LoadMetaData for <"+Name+">"); string url = GetUrl(urltypes.Raw); MetaDataStatus = AsynchContentStatus.Downloading; WWW _www = new WWW(url); while (!_www.isDone) yield return null; if (string.IsNullOrEmpty(_www.error)) { MetaDataStatus = AsynchContentStatus.Available; string jsonString = _www.text; bool canDecode = true; if (Type== ItemTypes.Action) { // we have to find the meta data within the script Match match = Regex.Match(jsonString,@"(?<=EcoMetaStart)[^>]*(?=EcoMetaEnd)",RegexOptions.IgnoreCase); // Here we check the Match instance. if (match.Success) { // Debug.Log("we have meta data :" + match.Value); jsonString = match.Value; }else{ canDecode = false; MetaDataStatus = AsynchContentStatus.Unavailable; } } if (canDecode) { if (EcosystemBrowser.IsDebugOn)Debug.Log("decode attempt for item"+Name+" from url <"+url+"> content:"+jsonString); try{ Hashtable _meta = (Hashtable)JSON.JsonDecode(jsonString); RawData["metaData"] = _meta; ProcessMetaData(); }catch(Exception e) { MetaDataStatus = AsynchContentStatus.Unavailable; if (EcosystemBrowser.IsDebugOn) Debug.LogError(e); if (EcosystemBrowser.IsDebugOn) Debug.LogError("could not decode json string for item"+Name+" from url <"+url+"> content:"+jsonString); } } }else{ if (EcosystemBrowser.IsDebugOn) Debug.LogError("LoadMetaData error for "+Name+" with url <"+url+"> : "+_www.error); MetaDataStatus = AsynchContentStatus.Unavailable; } yield break; }