private void GetAsset(string id, AssetReferenceType assetReferenceType) { openTasks++; AssetService.Get(id, assetReferenceType) .SetCompletion(new OnCompletedHandler <Asset>(OnAssetGetComplete)) .Execute(client); }
protected virtual void Get(ReactContext context, AssetReferenceType realType, object realValue, Action <AssetType> callback) { switch (realType) { case AssetReferenceType.Resource: callback(Resources.Load(realValue as string, typeof(AssetType)) as AssetType); break; case AssetReferenceType.Global: callback(context.Globals.GetValueOrDefault(realValue as string) as AssetType); break; case AssetReferenceType.Object: callback(realValue as AssetType); break; case AssetReferenceType.File: case AssetReferenceType.Url: case AssetReferenceType.None: case AssetReferenceType.Procedural: case AssetReferenceType.Data: default: callback(null); break; } }
public AssetReference(string fromAssetPath, string toPath, int sourceLineNumber, AssetReferenceType type) { ValidatePath(toPath, type); ToPath = toPath; FromAssetPath = fromAssetPath; SourceLineNumber = sourceLineNumber; Type = type; }
public AssetReference(string path, IAsset sourceAsset, int sourceLineNumber, AssetReferenceType type) { ValidatePath(path, type); Path = path; SourceAsset = sourceAsset; SourceLineNumber = sourceLineNumber; Type = type; }
public AssetReference(string path, IAsset sourceAsset, int sourceLineNumber, AssetReferenceType type) { if (type != AssetReferenceType.Url && path.StartsWith("~") == false) { throw new ArgumentException("Referenced path must be application relative and start with a \"~\"."); } Path = path; SourceAsset = sourceAsset; SourceLineNumber = sourceLineNumber; Type = type; }
protected override void Get(ReactContext context, AssetReferenceType realType, object realValue, Action <Texture2D> callback) { if (realType == AssetReferenceType.Url) { webDeferred = new DisposableHandle(context.Dispatcher, context.Dispatcher.StartDeferred(GetTexture(realValue as string, callback))); } else if (realType == AssetReferenceType.Data) { var base64 = realValue as string; byte[] fileData = Convert.FromBase64String(base64); var texture = new Texture2D(1, 1); texture.LoadImage(fileData); callback(texture); } else if (realType == AssetReferenceType.File) { var filePath = realValue as string; Texture2D texture = null; byte[] fileData; if (File.Exists(filePath)) { fileData = File.ReadAllBytes(filePath); texture = new Texture2D(1, 1); texture.LoadImage(fileData); } callback(texture); } else if (realType == AssetReferenceType.Procedural) { var color = ParserMap.ColorConverter.Convert(realValue); if (color is Color c) { var t = new Texture2D(1, 1); t.SetPixel(0, 0, c); t.Apply(); callback(t); } else { callback(null); } } else { base.Get(context, realType, realValue, callback); } }
static void ValidatePath(string path, AssetReferenceType type) { if (type == AssetReferenceType.Url) { if (!path.IsUrl()) { throw new ArgumentException(string.Format("Referenced path must be a URL.Path: {0}", path), "path"); } } else { if (!path.StartsWith("~")) { throw new ArgumentException(string.Format("Referenced path must be application relative and start with a \"~\". Path: {0}", path), "path"); } } }
protected override void Get(ReactContext context, AssetReferenceType realType, object realValue, Action <TMP_FontAsset> callback) { if (realType == AssetReferenceType.Procedural) { if (context.FontFamilies.TryGetValue((realValue as string).ToLowerInvariant(), out var found)) { found.Get(context, callback); } else { callback(null); IsCached = false; } } else { base.Get(context, realType, realValue, callback); } }
protected override void Get(UnityUGUIContext context, AssetReferenceType realType, object realValue, Action <VideoComponentSource> callback) { if (realType == AssetReferenceType.Url) { callback(new VideoComponentSource() { Type = UnityEngine.Video.VideoSource.Url, Url = realValue as string }); } else if (realType == AssetReferenceType.File) { callback(new VideoComponentSource() { Type = UnityEngine.Video.VideoSource.Url, Url = "file://" + realValue as string }); } else { base.Get(context, realType, realValue, callback); } }
public VideoReference(AssetReferenceType type, object value) : base(type, value) { }
public ImageReference(AssetReferenceType type, object value) : base(type, value) { }
public AssetGetRequestBuilder(string id, AssetReferenceType assetReferenceType) : this() { this.Id = id; this.AssetReferenceType = assetReferenceType; }
public static AssetGetRequestBuilder Get(string id, AssetReferenceType assetReferenceType) { return(new AssetGetRequestBuilder(id, assetReferenceType)); }
public AssetReference(AssetReferenceType type, object value) { this.type = type; this.value = value; }
public AssetReference(AssetReferenceType type, JsValue value) { this.type = type; this.value = value; }