private void GetAsset(string id, AssetReferenceType assetReferenceType)
 {
     openTasks++;
     AssetService.Get(id, assetReferenceType)
     .SetCompletion(new OnCompletedHandler <Asset>(OnAssetGetComplete))
     .Execute(client);
 }
Exemplo n.º 2
0
        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;
            }
        }
Exemplo n.º 3
0
        public AssetReference(string fromAssetPath, string toPath, int sourceLineNumber, AssetReferenceType type)
        {
            ValidatePath(toPath, type);

            ToPath = toPath;
            FromAssetPath = fromAssetPath;
            SourceLineNumber = sourceLineNumber;
            Type = type;
        }
Exemplo n.º 4
0
        public AssetReference(string path, IAsset sourceAsset, int sourceLineNumber, AssetReferenceType type)
        {
            ValidatePath(path, type);

            Path = path;
            SourceAsset = sourceAsset;
            SourceLineNumber = sourceLineNumber;
            Type = type;
        }
Exemplo n.º 5
0
        public AssetReference(string path, IAsset sourceAsset, int sourceLineNumber, AssetReferenceType type)
        {
            ValidatePath(path, type);

            Path             = path;
            SourceAsset      = sourceAsset;
            SourceLineNumber = sourceLineNumber;
            Type             = type;
        }
Exemplo n.º 6
0
        public AssetReference(string fromAssetPath, string toPath, int sourceLineNumber, AssetReferenceType type)
        {
            ValidatePath(toPath, type);

            ToPath           = toPath;
            FromAssetPath    = fromAssetPath;
            SourceLineNumber = sourceLineNumber;
            Type             = type;
        }
Exemplo n.º 7
0
 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;
 }
Exemplo n.º 8
0
        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);
            }
        }
Exemplo n.º 9
0
 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");
         }
     }
 }
Exemplo n.º 10
0
 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");
         }
     }
 }
Exemplo n.º 11
0
 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);
     }
 }
Exemplo n.º 12
0
 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);
     }
 }
Exemplo n.º 13
0
 public VideoReference(AssetReferenceType type, object value) : base(type, value)
 {
 }
Exemplo n.º 14
0
 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));
 }
Exemplo n.º 17
0
 public AssetReference(AssetReferenceType type, object value)
 {
     this.type  = type;
     this.value = value;
 }
Exemplo n.º 18
0
 public AssetReference(AssetReferenceType type, JsValue value)
 {
     this.type  = type;
     this.value = value;
 }