Example #1
0
 public void SetTexture(int i)
 {
     if (textures.IsEmpty())
     {
         return;
     }
     if (Platform.isPlaying)
     {
         texLoader.Load(textures[i], null);
     }
     else
     {
         #if UNITY_EDITOR
         i = i.Clamp(0, textures.Count);
         if (texLoader.rend != null)
         {
             AssetRef r = textures[i];
             r.LoadAsset <Texture>(t =>
             {
                 texLoader.tex = t;
                 UnityEditor.SceneManagement.EditorSceneManager.MarkAllScenesDirty();
             });
         }
         #else
         texLoader.Load(textures[i], null);
         #endif
     }
 }
Example #2
0
 private void Load(AssetRef texRef, Material mat, string texName)
 {
     if (texRef.isEmpty)
     {
         count++;
         if (count == materials.Length * 2)
         {
             callback.Call();
         }
     }
     else
     {
         Cdn.cache.GetTexture(texRef.path, tex => {
             if (tex != null)
             {
                 mat.SetTexture(texName, tex);
             }
             count++;
             if (count == materials.Length * 2)
             {
                 callback.Call();
             }
         });
     }
 }
Example #3
0
 public AssetRef(AssetRef src)
 {
     this.cdn       = src.cdn;
     this.path      = src.path;
     this.guid      = src.guid;
     this.reference = src.reference;
     this.md5       = src.md5;
 }
Example #4
0
 public override bool Equals(object o)
 {
     if (this == o)
     {
         return(true);
     }
     if (o is AssetRef)
     {
         AssetRef that = o as AssetRef;
         return(this.cdn == that.cdn && this.path == that.path);
     }
     return(false);
 }
Example #5
0
 public void Load(AssetRef asset, Action <Texture> callback)
 {
     if (rend != null && !asset.isEmpty)
     {
         if (asset.cdn)
         {
             Load(asset.path, callback);
         }
         else if (asset.GetReference() != null)
         {
             this.loadedCallback = callback;
             SetTexture(asset.GetReference() as Texture);
         }
     }
 }
Example #6
0
 public static string GetEditorPath(this AssetRef r)
 {
     if (!r.guid.IsEmpty())
     {
         string path = AssetDatabase.GUIDToAssetPath(r.guid);
         if (!path.IsEmpty())
         {
             return(path);
         }
     }
     if (!r.path.IsEmpty())
     {
         return("Assets/" + r.path);
     }
     else
     {
         return(string.Empty);
     }
 }
Example #7
0
 public void Add(AssetRef asset)
 {
     queue.Enqueue(asset);
 }
Example #8
0
 public static void SetPath(this AssetRef r, Object o)
 {
     r.path = GetPath(o);
     r.cdn  = AssetBundlePath.inst.IsRawCdnAsset(o);
     r.guid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(o));
 }