IEnumerator ParseSVGAssetProgress(string svgText) { yield return(new WaitForEndOfFrame()); yield return(StartCoroutine(SVGAsset.Load(svgText, _svgAssets, null, this._sliceLayerNum))); hudLayer.hideLoading(); for (int i = 1; i < _svgAssets.Count; i++) { GameObject svgGameObject = null; if (previewPool.Count > 0) { svgGameObject = previewPool[0]; svgGameObject.transform.parent = contentLayer.transform; svgGameObject.transform.position = svgPreview.transform.position; previewPool.RemoveAt(0); } if (svgGameObject == null) { svgGameObject = Instantiate(svgPreview.gameObject, svgPreview.transform.position, svgPreview.transform.rotation, contentLayer.transform); } svgGameObject.GetComponent <SVGRenderer>().vectorGraphics = _svgAssets[i]; yield return(new WaitForEndOfFrame()); } svgPreview.vectorGraphics = _svgAssets[0]; if (onGameMapChanged != null) { onGameMapChanged(this); } }
public void Load() { if (svgInput == null || string.IsNullOrEmpty(svgInput.text)) { return; } if (svgAsset != null) { Destroy(svgAsset); } svgAsset = SVGAsset.Load(svgInput.text); //preview.vectorGraphics = svgAsset; }
public static bool Prefix(ResourceLoadRequest <SVGAsset> __instance) { //RLog.M.TWL(0, "SVGAssetLoadRequest.Load "+__instance.ManifestEntry.Name); //return true; ResourceLoadRequest_Load(__instance);//base.Load(); if (__instance.State != DataManager.FileLoadRequest.RequestState.Requested) { return(false); } __instance.State(DataManager.FileLoadRequest.RequestState.Processing); __instance.StartTimeoutTracking(0.0f); if (__instance.ManifestEntry.IsAssetBundled) { __instance.dataManager().AssetBundleManager().RequestAsset <SVGAsset>(BattleTechResourceType.SVGAsset, __instance.ResourceId, new Action <SVGAsset>( (SVGAsset resource) => { SVGAssetLoadRequest.GetMethod("AssetLoaded", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(__instance, new object[] { resource }); } )); } else { if (!__instance.ManifestEntry.IsResourcesAsset) { try { SVGAsset resource = SVGAsset.Load(File.ReadAllText(__instance.ManifestEntry.FilePath)); if (resource == null) { throw new NullReferenceException("Fail to load SVG file"); } SVGAssetLoadRequest.GetMethod("AssetLoaded", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(__instance, new object[] { resource }); RLog.M.WL(1, "Loaded from external file:" + __instance.ManifestEntry.FilePath); }catch (Exception e) { RLog.M.TWL(0, "Fail to load external file:" + __instance.ManifestEntry.FilePath); RLog.M.WL(0, e.ToString()); throw new ArgumentNullException("THIS IS !NOT! I REPEAT, !NOT! MODTEK ERROR. YOUR SVG FILE FAIL TO LOAD! More info in ModTek_runtime_log.txt"); } return(false); } __instance.dataManager().RequestResourcesLoad_SVGAsset(__instance.ManifestEntry.ResourcesLoadPath, new Action <SVGAsset>( (SVGAsset resource) => { SVGAssetLoadRequest.GetMethod("AssetLoaded", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(__instance, new object[] { resource }); } )); } return(false); }
public void Load() { // if(svgInput == null || string.IsNullOrEmpty(svgInput.text)) return; // if(svgAsset != null) // { // Destroy(svgAsset[0]); // } svgAsset = new List <SVGAsset>(); StartCoroutine(SVGAsset.Load(TxtFile.text, svgAsset, null, 100)); Debug.Log("load svg asset count: " + svgAsset.Count); for (int i = 1; i < svgAsset.Count; i++) { SVGImage newSVGImage = Instantiate(preview, preview.transform.position, preview.transform.rotation, preview.transform.parent); newSVGImage.vectorGraphics = svgAsset[i]; } preview.vectorGraphics = svgAsset[0]; }
internal static void LoadIcons(Dictionary <string, VersionManifestEntry> icons_ressourses) { Control.LogDebug(DType.Icons, $"Get data:"); foreach (var pair in icons_ressourses) { Control.LogDebug(DType.Icons, $"- {pair.Key}: {pair.Value.FileName} {pair.Value.FilePath} {pair.Value.Name}"); try { using (var reader = new StreamReader(pair.Value.FilePath)) { var txt = reader.ReadToEnd(); var icon = SVGAsset.Load(txt); icons["@" + pair.Key] = icon; } } catch (Exception e) { Control.LogError(e); } } }