Beispiel #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
     }
 }
Beispiel #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();
             }
         });
     }
 }
Beispiel #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;
 }
Beispiel #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);
 }
Beispiel #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);
         }
     }
 }
Beispiel #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);
     }
 }
Beispiel #7
0
 public void Add(AssetRef asset)
 {
     queue.Enqueue(asset);
 }
Beispiel #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));
 }