IEnumerator ChangeImageFromURLCoroutine(string imageURL)
    {
        m_isLoadingNewImage = true;
        FileToSprite currentFileToSprite = gameObject.AddComponent <FileToSprite>();

        currentFileToSprite.CreateSpriteFromFile(imageURL);

        while (currentFileToSprite.GetSprite() == null)
        {
            yield return(null);
        }

        if (m_mainSprite.sprite != null)
        {
            Destroy(m_mainSprite.sprite.texture);
        }

        m_mainSprite.sprite = currentFileToSprite.GetSprite();

        Destroy(m_mainSprite.gameObject.GetComponent <BoxCollider2D>());
        m_mainSprite.gameObject.AddComponent <BoxCollider2D>();

        Destroy(currentFileToSprite);

        UpdateScene();
        m_isLoadingNewImage = false;
    }
Exemplo n.º 2
0
    IEnumerator LoadDiaryPage(string filename)
    {
        m_isLoadingImage = true;

        FileToSprite currentFileToSprite = gameObject.AddComponent <FileToSprite>();

        currentFileToSprite.CreateSpriteFromFile(filename);

        while (currentFileToSprite.IsSpriteLoading())
        {
            yield return(null);
        }

        Sprite sprite = currentFileToSprite.GetSprite();

        if (sprite != null)
        {
            if (!m_hasAlreadyAnImage)
            {
                m_backgroundImage.sprite = sprite;
                m_hasAlreadyAnImage      = true;
            }
            else
            {
                MergeToBackgroundImage(sprite);
            }
        }

        Destroy(currentFileToSprite);
        m_isLoadingImage = false;
        yield return(null);
    }
Exemplo n.º 3
0
    IEnumerator LoadImage()
    {
        m_isLoadingAdviceReady = false;

        while (!SEGMentPath.instance.ArePathGenerated())
        {
            yield return(null);
        }

        Debug.Log(SEGMentPath.instance.GetTitleLoadingPanelPath());

        FileToSprite currentFileToSprite = gameObject.AddComponent <FileToSprite>();

        currentFileToSprite.CreateSpriteFromFile(SEGMentPath.instance.GetTitleLoadingPanelPath());



        while (currentFileToSprite.IsSpriteLoading())
        {
            yield return(null);
        }

        if (currentFileToSprite.HasLoadingFailed())
        {
            m_hasLoadingAdviceFailedToLoad = true;
        }
        else
        {
            m_loadedSprite         = currentFileToSprite.GetSprite();
            m_isLoadingAdviceReady = true;
        }

        Destroy(currentFileToSprite);
    }
Exemplo n.º 4
0
    public IEnumerator SetSpriteByURLRelativelyToAnotherOneCoroutine(string url, SpriteRenderer parentSpriteRenderer, float relativex1, float relativey1, float relativex2, float relativey2, int orderInLayer = 0, UIManager manager = null)
    {
        //GenericLog.Log(url.Substring(url.Length - 4, 3));

        m_spriteIsLoaded = false;

                #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
        url = url.Replace("\\", "/");
                #endif

        m_url = url;

        /* test if the file is a gif */
        //if (url.Substring(url.Length - 3, 3) == "gif") {
        if (IsAGifFile(url))
        {
            GenericLog.Log("THIS IS A GIF " + url);
            StartCoroutine(GifLoader(url, parentSpriteRenderer, relativex1, relativey1, relativex2, relativey2, orderInLayer));

            while (!m_gifIsLoaded)
            {
                yield return(null);
            }

            m_spriteIsLoaded = true;
        }
        else
        {
            FileToSprite currentFileToSprite = gameObject.AddComponent <FileToSprite>();
            currentFileToSprite.CreateSpriteFromFile(url);

            while (currentFileToSprite.GetSprite() == null)
            {
                yield return(null);
            }

            Sprite sprite = currentFileToSprite.GetSprite();

            SetSpriteRelativelyToAnotherOne(sprite, parentSpriteRenderer, relativex1, relativey1, relativex2, relativey2, orderInLayer);
            m_spriteIsLoaded = true;

            Destroy(currentFileToSprite);

            yield return(null);
        }
    }