コード例 #1
0
        public override bool FindAllComponents()
        {
            try
            {
                #region Canvas
                var canvasGameObject = gameObject.GetComponentInChildren <Canvas>()?.gameObject;

                if (canvasGameObject == null)
                {
                    throw new MissingComponentException($"A component cant be found.\nMissing Component: Canvas");
                }
                #endregion

                #region Home Page
                var home = InterfaceHelpers.FindGameObject(canvasGameObject, "HomePage");
                #endregion

                #region Filter Page
                var filterPage = InterfaceHelpers.FindGameObject(canvasGameObject, "FilterPage");
                #endregion

                #region Category Page
                var categoryPage = InterfaceHelpers.FindGameObject(canvasGameObject, "CategoryPage");
                #endregion

                #region Item Page
                var itemPage = InterfaceHelpers.FindGameObject(canvasGameObject, "ItemPage");
                #endregion

                #region Filter Grid

                _filterGrid = _mono.gameObject.AddComponent <GridHelper>();
                _filterGrid.OnLoadDisplay += OnLoadFilterGrid;
                _filterGrid.Setup(3, DSSModelPrefab.FilterItemPrefab, filterPage, _startColor, _hoverColor, OnButtonClick); //Minus 1 ItemPerPage because of the added Home button

                #endregion

                #region Item Grid

                _itemGrid = _mono.gameObject.AddComponent <GridHelper>();
                _itemGrid.OnLoadDisplay += OnLoadItemsGrid;
                _itemGrid.Setup(3, DSSModelPrefab.FilterItemPrefab, itemPage, _startColor, _hoverColor, OnButtonClick); //Minus 1 ItemPerPage because of the added Home button

                #endregion

                #region Category Grid

                _categoryGrid = _mono.gameObject.AddComponent <GridHelper>();
                _categoryGrid.OnLoadDisplay += OnLoadCategoryGrid;
                _categoryGrid.Setup(3, DSSModelPrefab.FilterItemPrefab, categoryPage, _startColor, _hoverColor, OnButtonClick); //Minus 1 ItemPerPage because of the added Home button

                #endregion

                #region Remove Server
                var removeServerBTN = InterfaceHelpers.FindGameObject(filterPage, "RemoveServerBTN");

                InterfaceHelpers.CreateButton(removeServerBTN, "RemoveServerBTN", InterfaceButtonMode.Background,
                                              OnButtonClick, _startColor, _hoverColor, MAX_INTERACTION_DISTANCE, AuxPatchers.RemoveServer());
                #endregion

                #region Add Server
                var addServerBTN = InterfaceHelpers.FindGameObject(home, "AddServerBTN");

                InterfaceHelpers.CreateButton(addServerBTN, "AddServerBTN", InterfaceButtonMode.Background,
                                              OnButtonClick, _startColor, _hoverColor, MAX_INTERACTION_DISTANCE, AuxPatchers.InsertServer());
                #endregion

                #region AddItemBTN
                var itemPageBTN = InterfaceHelpers.FindGameObject(filterPage, "AddItemBTN");

                InterfaceHelpers.CreateButton(itemPageBTN, "AddItemBTN", InterfaceButtonMode.Background,
                                              OnButtonClick, _startColor, _hoverColor, MAX_INTERACTION_DISTANCE, AuxPatchers.AddFilterItem());
                #endregion

                #region AddCategoryBTN
                var categoryBTN = InterfaceHelpers.FindGameObject(filterPage, "AddCategoryBTN");

                InterfaceHelpers.CreateButton(categoryBTN, "AddCategoryBTN", InterfaceButtonMode.Background,
                                              OnButtonClick, _startColor, _hoverColor, MAX_INTERACTION_DISTANCE, AuxPatchers.AddFilterCategory());
                #endregion

                return(true);
            }
            catch (Exception e)
            {
                QuickLogger.Error($"{e.Message}: {e.StackTrace}");
                return(false);
            }
        }