Пример #1
0
        private async void Load()
        {
            if (string.IsNullOrEmpty(url))
            {
                return;
            }

            var   task = Cache.GetAsync(url);
            await task;

            if (!enabled || !gameObject.activeInHierarchy)
            {
                task.Result.Dispose();
                return;
            }

            if (cachedAsset != null)
            {
                Unload();
            }

            cachedAsset = task.Result;

            image.texture = cachedAsset.Asset;
            image.enabled = true;
        }
Пример #2
0
        private void Unload()
        {
            if (cachedAsset == null)
            {
                return;
            }

            cachedAsset.Dispose();
            cachedAsset = null;
        }