Exemple #1
0
    private void Start()
    {
        Tags.useTag = false;
        // Begin by initializing ShopifyHelper, to make connection to shop
        ShopifyHelper.Init(AccessToken, ShopDomain);
        // With initialization complete, initial products panel
        ProductsPanel.Init();

        // Setup event listeners for panels

        // Handle transition to specific product
        ProductsPanel.OnShowProduct.AddListener(product => {
            ShowPanel(ProductPanel.gameObject);
            ProductPanel.SetCurrentProduct(product);
        });

        // Handle event from click of the close pop up button
        ProductsPanel.OnClosePanel.AddListener(HidePopup);

        ProductsPanel.OnNetworkError.AddListener(() => RenderError("Could not find products."));

        // Handle transition back to products list from product view
        ProductPanel.OnReturnToProducts.AddListener(() => ShowPanel(ProductsPanel.gameObject));
        // Handle transition to the cart view
        ProductPanel.OnViewCart.AddListener(() => ShowPanel(CartPanel.gameObject));
        // Handles click of the add to cart button, which transitions to the cart view
        ProductPanel.OnAddProductToCart.AddListener(CartPanel.AddToCart);

        // Handle transition back to products list from cart view
        CartPanel.OnReturnToProducts.AddListener(() => ShowPanel(ProductsPanel.gameObject));
        // Handles a change in cart quanity, in order to update the cart quantity indicators
        CartPanel.OnCartQuantityChanged.AddListener(UpdateCartQuantity);
        // Handles a successful checkout, by hiding the shop pop up
        CartPanel.OnCheckoutSuccess.AddListener(HidePopup);
        // Handles a failed checkout by displaying the error
        CartPanel.OnCheckoutFailure.AddListener(RenderError);

        // Handle transition back to products list from empty cart view
        EmptyCartPanel.OnReturnToProducts.AddListener(() => ShowPanel(ProductsPanel.gameObject));

        // Handle transition to cart view, when view cart button is clicked
        ViewCartButton.OnClick.AddListener(() => ShowPanel(CartPanel.gameObject));
        // Handle click on empty view cart button, by transitioning to empty cart view
        EmptyViewCartButton.onClick.AddListener(() => ShowPanel(EmptyCartPanel.gameObject));

        AnimationCanvas.OnAnimationStarted.AddListener(() => ProductsPanel.PauseFetching());
        AnimationCanvas.OnAnimationStopped.AddListener(() => ProductsPanel.ResumeFetching());
    }
        public void Start()
        {
            Tags.SetTag(true, "Fedora");

            if (!Permission.HasUserAuthorizedPermission(Permission.Camera))
            {
                Permission.RequestUserPermission(Permission.Camera);
            }


            OnShoopingCartPanelAR += ShoopingCartPanelAR;
            OnBackAR += BackAR;

            ShopifyHelper.Init(AccessToken, ShopDomain);

            GalleryPanel.Init();

            Application.targetFrameRate = 60;

            GalleryPanel.OnShowProduct.AddListener(product =>
            {
                InformationPanel.gameObject.GetComponent <RectTransform>().DOLocalMoveX(0, speedMovementPanel);
                // ShowPanel(ProductPanel.gameObject);
                InformationPanel.SetCurrentProduct(product);
            });

            HatSlidingContentAR.OnShowProduct.AddListener(p =>
            {
                InformationPanel.SetCurrentProduct(p);
            });

            InformationPanel.OnReturnToProducts.AddListener(() =>
            {
                InformationPanel.gameObject.GetComponent <RectTransform>().DOLocalMoveX(719, speedMovementPanel);
            });

            InformationPanel.OnViewCart.AddListener(() =>
            {
                HatCartPanel.gameObject.GetComponent <RectTransform>().DOLocalMoveX(0, speedMovementPanel);
            });

            InformationPanel.OnTryProduct.AddListener(() =>
            {
                InformationPanel.gameObject.GetComponent <RectTransform>().DOLocalMoveX(719, speedMovementPanel);
                GalleryPanel.gameObject.GetComponent <RectTransform>().DOLocalMoveX(719, speedMovementPanel).OnComplete(() =>
                {
                    if (loadSceneAR == false)
                    {
                        UnityEngine.SceneManagement.SceneManager.LoadScene(2);
                        loadSceneAR = true;
                    }
                });
            });

            HatCartPanel.OnReturnToProducts.AddListener(() =>
            {
                HatCartPanel.gameObject.GetComponent <RectTransform>().DOLocalMoveX(-719, speedMovementPanel);
            });

            InformationPanel.OnAddProductToCart.AddListener(HatCartPanel.AddToCart);
            //  GalleryPanel.OnNetworkError.AddListener(() => RenderError("Could not find products."));
        }