Example #1
0
 public void Add(WindowComponentBase component, HistoryTrackerEventType eventType)
 {
     if (WindowSystemLogger.IsActiveComponents() == true)
     {
         var stack = new StackTrace();
         this.items.Add(new Item(stack.GetFrames(), eventType));
     }
 }
Example #2
0
 public void Add(WindowObject component, AppearanceParameters parameters, HistoryTrackerEventType eventType)
 {
     if (WindowSystemLogger.IsActiveComponents() == true)
     {
         var stack = new StackTrace();
         this.items.Add(new Item(stack.GetFrames(), parameters, eventType));
     }
 }
Example #3
0
        private void LoadAuto_INTERNAL(ILoadableResource resourceController, System.Action onDataLoaded, System.Action onComplete, string customResourcePath = null)
        {
            var image = resourceController as IImageComponent;

            System.Action <Object> setup = (data) => {
                if (data == null)
                {
                    WindowSystemLogger.Error(image, string.Format("Error in ResourcesManager: Required resource can't be loaded. Resource: {0}", image.GetResource().GetId()));
                    return;
                }

                var res = resourceController.GetResource();
                res.loadedObject   = data;
                res.loadedObjectId = data.GetInstanceID();
                res.loaded         = true;
            };

            Graphic source = image.GetImageSource();

            if (source != null)
            {
                this.LoadAndSetup_INTERNAL <Sprite>(image, source, (data) => {
                    setup.Invoke(data);
                    image.SetImage(data, () => {
                        if (onComplete != null)
                        {
                            onComplete.Invoke();
                        }
                    });

                    if (onDataLoaded != null)
                    {
                        onDataLoaded.Invoke();
                    }
                }, customResourcePath);
            }
            else
            {
                source = image.GetRawImageSource();
                if (source != null)
                {
                    this.LoadAndSetup_INTERNAL <Texture>(image, source, (data) => {
                        setup.Invoke(data);
                        image.SetImage(data, () => {
                            if (onComplete != null)
                            {
                                onComplete.Invoke();
                            }
                        });

                        if (onDataLoaded != null)
                        {
                            onDataLoaded.Invoke();
                        }
                    }, customResourcePath);
                }
            }
        }
Example #4
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);
            }
        }
        public void Awake()
        {
            this.logger = new Logger()
            {
                enabled =
                    (Application.isEditor == true && (this.textLogs & ActiveType.InEditor) != 0) ||
                    (Application.isEditor == false && (this.textLogs & ActiveType.InBuild) != 0)
            };

            WindowSystemLogger.instance = this;
        }
        public void Awake()
        {
            this.logger = new Logger()
            {
                enabled =
                    (Application.isEditor == true && (this.textLogs & ActiveType.InEditor) != 0) ||
                    (Application.isEditor == false && (this.textLogs & ActiveType.InBuild) != 0)
            };

            if (UnityEngine.UI.Windows.Constants.LOGS_ENABLED == true)
            {
                UnityEngine.Debug.unityLogger.filterLogType = this.filterLogType;
            }
            if (UnityEngine.UI.Windows.Constants.LOGS_ENABLED == true)
            {
                UnityEngine.Debug.unityLogger.logEnabled = this.loggerEnabled;
            }

            WindowSystemLogger.instance = this;
        }
Example #7
0
 protected virtual void OnDestory()
 {
     WindowSystemLogger.instance = null;
 }
Example #8
0
        /// <summary>
        /// Registers the sub component.
        /// If you want to instantiate a new component manualy but wants window events - register this component here.
        /// </summary>
        /// <param name="subComponent">Sub component.</param>
        public virtual void RegisterSubComponent(WindowObjectElement subComponent)
        {
            //Debug.Log("TRY REGISTER: " + subComponent + " :: " + this.GetComponentState() + "/" + subComponent.GetComponentState(), this);
            if (this.subComponents.Contains(subComponent) == false)
            {
                subComponent.rootComponent = this;
                this.subComponents.Add(subComponent);
            }
            else
            {
                WindowSystemLogger.Warning(this, "RegisterSubComponent can't complete because of duplicate item.");
                return;
            }

                        #if UNITY_EDITOR
            if (Application.isPlaying == false)
            {
                return;
            }
                        #endif

            var controller = (subComponent as IWindowEventsController);
            subComponent.DoLoad(async: false, onItem: null, callback: () => {
                switch (this.GetComponentState())
                {
                case WindowObjectState.Hiding:

                    if (subComponent.GetComponentState() == WindowObjectState.NotInitialized)
                    {
                        controller.DoInit();
                        WindowSystem.RunSafe(subComponent.OnWindowActive);
                    }

                    subComponent.SetComponentState(this.GetComponentState());

                    break;

                case WindowObjectState.Hidden:

                    if (subComponent.GetComponentState() == WindowObjectState.NotInitialized)
                    {
                        controller.DoInit();
                        WindowSystem.RunSafe(subComponent.OnWindowActive);
                    }

                    subComponent.SetComponentState(this.GetComponentState());

                    break;

                case WindowObjectState.Initializing:
                case WindowObjectState.Initialized:

                    if (subComponent.GetComponentState() == WindowObjectState.NotInitialized)
                    {
                        controller.DoInit();
                        WindowSystem.RunSafe(subComponent.OnWindowActive);
                    }

                    break;

                case WindowObjectState.Showing:

                    // after OnShowBegin

                    if (subComponent.GetComponentState() == WindowObjectState.NotInitialized)
                    {
                        controller.DoInit();
                        WindowSystem.RunSafe(subComponent.OnWindowActive);
                    }

                    if (subComponent.showOnStart == true)
                    {
                        controller.DoShowBegin(AppearanceParameters.Default());
                    }

                    break;

                case WindowObjectState.Shown:

                    // after OnShowEnd

                    if (subComponent.GetComponentState() == WindowObjectState.NotInitialized)
                    {
                        controller.DoInit();
                        WindowSystem.RunSafe(subComponent.OnWindowActive);
                    }

                    if (subComponent.showOnStart == true)
                    {
                        controller.DoShowBegin(AppearanceParameters.Default().ReplaceCallback(() => {
                            controller.DoShowEnd(AppearanceParameters.Default());
                        }));
                    }

                    break;
                }

                if (this.GetWindow() != null)
                {
                    subComponent.Setup(this.GetWindow());
                    // subComponent.Setup(this.GetLayoutRoot());
                }
            });
        }
Example #9
0
        private void LoadAuto_INTERNAL(ILoadableResource resourceController, System.Action onDataLoaded, System.Action onComplete, System.Action onFailed = null, string customResourcePath = null)
        {
            var image = resourceController as IImageComponent;
            var async = image.GetResource().async;

            System.Action <Object> setup = (data) => {
                if (data == null)
                {
                    if (onFailed != null)
                    {
                        onFailed.Invoke();
                    }
                    WindowSystemLogger.Error(image, string.Format("Error in ResourcesManager: Required resource can't be loaded. Resource: {0}", image.GetResource().GetId()));
                    return;
                }
            };

            var source = image.GetGraphicSource();

            var isMaterial = image.GetResource().IsMaterialLoadingType();

            if (isMaterial == false)
            {
                MovieSystem.UnregisterOnUpdateTexture(this.ValidateTexture);
            }

            if (isMaterial == true)
            {
                this.LoadRefCounter_INTERNAL <Material>(resourceController, (data) => {
                    setup.Invoke(data);
                    image.SetMaterial(data, callback: () => {
                        if (onComplete != null)
                        {
                            onComplete.Invoke();
                        }
                    });

                    if (onDataLoaded != null)
                    {
                        onDataLoaded.Invoke();
                    }
                }, onFailed, async, customResourcePath);
            }
            else
            {
                if (source is Image)
                {
                    this.LoadRefCounter_INTERNAL <Sprite>(resourceController, (data) => {
                        setup.Invoke(data);
                        image.SetImage(data, () => {
                            if (onComplete != null)
                            {
                                onComplete.Invoke();
                            }
                        });

                        if (onDataLoaded != null)
                        {
                            onDataLoaded.Invoke();
                        }
                    }, onFailed, async, customResourcePath);
                }
                else if (source is RawImage)
                {
                    this.LoadRefCounter_INTERNAL <Texture>(resourceController, (data) => {
                        setup.Invoke(data);
                        image.SetImage(data, () => {
                            if (onComplete != null)
                            {
                                onComplete.Invoke();
                            }
                        });

                        if (isMaterial == true)
                        {
                            MovieSystem.RegisterOnUpdateTexture(this.ValidateTexture);
                        }

                        if (onDataLoaded != null)
                        {
                            onDataLoaded.Invoke();
                        }
                    }, onFailed, async, customResourcePath);
                }
            }
        }
		public void Awake() {

			this.logger = new Logger() {
				enabled = 
					(Application.isEditor == true && (this.textLogs & ActiveType.InEditor) != 0) ||
					(Application.isEditor == false && (this.textLogs & ActiveType.InBuild) != 0)
			};

			WindowSystemLogger.instance = this;

		}
Example #11
0
        /// <summary>
        /// Registers the sub component.
        /// If you want to instantiate a new component manualy but wants window events - register this component here.
        /// </summary>
        /// <param name="subComponent">Sub component.</param>
        public virtual void RegisterSubComponent(WindowObjectElement subComponent)
        {
            //Debug.Log("TRY REGISTER: " + subComponent + " :: " + this.GetComponentState() + "/" + subComponent.GetComponentState(), this);
            if (this.subComponents.Contains(subComponent) == false)
            {
                this.subComponents.Add(subComponent);
            }
            else
            {
                WindowSystemLogger.Warning(this, "RegisterSubComponent can't complete because of duplicate item.");
                return;
            }

            switch (this.GetComponentState())
            {
            case WindowObjectState.Hiding:

                if (subComponent.GetComponentState() == WindowObjectState.NotInitialized)
                {
                    subComponent.DoInit();
                }

                subComponent.SetComponentState(this.GetComponentState());

                break;

            case WindowObjectState.Hidden:

                if (subComponent.GetComponentState() == WindowObjectState.NotInitialized)
                {
                    subComponent.DoInit();
                }

                subComponent.SetComponentState(this.GetComponentState());

                break;

            case WindowObjectState.Initializing:
            case WindowObjectState.Initialized:

                if (subComponent.GetComponentState() == WindowObjectState.NotInitialized)
                {
                    subComponent.DoInit();
                }

                break;

            case WindowObjectState.Showing:

                // after OnShowBegin

                if (subComponent.GetComponentState() == WindowObjectState.NotInitialized)
                {
                    subComponent.DoInit();
                }

                if (subComponent.showOnStart == true)
                {
                    subComponent.DoShowBegin(AppearanceParameters.Default());
                }

                break;

            case WindowObjectState.Shown:

                // after OnShowEnd

                if (subComponent.GetComponentState() == WindowObjectState.NotInitialized)
                {
                    subComponent.DoInit();
                }

                if (subComponent.showOnStart == true)
                {
                    subComponent.DoShowBegin(AppearanceParameters.Default().ReplaceCallback(() => {
                        subComponent.DoShowEnd(AppearanceParameters.Default());
                    }));
                }

                break;
            }

            if (this.GetWindow() != null)
            {
                subComponent.Setup(this.GetWindow());
                // subComponent.Setup(this.GetLayoutRoot());
            }
        }