Beispiel #1
0
    /// <summary>
    /// Goes to the specified page and configures it acordingly
    /// </summary>
    /// <param name="Page">The index of the page to go to</param>
    /// <returns>If the page was indeed changed</returns>
    private bool GoToPage(int Page)
    {
        if (Contenidos == null || Page < 0 || Page >= Contenidos.Length)
        {
            return(false);
        }

        //Change the content here
        Contenido currentContent = Contenidos[Page];

        DetailText.text = currentContent.Data;

        //Update the current index
        CurrentPage = Page;

        //Try to setup the image if there is one
        if (currentContent.ImagenURL.Length > 0)
        {
            //First we should enable the image wrapper
            ImageWrapper.SetActive(true);

            //There's an image url, should try to get it if it exists
            Texture2D image = currentContent.TryGetImage(this);
            if (image)
            {
                ContentImage.overrideSprite = Sprite.Create(image, new Rect(0, 0, image.width, image.height), new Vector2(0, 0));
            }
            else
            {
                ContentImage.overrideSprite = Sprite.Create(LoadingImage, new Rect(0, 0, LoadingImage.width, LoadingImage.height), new Vector2(0, 0));
            }
        }
        else
        {
            //No image wrapper needed
            ImageWrapper.SetActive(false);
        }

        //Check if we should update the list area
        if (UsesOptionListArea(currentContent))
        {
            OptionListWrapper.SetActive(true);
            ListController.Clear();

            FillOptionList(currentContent);
        }
        else
        {
            OptionListWrapper.SetActive(false);
        }

        return(true);
    }