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 } }
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(); } }); } }
public AssetRef(AssetRef src) { this.cdn = src.cdn; this.path = src.path; this.guid = src.guid; this.reference = src.reference; this.md5 = src.md5; }
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); }
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); } } }
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); } }
public void Add(AssetRef asset) { queue.Enqueue(asset); }
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)); }