Exemplo n.º 1
0
    void GetRandomEaseType(string effectName)
    {
        int whichEaseType = Random.Range(1, 33);

        GUITween.EaseType tempEase = GUITween.EaseType.linear;

        switch (whichEaseType)
        {
        case 1:
            tempEase = GUITween.EaseType.easeInQuad;
            break;

        case 2:
            tempEase = GUITween.EaseType.easeOutQuad;
            break;

        case 3:
            tempEase = GUITween.EaseType.easeInOutQuad;
            break;

        case 4:
            tempEase = GUITween.EaseType.easeInCubic;
            break;

        case 5:
            tempEase = GUITween.EaseType.easeOutCubic;
            break;

        case 6:
            tempEase = GUITween.EaseType.easeInOutCubic;
            break;

        case 7:
            tempEase = GUITween.EaseType.easeOutElastic;
            break;

        case 8:
            tempEase = GUITween.EaseType.easeInQuart;
            break;

        case 9:
            tempEase = GUITween.EaseType.easeOutQuart;
            break;

        case 10:
            tempEase = GUITween.EaseType.easeInOutQuart;
            break;

        case 11:
            tempEase = GUITween.EaseType.easeInQuint;
            break;

        case 12:
            tempEase = GUITween.EaseType.easeOutQuint;
            break;

        case 13:
            tempEase = GUITween.EaseType.easeInOutQuint;
            break;

        case 14:
            tempEase = GUITween.EaseType.easeInSine;
            break;

        case 15:
            tempEase = GUITween.EaseType.easeOutSine;
            break;

        case 16:
            tempEase = GUITween.EaseType.easeInOutElastic;
            break;

        case 17:
            tempEase = GUITween.EaseType.easeInOutSine;
            break;

        case 18:
            tempEase = GUITween.EaseType.easeInExpo;
            break;

        case 19:
            tempEase = GUITween.EaseType.easeOutExpo;
            break;

        case 20:
            tempEase = GUITween.EaseType.easeInOutExpo;
            break;

        case 21:
            tempEase = GUITween.EaseType.easeInCirc;
            break;

        case 22:
            tempEase = GUITween.EaseType.easeOutCirc;
            break;

        case 23:
            tempEase = GUITween.EaseType.easeInOutCirc;
            break;

        case 24:
            tempEase = GUITween.EaseType.linear;
            break;

        case 25:
            tempEase = GUITween.EaseType.spring;
            break;

        case 26:
            tempEase = GUITween.EaseType.easeInBounce;
            break;

        case 27:
            tempEase = GUITween.EaseType.easeOutBounce;
            break;

        case 28:
            tempEase = GUITween.EaseType.easeInOutBounce;
            break;

        case 29:
            tempEase = GUITween.EaseType.easeInBack;
            break;

        case 30:
            tempEase = GUITween.EaseType.easeOutBack;
            break;

        case 31:
            tempEase = GUITween.EaseType.easeInOutBack;
            break;

        case 32:
            tempEase = GUITween.EaseType.easeInElastic;
            break;

        default:
            tempEase = GUITween.EaseType.linear;
            break;
        }

        switch (effectName)
        {
        case "Fade":
            // nothing
            break;

        case "Position":
            positionEaseType = tempEase;
            break;

        case "Scale":
            scaleEaseType = tempEase;
            break;

        case "Rotation":
            rotationEaseType = tempEase;
            break;

        default:
            // nothing
            break;
        }
    }
Exemplo n.º 2
0
    // Use this for initialization
    public void Start( )
    {
        tempFadeAlpha         = fadeStartValue;
        tempFadeAlphaAddition = ((fadeEndValue - fadeStartValue) / ((2.0f / fadeSpeed) * 50.0f));

        WhichObjectIsThis();
        // check if common parameters
        if (isCommonParams)
        {
            fadeSpeed        = positionEffectSpeed = scaleEffectSpeed = rotationSpeed = commonSpeed;
            fadeDelay        = positionEffectDelay = scaleEffectDelay = rotationDelay = commonStartDelay;
            fadeDismissDelay = positionEffectDismissDelay = scaleEffectDismissDelay = rotationDismissDelay = commonDismissDelay;
            positionEaseType = scaleEaseType = rotationEaseType = commonEaseType;
            fadeLoopType     = positionLoopType = scaleLoopType = rotationLoopType = commonLoopType;
        }

        // check if random
        if (isRandom)
        {
            ApplyRandomEffects();
        }

        // get placeholder's alpha of input field.
        if (isInputField)
        {
            if (transform.childCount > 1)
            {
                Transform placeHold = transform.GetChild(transform.childCount - 2);
                inFieldPlaceAlphaDevider = 1.0f / (placeHold.GetComponent <Text>().color.a);
            }
        }

        // checking for random easetype of all objects
        if (isRandomPositionEaseType)
        {
            GetRandomEaseType("Position");
        }
        if (isRandomRotationEaseType)
        {
            GetRandomEaseType("Rotation");
        }
        if (isRandomScaleEaseType)
        {
            GetRandomEaseType("Scale");
        }

        if (isMoveFromBottom)
        {
            GUITween.MoveFrom(gameObject, GUITween.Hash("position", new Vector3(gameObject.GetComponent <RectTransform>().localPosition.x, gameObject.GetComponent <RectTransform>().localPosition.y - Screen.height, gameObject.GetComponent <RectTransform>().localPosition.z), "islocal", true, "time", 2.0f / positionEffectSpeed, "delay", positionEffectDelay, "easeType", positionEaseType, "ignoretimescale", ignoreTimeScale, "looptype", positionLoopType));
        }
        if (isMoveFromLeft)
        {
            GUITween.MoveFrom(gameObject, GUITween.Hash("position", new Vector3(gameObject.GetComponent <RectTransform>().localPosition.x - Screen.width, gameObject.GetComponent <RectTransform>().localPosition.y, gameObject.GetComponent <RectTransform>().localPosition.z), "islocal", true, "time", 2.0f / positionEffectSpeed, "delay", positionEffectDelay, "easeType", positionEaseType, "ignoretimescale", ignoreTimeScale, "looptype", positionLoopType));
        }
        if (isMoveFromRight)
        {
            GUITween.MoveFrom(gameObject, GUITween.Hash("position", new Vector3(gameObject.GetComponent <RectTransform>().localPosition.x + Screen.width, gameObject.GetComponent <RectTransform>().localPosition.y, gameObject.GetComponent <RectTransform>().localPosition.z), "islocal", true, "time", 2.0f / positionEffectSpeed, "delay", positionEffectDelay, "easeType", positionEaseType, "ignoretimescale", ignoreTimeScale, "looptype", positionLoopType));
        }
        if (isMoveFromTop)
        {
            GUITween.MoveFrom(gameObject, GUITween.Hash("position", new Vector3(gameObject.GetComponent <RectTransform>().localPosition.x, gameObject.GetComponent <RectTransform>().localPosition.y + Screen.height, gameObject.GetComponent <RectTransform>().localPosition.z), "islocal", true, "time", 2.0f / positionEffectSpeed, "delay", positionEffectDelay, "easeType", positionEaseType, "ignoretimescale", ignoreTimeScale, "looptype", positionLoopType));
        }
        if (isMoveFromTopRight)
        {
            GUITween.MoveFrom(gameObject, GUITween.Hash("position", new Vector3(gameObject.GetComponent <RectTransform>().localPosition.x + Screen.width, gameObject.GetComponent <RectTransform>().localPosition.y + Screen.height, gameObject.GetComponent <RectTransform>().localPosition.z), "islocal", true, "time", 2.0f / positionEffectSpeed, "delay", positionEffectDelay, "easeType", positionEaseType, "ignoretimescale", ignoreTimeScale, "looptype", positionLoopType));
        }
        if (isMoveFromTopLeft)
        {
            GUITween.MoveFrom(gameObject, GUITween.Hash("position", new Vector3(gameObject.GetComponent <RectTransform>().localPosition.x - Screen.width, gameObject.GetComponent <RectTransform>().localPosition.y + Screen.height, gameObject.GetComponent <RectTransform>().localPosition.z), "islocal", true, "time", 2.0f / positionEffectSpeed, "delay", positionEffectDelay, "easeType", positionEaseType, "ignoretimescale", ignoreTimeScale, "looptype", positionLoopType));
        }
        if (isMoveFromBottomRight)
        {
            GUITween.MoveFrom(gameObject, GUITween.Hash("position", new Vector3(gameObject.GetComponent <RectTransform>().localPosition.x + Screen.width, gameObject.GetComponent <RectTransform>().localPosition.y - Screen.height, gameObject.GetComponent <RectTransform>().localPosition.z), "islocal", true, "time", 2.0f / positionEffectSpeed, "delay", positionEffectDelay, "easeType", positionEaseType, "ignoretimescale", ignoreTimeScale, "looptype", positionLoopType));
        }
        if (isMoveFromBottomLeft)
        {
            GUITween.MoveFrom(gameObject, GUITween.Hash("position", new Vector3(gameObject.GetComponent <RectTransform>().localPosition.x - Screen.width, gameObject.GetComponent <RectTransform>().localPosition.y - Screen.height, gameObject.GetComponent <RectTransform>().localPosition.z), "islocal", true, "time", 2.0f / positionEffectSpeed, "delay", positionEffectDelay, "easeType", positionEaseType, "ignoretimescale", ignoreTimeScale, "looptype", positionLoopType));
        }
        if (isPopUp)
        {
            GUITween.ScaleFrom(gameObject, GUITween.Hash("scale", new Vector3(popUpStartValue, popUpStartValue, popUpStartValue), "islocal", true, "time", 2.0f / scaleEffectSpeed, "delay", scaleEffectDelay, "easeType", scaleEaseType, "ignoretimescale", ignoreTimeScale, "looptype", scaleLoopType));
        }
        if (isReversePopUp)
        {
            GUITween.ScaleFrom(gameObject, GUITween.Hash("scale", new Vector3(reversePopUpStartValue, reversePopUpStartValue, reversePopUpStartValue), "islocal", true, "time", 2.0f / scaleEffectSpeed, "delay", scaleEffectDelay, "easeType", scaleEaseType, "ignoretimescale", ignoreTimeScale, "looptype", scaleLoopType));
        }
        if (isRotation)
        {
            if (axisX)
            {
                rotationVector = new Vector3(flipsPerRotation, 0, 0);
            }
            else
            if (axisY)
            {
                rotationVector = new Vector3(0, flipsPerRotation, 0);
            }
            else
            if (axisZ)
            {
                rotationVector = new Vector3(0, 0, flipsPerRotation);
            }
            else
            {
                rotationVector = new Vector3(flipsPerRotation, flipsPerRotation, flipsPerRotation);
                Debug.LogError("You have not selected your axis to rotate in GUIEffects. Please select any one axis in the inspector on your GUI element.");
            }
            if (rotationLoopType == GUITween.LoopType.none)
            {
                if (isContinuosRotation)
                {
                    GUITween.RotateBy(gameObject, GUITween.Hash("amount", rotationVector, "time", 2.0f / rotationSpeed, "delay", rotationDelay, "looptype", GUITween.LoopType.none, "easeType", rotationEaseType, "ignoretimescale", ignoreTimeScale, "oncomplete", "WaitAndRotateContinuos"));
                }
                else
                {
                    GUITween.RotateBy(gameObject, GUITween.Hash("amount", rotationVector, "time", 2.0f / rotationSpeed, "delay", rotationDelay, "looptype", GUITween.LoopType.none, "easeType", rotationEaseType, "ignoretimescale", ignoreTimeScale, "oncomplete", "WaitAndRotateNonContinuos"));
                }
            }
            else
            {
                GUITween.RotateBy(gameObject, GUITween.Hash("amount", rotationVector, "time", 2.0f / rotationSpeed, "delay", rotationDelay, "looptype", rotationLoopType, "easeType", rotationEaseType, "ignoretimescale", ignoreTimeScale));
            }
        }
    }