Exemplo n.º 1
0
        public IImageComponent SetMovieTexture(ResourceAuto resource, System.Action onDataLoaded, System.Action onComplete = null, System.Action onFailed = null)
        {
            this.flipVerticalInternal = MovieSystem.IsVerticalFlipped();
            this.SetVerticesDirty();

            this.Stop();
            this.SetImage(resource,
                          onDataLoaded: () => {
                if (onDataLoaded != null)
                {
                    onDataLoaded.Invoke();
                }
            },
                          onComplete: () => {
                //if (UnityEngine.UI.Windows.Constants.LOGS_ENABLED == true) UnityEngine.Debug.Log("SetMovieTexture: " + this.name);
                MovieSystem.UnregisterOnUpdateTexture(this.ValidateTexture);
                MovieSystem.RegisterOnUpdateTexture(this.ValidateTexture);
                if (onComplete != null)
                {
                    onComplete.Invoke();
                }
            },
                          onFailed: onFailed);

            return(this);
        }
Exemplo n.º 2
0
        private System.Collections.Generic.IEnumerator <byte> SetImage_INTERNAL(ResourceAuto resource, System.Action onDataLoaded = null, System.Action onComplete = null, System.Action onFailed = null)
        {
            yield return(0);

            if (this.imageCrossFadeModule.IsValid() == true)
            {
                this.imageCrossFadeModule.Prepare(this);
            }

            var oldResource = this.imageResource;
            var newResource = resource;

            this.imageResource = resource;

            // if (UnityEngine.UI.Windows.Constants.LOGS_ENABLED == true) UnityEngine.Debug.Log("Loading resource: " + this.imageResource.GetId());
            WindowSystemResources.Load(this,
                                       onDataLoaded: onDataLoaded,
                                       onComplete: () => {
                //if (UnityEngine.UI.Windows.Constants.LOGS_ENABLED == true) UnityEngine.Debug.Log("Resource loaded: " + newResource.GetId() + " :: " + this.name, this);
                if (newResource.GetId() != oldResource.GetId())
                {
                    // if (UnityEngine.UI.Windows.Constants.LOGS_ENABLED == true) UnityEngine.Debug.Log("Unloading: " + newResource.GetId() + " != " + oldResource.GetId() + " :: " + this.name, this);
                    WindowSystemResources.Unload(this, oldResource, resetController: false);
                }


                if (onComplete != null)
                {
                    onComplete.Invoke();
                }
            },
                                       onFailed: () => {
                //if (UnityEngine.UI.Windows.Constants.LOGS_ENABLED == true) UnityEngine.Debug.Log("Resource loading failed: " + newResource.GetId() + " :: " + this.name, this);
                if (newResource.GetId() != oldResource.GetId())
                {
                    //if (UnityEngine.UI.Windows.Constants.LOGS_ENABLED == true) UnityEngine.Debug.Log("Failed, Unloading: " + this.imageResource.GetId() + " != " + oldResource.GetId() + " :: " + this.name, this);
                    WindowSystemResources.Unload(this, oldResource, resetController: false);
                }

                if (onFailed != null)
                {
                    onFailed.Invoke();
                }
            }
                                       );
        }
Exemplo n.º 3
0
        public IImageComponent SetImage(UnityEngine.UI.Windows.Plugins.Localization.LocalizationKey key, params object[] parameters)
        {
            if (this.imageCrossFadeModule.IsValid() == true)
            {
                this.imageCrossFadeModule.Prepare(this);
            }

            this.lastImageLocalization           = true;
            this.lastImageLocalizationKey        = key;
            this.lastImageLocalizationParameters = parameters;

            this.SetImage(ResourceAuto.CreateResourceRequest(UnityEngine.UI.Windows.Plugins.Localization.LocalizationSystem.GetSpritePath(key, parameters)));

            //this.SetImage(UnityEngine.UI.Windows.Plugins.Localization.LocalizationSystem.GetSprite(key, parameters));
            //WindowSystemResources.Unload(this, this.GetResource());
            //WindowSystemResources.Load(this, onDataLoaded: null, onComplete: null, customResourcePath: UnityEngine.UI.Windows.Plugins.Localization.LocalizationSystem.GetSpritePath(key, parameters));

            return(this);
        }
        public static ResourceAuto GetResource(string groupName, string filename, string resourcesPathMask = "{0}", string webPathMask = null, string webPath = null, bool readable = true)
        {
            //if (UnityEngine.UI.Windows.Constants.LOGS_ENABLED == true) UnityEngine.Debug.Log("Load: " + groupName + " :: " + filename + " :: " + resourcesPathMask + " :: " + webPathMask);

            ResourceAuto resource = null;

            // Look up built-in storage
            if (resource == null)
            {
                var path = string.Format("{0}/{1}", groupName, string.Format(resourcesPathMask, filename));
                //if (UnityEngine.UI.Windows.Constants.LOGS_ENABLED == true) UnityEngine.Debug.Log("RES: " + path);
                if (UnityEngine.Resources.Load(path) != null)
                {
                    resource = ResourceAuto.CreateResourceRequest(path);
                }
            }

#if !UNITY_SWITCH
            // Look up cache storage
            if (resource == null)
            {
                var path = Utilities.GetCachePath(groupName, filename);
                if (File.Exists(path) == true)
                {
                    //if (UnityEngine.UI.Windows.Constants.LOGS_ENABLED == true) UnityEngine.Debug.Log("CCH: " + path);
                    resource = ResourceAuto.CreateWebRequest(path, readable: readable);
                }
            }
#endif

            // Create web request
            if (resource == null)
            {
                var path = (string.IsNullOrEmpty(webPath) == false ? webPath : string.Format(webPathMask, filename));
                //if (UnityEngine.UI.Windows.Constants.LOGS_ENABLED == true) UnityEngine.Debug.Log("WEB: " + path);
                resource = ResourceAuto.CreateWebRequest(path, readable: readable);
            }

            return(resource);
        }
Exemplo n.º 5
0
        public IImageComponent SetImage(ResourceAuto resource, System.Action onDataLoaded = null, System.Action onComplete = null, System.Action onFailed = null)
        {
            ME.Coroutines.Run(this.SetImage_INTERNAL(resource, onDataLoaded, onComplete, onFailed));

            return(this);
        }