Example #1
0
        public CdnAssetLoaderApi(MonoBehaviour monoBehaviour, Game game = Game.None, bool tryPersistentData = true)
        {
            streamingAssetStorage = new StreamingAssetsStorage(game, monoBehaviour);
#if !SKU_CHINA && (!UNITY_EDITOR || CDN_ENABLE_IN_UNITY_EDITOR)
            if (tryPersistentData)
            {
                persistentDataStorage = new PersistentDataStorage(game);
            }
#endif
        }
Example #2
0
        private void loadFlagImage(string path)
        {
            byte[] bytes = null;

            PersistentDataStorage persistentDataStorage = new PersistentDataStorage(Game.ForceVision);

            if (persistentDataStorage.FileExists(path))
            {
                bytes = persistentDataStorage.LoadBytes(path);
            }
            else
            {
                StreamingAssetsStorage streamingAssetsStorage = new StreamingAssetsStorage(Game.ForceVision, this);
                streamingAssetsStorage.LoadStreamingAssetsFile(path, (success, loadedBytes) =>
                {
                    if (string.IsNullOrEmpty(success))
                    {
                        bytes = loadedBytes;
                    }
                    else
                    {
                        Log.Error("No image flag found for " + path);
                    }
                }, true);
            }

            if (bytes != null && bytes.Length > 0)
            {
                Texture2D flagTexture = new Texture2D(4, 4);
                bool      isLoaded    = flagTexture.LoadImage(bytes);
                if (isLoaded)
                {
                    Flag.sprite = Sprite.Create(flagTexture, new Rect(0, 0, flagTexture.width, flagTexture.height), new Vector2(0, 0));
                }
            }
        }
Example #3
0
        public Config()
        {
            var loader = new StreamingAssetsStorage(Game.ForceVision, null);

            loader.LoadStreamingAssetsFile(DefaultConfigFile, OnConfigLoaded, true);
        }