Example #1
0
        public void InitializeViews()
        {
            _productListView    = Instantiate <ProductListView>(ProductListViewPrefab);
            _productDetailsView = Instantiate <ProductDetailsView>(ProductDetailsViewPrefab);
            _cartView           = Instantiate <CartView>(CartViewPrefab);

            _productListView.Shop    = this;
            _productDetailsView.Shop = this;
            _cartView.Shop           = this;

            ViewSwitcher.RegisterView(_productListView.RectTransform);
            ViewSwitcher.RegisterView(_productDetailsView.RectTransform);
            ViewSwitcher.RegisterView(_cartView.RectTransform);

            _activeView = _productListView;
            OnViewChanged();
        }
        public void Setup()
        {
            Views = new List <RectTransform>();

            var fixture = AssetDatabase.LoadAssetAtPath <GameObject>("Assets/Shopify/UIToolkit/Components/ViewSwitcher/View Switcher Example.prefab");

            ViewSwitcherPrefab        = GameObject.Instantiate(fixture, Vector3.zero, Quaternion.identity);
            Subject                   = ViewSwitcherPrefab.GetComponentInChildren <ViewSwitcher>();
            Subject.AnimationDuration = AnimationDuration;

            foreach (Transform child in Subject.Container.transform)
            {
                Views.Add(child.GetComponent <RectTransform>());
            }

            Views.ForEach((x) => Subject.RegisterView(x));
        }