示例#1
0
    public bool usingLock;                                                      // 사용 락


    // 초기화
    private void Awake()
    {
        thisRect  = GetComponent <RectTransform>();
        imgColor  = Color.white;
        isSliding = new bool[4] {
            true, true, true, true
        };
        targetSlideFunc = new SlideFunc(StopSlide);
        slideFuncs      = new SlideFunc[] { StopSlide, StopSlide, StopSlide, StopSlide };
        maxAngle        = new Vector3(0, 0, 360);

        // 배열 변수 초기화
        slideWayRect = new RectTransform[4];
        for (int i = 0; i < 4; i++)
        {
            slideWayRect[i] = slideWayImg[i].gameObject.GetComponent <RectTransform>();
        }

        slideWayOriginPos = new Vector2[4];
        for (int i = 0; i < 4; i++)
        {
            slideWayOriginPos[i] = slideWayRect[i].position;
        }

        slideWayOriginScale = new Vector2[4];
        for (int i = 0; i < 4; i++)
        {
            slideWayOriginScale[i] = slideWayRect[i].localScale;
        }

        startPos    = thisRect.position;
        slideDis.x  = (int)(Screen.width * slideDisPer);
        slideDis.y  = (int)(Screen.height * slideDisPer);
        originAlpha = 0;
    }
示例#2
0
    // 드래그 중
    public void OnDrag(PointerEventData eventData)
    {
        if (!usingLock)
        {
            // 알파 조절
            float pointerDis = Vector2.Distance(eventData.position, startPos);

            targetSlideFunc = StopSlide;

            float lerpValue = Mathf.Max(0, imgColor.a / slideMovePer);

            // 가이드라인 끄기
            GuidLineManager.instance.DisableAllGuidLine();

            // 방향 측정
            // 오른쪽에서 왼쪽으로
            //if (eventData.position.x < startPos.x - slideDis.x && isSliding[0])
            //{
            //	imgColor.a = (pointerDis - slideDis.x) / disValue;

            //	if (isUseAlpha[0])    { slideWayImg[0].color = imgColor; }
            //	if (isUsePosition[0]) { slideWayRect[0].position = Vector2.Lerp(slideWayOriginPos[0], UIManager.instance.midPos, lerpValue); }
            //	if (isUseRotation[0]) { slideWayRect[0].rotation = Quaternion.Euler(Vector3.Lerp(Vector3.zero, maxAngle, lerpValue)); }
            //	if (isUseScale[0])    { slideWayRect[0].localScale = Vector2.Lerp(slideWayOriginScale[0], slideWayOriginScale[0] + Vector2.one * 3, lerpValue); }

            //	isSliding[1] = isSliding[2] = isSliding[3] = false;

            //	if (imgColor.a >= 0.7f)
            //	{
            //		targetSlideFunc = slideFuncs[0];
            //	}
            //}
            // 왼쪽에서 오른쪽으로 (상점)
            if (eventData.position.x > startPos.x + slideDis.x && isSliding[1])
            {
                imgColor.a = (pointerDis - slideDis.x) / disValue;

                if (isUseAlpha[1])
                {
                    slideWayImg[1].color = imgColor;
                }
                if (isUsePosition[1])
                {
                    slideWayRect[1].position = Vector2.Lerp(slideWayOriginPos[1], UIManager.instance.midPos, lerpValue);
                }
                if (isUseRotation[1])
                {
                    slideWayRect[1].rotation = Quaternion.Euler(Vector3.Lerp(Vector3.zero, maxAngle, lerpValue));
                }
                if (isUseScale[1])
                {
                    slideWayRect[1].localScale = Vector2.Lerp(slideWayOriginScale[1], slideWayOriginScale[1] + Vector2.one * 3, lerpValue);
                }

                isSliding[0] = isSliding[2] = isSliding[3] = false;

                if (imgColor.a >= 0.7f)
                {
                    targetSlideFunc = slideFuncs[1];
                }
            }
            // 아래에서 위로
            //else if (eventData.position.y > startPos.y + slideDis.y && isSliding[2])
            //{
            //	imgColor.a = (pointerDis - slideDis.y) / disValue;

            //	if (isUseAlpha[2])    { slideWayImg[2].color = imgColor; }
            //	if (isUsePosition[2]) { slideWayRect[2].position = Vector2.Lerp(slideWayOriginPos[2], UIManager.instance.midPos, lerpValue); }
            //	if (isUseRotation[2]) { slideWayRect[2].rotation = Quaternion.Euler(Vector3.Lerp(Vector3.zero, maxAngle, lerpValue)); }
            //	if (isUseScale[2])    { slideWayRect[2].localScale = Vector2.Lerp(slideWayOriginScale[2], slideWayOriginScale[2] + Vector2.one * 3, lerpValue); }

            //	isSliding[0] = isSliding[1] = isSliding[3] = false;

            //	if (imgColor.a >= 0.7f)
            //	{
            //		targetSlideFunc = slideFuncs[2];
            //	}
            //}
            // 위에서 아래로 (시작)
            else if (eventData.position.y < startPos.y - slideDis.y && isSliding[3])
            {
                imgColor.a = (pointerDis - slideDis.y) / disValue;

                if (isUseAlpha[3])
                {
                    slideWayImg[3].color = imgColor;
                }
                if (isUsePosition[3])
                {
                    slideWayRect[3].position = Vector2.Lerp(slideWayOriginPos[3], UIManager.instance.midPos, lerpValue);
                }
                if (isUseRotation[3])
                {
                    slideWayRect[3].rotation = Quaternion.Euler(Vector3.Lerp(Vector3.zero, maxAngle, lerpValue));
                }
                if (isUseScale[3])
                {
                    slideWayRect[3].localScale = Vector2.Lerp(slideWayOriginScale[3], slideWayOriginScale[3] + Vector2.one * 3, lerpValue);
                }

                isSliding[0] = isSliding[1] = isSliding[2] = false;

                if (imgColor.a >= 0.7f)
                {
                    targetSlideFunc = slideFuncs[3];
                }
            }
        }
    }