예제 #1
0
        private void LoadAndSetup_INTERNAL <T>(IImageComponent image, Graphic graphic, System.Action <T> callbackOnLoad, string customResourcePath = null) where T : Object
        {
            //var key = (image as WindowComponent).GetInstanceID();

            //Coroutine coroutine;

            /*if (this.loading.TryGetValue(key, out coroutine) == true) {
             *
             *      this.StopCoroutine(coroutine);
             *      this.loading.Remove(key);
             *
             * }*/

            /*this.loaded.ForEach(z => { z.references.Remove(image as WindowComponent); });
             * this.loaded.RemoveAll(x => {
             *
             *      if (x.references.Count == 0) {
             *
             *              //if (x.loadedObjectId < 0) Object.Destroy(x.loadedObject);
             *              return true;
             *
             *      }
             *
             *      return false;
             *
             * });*/

            Item item;

            if (this.IsLoaded <T>(image as WindowComponent, image.GetResource(), out item, callbackOnLoad) == false)
            {
                /*coroutine = */ this.StartCoroutine(image.GetResource().Load <T>(image, graphic, customResourcePath, (data) => {
                    if (data == null)
                    {
                        WindowSystemLogger.Error(image, string.Format("Error in ResourcesManager: Required resource can't loaded. Resource: {0}", image.GetResource().GetId()));
                        return;
                    }

                    item.@object = data;

                    item.loadedObject   = data;
                    item.loadedObjectId = data.GetInstanceID();
                    item.loaded         = true;

                    if (item.onObjectLoaded != null)
                    {
                        item.onObjectLoaded.Invoke();
                    }
                    callbackOnLoad(data);

                    //this.loading.Remove(key);
                }));

                //this.loading.Add(key, coroutine);
            }
        }
예제 #2
0
        public void Play(IImageComponent component, bool loop, bool pause, System.Action onComplete)
        {
            var resource = component.GetResource();

            if (resource.loaded == false)
            {
                if (UnityEngine.UI.Windows.Constants.LOGS_ENABLED == true)
                {
                    UnityEngine.Debug.LogWarning("Resource was not loaded yet. Play interrupted.", component as MonoBehaviour);
                }
                return;
            }

            var item  = this.GetMovieItem(component, resource);
            var movie = resource.loadedObject as Texture;

            if (item.state != MovieItem.State.Playing)
            {
                item.state = MovieItem.State.Playing;
                this.OnPlay(resource, movie, loop, onComplete);
            }

            if (pause == true || MovieSystem.CanPlayByQuality(movie) == false)
            {
                this.StartCoroutine(this.PauseWithDelay_YIELD(component, this.delayToPause));
            }
        }
        public void Pause(IImageComponent component)
        {
            //var image = component.GetRawImageSource();
            //if (image == null) return;

            var resource = component.GetResource();

            if (resource.loaded == false)
            {
                Debug.LogWarning("Resource was not loaded yet. Pause interrupted.", component as MonoBehaviour);
                return;
            }

            var movie = resource.loadedObject as Texture;

            var item = this.current.FirstOrDefault(x => x.id == resource.GetId());

            if (item != null)
            {
                //item.components.Remove(component as WindowComponent);

                //if (item.components.Count == 0) {

                if (item.state != MovieItem.State.Paused)
                {
                    item.state = MovieItem.State.Paused;
                    this.OnPause(resource, movie);
                }

                //}
            }
        }
        public bool IsPlaying(IImageComponent component)
        {
            //var image = component.GetRawImageSource();
            //if (image == null) return false;

            var resource = component.GetResource();

            if (resource.loaded == false)
            {
                Debug.LogWarning("Resource was not loaded yet. IsPlaying returns false.", component as MonoBehaviour);
                return(false);
            }

            var movie = resource.loadedObject as Texture;

            return(this.IsPlaying(component.GetResource(), movie));
        }
예제 #5
0
        public ResourceAsyncOperation LoadTexture(IImageComponent component)
        {
            var request = new ResourceAsyncOperation();

            this.StartCoroutine(this.LoadTexture_YIELD(request, component, component.GetResource()));

            return(request);
        }
예제 #6
0
		public ResourceAsyncOperation LoadTexture(IImageComponent component) {

			var request = new ResourceAsyncOperation();
			this.StartCoroutine(this.LoadTexture_YIELD(request, component, component.GetResource()));

			return request;

		}
예제 #7
0
        public bool IsPlaying(IImageComponent component)
        {
            //var image = component.GetRawImageSource();
            //if (image == null) return false;

            var resource = component.GetResource();

            if (resource.loaded == false)
            {
                //if (UnityEngine.UI.Windows.Constants.LOGS_ENABLED == true) UnityEngine.Debug.LogWarning("Resource was not loaded yet. IsPlaying returns false.", component as MonoBehaviour);
                return(false);
            }

            var movie = resource.loadedObject as Texture;

            return(this.IsPlaying(component.GetResource(), movie));
        }
예제 #8
0
        public void Play(IImageComponent component, bool loop, bool pause)
        {
            var image = component.GetRawImageSource();

            if (image == null)
            {
                return;
            }

            var resource = component.GetResource();

            if (resource.loaded == false)
            {
                Debug.LogWarning("Resource was not loaded yet. Play interrupted.", component as MonoBehaviour);
                return;
            }

            var movie = resource.loadedObject as Texture;

            var item = this.current.FirstOrDefault(x => x.id == resource.GetId());

            if (item != null)
            {
                var c = component as WindowComponent;
                if (item.components.Contains(c) == false)
                {
                    item.components.Add(c);
                }
            }
            else
            {
                item = new Item()
                {
                    id         = resource.GetId(),
                    components = new List <WindowComponent>()
                    {
                        component as WindowComponent
                    },
                    loadedObject   = resource.loadedObject,
                    loadedObjectId = resource.loadedObjectId,
                };

                this.current.Add(item);
            }

            if (item.state != Item.State.Playing)
            {
                item.state = Item.State.Playing;
                this.OnPlay(resource, movie, loop);
            }

            if (pause == true || MovieSystem.CanPlayByQuality(movie) == false)
            {
                this.StartCoroutine(this.PauseWithDelay_YIELD(component, this.delayToPause));
            }
        }
예제 #9
0
        public bool IsPlaying(IImageComponent component)
        {
            var image = component.GetRawImageSource();

            if (image == null)
            {
                return(false);
            }

            return(this.IsPlaying(component.GetResource(), image.mainTexture));
        }
        protected System.Collections.Generic.IEnumerator <byte> PauseWithDelay_YIELD(IImageComponent component, Texture movie, float delay, System.Action <ResourceBase, Texture> callback)
        {
            var timer = 0f;

            while (timer < delay)
            {
                timer += Time.unscaledDeltaTime;
                yield return(0);
            }

            yield return(0);

            callback.Invoke(component.GetResource(), movie);
        }
예제 #11
0
        public void Stop(IImageComponent component, int instanceId = 0)
        {
            var resource = component.GetResource();

            if (resource.loaded == false)
            {
                if (UnityEngine.UI.Windows.Constants.LOGS_ENABLED == true)
                {
                    UnityEngine.Debug.LogWarning("Resource was not loaded yet. Stop interrupted.", component as MonoBehaviour);
                }
                return;
            }

            var item = this.current.FirstOrDefault(x => {
                if (instanceId != 0)
                {
                    return((x.resource.loadedObject as Object).GetID() == instanceId);
                }
                else
                {
                    return(x.id == resource.GetId());
                }
            });

            if (item != null)
            {
                //if (UnityEngine.UI.Windows.Constants.LOGS_ENABLED == true) UnityEngine.Debug.Log("Stop: " + item.id + " :: " + instanceId + " :: " + item.components.Count + " :: " + (component as MonoBehaviour), component as MonoBehaviour);
                //if (WindowSystemResources.Remove(item.resource, component as WindowComponent) == true) {

                if (item.components != null && item.components.Count == 0)
                {
                    if (item.state != MovieItem.State.Stopped)
                    {
                        item.state = MovieItem.State.Stopped;

                        var movie = resource.loadedObject as Texture;
                        this.OnStop(resource, movie);

                        //this.current.RemoveAll(x => x.id == item.id);
                    }
                }

                //}
            }
        }
        public void Rewind(IImageComponent component, bool pause)
        {
            var resource = component.GetResource();

            if (resource.loaded == false)
            {
                Debug.LogWarning("Resource was not loaded yet. Rewind interrupted.", component as MonoBehaviour);
                return;
            }

            var item = this.GetMovieItem(component, resource);

            item.state = (pause == true) ? MovieItem.State.Paused : MovieItem.State.Playing;

            var movie = resource.loadedObject as Texture;

            this.OnRewind(resource, movie, pause);
        }
        public ResourceAsyncOperation LoadTexture(IImageComponent component)
        {
            /*if (this.IsMaterialLoadingType() == true) {
             *
             * } else {
             *
             *      MovieSystem.UnregisterOnUpdateTexture(this.ValidateTexture);
             *      MovieSystem.RegisterOnUpdateTexture(this.ValidateTexture);
             *
             * }*/

            var request   = new ResourceAsyncOperation();
            var resource  = component.GetResource();
            var movieItem = this.GetMovieItem(component, resource);

            this.StartCoroutine(this.LoadTexture_YIELD(request, component, movieItem, resource));

            return(request);
        }
예제 #14
0
        public void Stop(IImageComponent component)
        {
            var image = component.GetRawImageSource();

            if (image == null)
            {
                return;
            }

            var resource = component.GetResource();

            if (resource.loaded == false)
            {
                //Debug.LogWarning("Resource was not loaded yet. Stop interrupted.", component as MonoBehaviour);
                return;
            }

            var movie = resource.loadedObject as Texture;

            var item = this.current.FirstOrDefault(x => x.id == resource.GetId());

            if (item != null)
            {
                item.components.Remove(component as WindowComponent);

                if (item.components.Count == 0)
                {
                    if (item.state != Item.State.Stopped)
                    {
                        item.state = Item.State.Stopped;
                        this.OnStop(resource, movie);

                        this.current.RemoveAll(x => x.id == item.id);
                    }
                }
            }
        }
예제 #15
0
		protected IEnumerator PauseWithDelay_YIELD(IImageComponent component, Texture movie, float delay, System.Action<ResourceBase, Texture> callback) {
			
			var timer = 0f;
			while (timer < delay) {
				
				timer += Time.unscaledDeltaTime;
				yield return false;
				
			}
			
			yield return false;

			callback.Invoke(component.GetResource(), movie);
			
		}
예제 #16
0
		public bool IsPlaying(IImageComponent component) {
			
			var image = component.GetRawImageSource();
			if (image == null) return false;
			
			return this.IsPlaying(component.GetResource(), image.mainTexture);
			
		}
예제 #17
0
		public void Pause(IImageComponent component) {
			
			var image = component.GetRawImageSource();
			if (image == null) return;
			
			var resource = component.GetResource();
			if (resource.loaded == false) {
				
				Debug.LogWarning("Resource was not loaded yet. Pause interrupted.", component as MonoBehaviour);
				return;
				
			}
			
			var movie = resource.loadedObject as Texture;

			var item = this.current.FirstOrDefault(x => x.id == resource.GetId());
			if (item != null) {
				
				//item.components.Remove(component as WindowComponent);

				//if (item.components.Count == 0) {

					if (item.state != Item.State.Paused) {
						
						item.state = Item.State.Paused;
						this.OnPause(resource, movie);
						
					}
					
				//}

			}

		}
예제 #18
0
		public void Play(IImageComponent component, bool loop, bool pause) {
			
			var image = component.GetRawImageSource();
			if (image == null) return;

			var resource = component.GetResource();
			if (resource.loaded == false) {

				Debug.LogWarning("Resource was not loaded yet. Play interrupted.", component as MonoBehaviour);
				return;

			}

			var movie = resource.loadedObject as Texture;

			var item = this.current.FirstOrDefault(x => x.id == resource.GetId());
			if (item != null) {
				
				var c = component as WindowComponent;
				if (item.components.Contains(c) == false) {

					item.components.Add(c);

				}

			} else {

				item = new Item() {

					id = resource.GetId(),
					components = new List<WindowComponent>() { component as WindowComponent },
					loadedObject = resource.loadedObject,
					loadedObjectId = resource.loadedObjectId,

				};

				this.current.Add(item);
				
			}

			if (item.state != Item.State.Playing) {

				item.state = Item.State.Playing;
				this.OnPlay(resource, movie, loop);

			}
			
			if (pause == true || MovieSystem.CanPlayByQuality(movie) == false) {
				
				this.StartCoroutine(this.PauseWithDelay_YIELD(component, this.delayToPause));
				
			}

		}