static Texture2D LoadTextureInternalAsync(string imagePath, bool doMipMaps, int preloadWidth = 4, int preloadHeight = 4) { Texture2D resultTexture = null; IntPtr texture = UnityEngine.GameObject.Instantiate <Texture2D>(Texture2D.blackTexture).GetNativeTexturePtr(); if (texture != IntPtr.Zero) { lock (loadingTextures) { resultTexture = Texture2D.CreateExternalTexture(preloadWidth, preloadHeight, TextureFormat.RGBA32, doMipMaps, false, texture); loadingTextures.Add(texture, resultTexture); AssetStreaming streamTexture = new AssetStreaming(imagePath); streamTexture.GetWWWAsync((WWW wwwTexture) => { if (wwwTexture != null) { Texture2D result = null; if (loadingTextures.TryGetValue(texture, out result)) { loadingTextures.Remove(texture); if (result) { wwwTexture.LoadImageIntoTexture(result); } } wwwTexture.Dispose(); } else { loadingTextures.Remove(texture); } streamTexture.Unload(); }); } } return(resultTexture); }