Exemplo n.º 1
0
 /// <summary>
 /// 回调事件/
 /// </summary>
 public void StartQiQiAnima(UVAnimaType type, Action complete)
 {
     //if (isPlaying)
     //    return;
     OnComplete = complete;
     StartCoroutine(StartUV(type));
 }
Exemplo n.º 2
0
    /// <summary>
    /// In:变白色
    /// out:变透明
    /// </summary>
    /// <param name="type"></param>
    public void StartWhiteAnima(UVAnimaType type, Action onComplete = null)
    {
        Material mate = whiteTransfrom.GetComponent <MeshRenderer>().material;

        if (type == UVAnimaType.In)
        {
            mate.color = new Color(1, 1, 1, 0);
            if (onComplete == null)
            {
                mate.DOColor(Color.white, whiteAnimaTime);
            }
            else
            {
                mate.DOColor(Color.white, whiteAnimaTime).OnComplete(() => { onComplete(); });
            }
        }
        else
        {
            mate.color = Color.white;
            if (onComplete == null)
            {
                mate.DOColor(new Color(1, 1, 1, 0), whiteAnimaTime);
            }
            else
            {
                mate.DOColor(new Color(1, 1, 1, 0), whiteAnimaTime).OnComplete(() => { onComplete(); });
            }
        }
    }
Exemplo n.º 3
0
 /// <summary>
 /// 开始
 /// </summary>
 /// <param name="type"></param>
 public void StartQiQiAnima(UVAnimaType type, float size1, float size2, Action complete = null)
 {
     if (isPlaying)
     {
         return;
     }
     OnComplete = complete;
     StartCoroutine(StartUV(type, size1, size2));
     OnComplete = null;
 }
Exemplo n.º 4
0
    IEnumerator StartUV(UVAnimaType type, float size1, float size2)
    {
        isPlaying = true;
        overlay.gameObject.SetActive(true);
        if (material == null)
        {
            material = overlay.GetComponent <MeshRenderer>().material;
        }

        float startSize  = 0;
        float targetSize = 0;

        //if (type == UVAnimaType.In)
        //{
        //    startSize = 0.2f;
        //    targetSize = 50f;
        //}
        //else
        //{
        //    startSize = 50f;
        //    targetSize = 0.2f;
        //}
        if (type == UVAnimaType.In)
        {
            startSize  = size1;
            targetSize = size2;
        }
        else
        {
            startSize  = size2;
            targetSize = size1;
        }
        float time     = 0;
        float outScale = 10;

        while (true)
        {
            if (type == UVAnimaType.In)
            {
                time += Time.deltaTime / AnimaTime;
            }
            else
            {
                outScale = Mathf.Lerp(outScale, 1, time);
                time    += Time.deltaTime / AnimaTime * outScale;
            }

            Size = Mathf.Lerp(startSize, targetSize, time);


            Vector2 tiling = new Vector2(Size, Size);

            //float offsetScale = -(Size - 1) * 0.5f;

            float offsetScaleX = -0.32f * Size + 0.32f;
            float offsetScaleY = -0.6f * Size + 0.6f;

            Vector2 offset = new Vector2(offsetScaleX, offsetScaleY);


            material.SetTextureScale("_MainTex", tiling);
            material.SetTextureOffset("_MainTex", offset);

            if (time > AnimaTime)
            {
                isPlaying = false;
                if (OnComplete != null)
                {
                    OnComplete();
                }
                break;
            }
            yield return(null);
        }
        if (type == UVAnimaType.Out)
        {
            overlay.gameObject.SetActive(false);
        }

        //yield return new WaitForSeconds(1f);
        //isPlaying = false;
    }
Exemplo n.º 5
0
    IEnumerator StartUV(UVAnimaType type)
    {
        if (type == UVAnimaType.In)
        {
            //SoundManager.Main.PlayFromPrefab(SoundType.音效, "010007过场收起");
        }
        else if (type == UVAnimaType.Out)
        {
            //SoundManager.Main.PlayFromPrefab(SoundType.音效, "010008过场展开");
        }
        isPlaying = true;
        overlay.gameObject.SetActive(true);
        if (material == null)
        {
            material = overlay.GetComponent <MeshRenderer>().material;
        }

        float startSize  = 0;
        float targetSize = 0;

        if (type == UVAnimaType.In)
        {
            startSize  = 0.2f;
            targetSize = 50f;
        }
        else
        {
            startSize  = 50f;
            targetSize = 0.2f;
        }
        float time     = 0;
        float outScale = 10;

        while (true)
        {
            if (type == UVAnimaType.In)
            {
                time += Time.deltaTime / AnimaTime;
            }
            else
            {
                outScale = Mathf.Lerp(outScale, 1, time);
                time    += Time.deltaTime / AnimaTime * outScale;
            }

            Size = Mathf.Lerp(startSize, targetSize, time);

            Vector2 tiling      = new Vector2(Size, Size);
            float   offsetScale = -(Size - 1) * 0.5f;
            Vector2 offset      = new Vector2(offsetScale, offsetScale);

            material.SetTextureScale("_MainTex", tiling);
            material.SetTextureOffset("_MainTex", offset);
            if (time > AnimaTime)
            {
                if (OnComplete != null)
                {
                    OnComplete();
                }
                isPlaying = false;
                break;
            }
            yield return(null);
        }
        if (type == UVAnimaType.Out)
        {
            overlay.gameObject.SetActive(false);
        }

        //yield return new WaitForSeconds(1f);
        //isPlaying = false;
    }