Beispiel #1
0
    //----------------------------------------------------------------------------------
// Align element and  setup start position/animation
    public void Start()
    {
        Vector2 screenSizeMultiplier = parentElement.GetScreenSizeMultiplier();

        parentSize = parentElement.size;

        if (screenSizeMultiplier != Vector2.zero)
        {
            size.x     *= screenSizeMultiplier.x;
            size.y     *= screenSizeMultiplier.y;
            position.x *= screenSizeMultiplier.x;
            position.y *= screenSizeMultiplier.y;
        }

        switch (globalAligment)
        {
        case Aligments.center_center:
            position.x = (parentSize.x - size.x) / 2;
            position.y = (parentSize.y - size.y) / 2;
            break;

        case Aligments.center_up:
            position.x = (parentSize.x - size.x) / 2;
            position.y = 0;
            break;

        case Aligments.center_down:
            position.x = (parentSize.x - size.x) / 2;
            position.y = parentSize.y - size.y;
            break;

        case Aligments.left_center:
            position.x = 0;
            position.y = (parentSize.y - size.y) / 2;
            break;

        case Aligments.left_up:
            position.x = 0;
            position.y = 0;
            break;

        case Aligments.left_down:
            position.x = 0;
            position.y = parentSize.y - size.y;
            break;

        case Aligments.right_center:
            position.x = parentSize.x - size.x;
            position.y = (parentSize.y - size.y) / 2;
            break;

        case Aligments.right_up:
            position.x = parentSize.x - size.x;
            position.y = 0;
            break;

        case Aligments.right_down:
            position.x = parentSize.x - size.x;
            position.y = parentSize.y - size.y;
            break;

        case Aligments.left:
            position.x = 0;
            break;

        case Aligments.center_y:
            position.x = (parentSize.x - size.y) / 2;
            position.y = (parentSize.y - size.y) / 2;
            break;

        case Aligments.center_x:
            position.x = (parentSize.x - size.x) / 2;
            break;

        case Aligments.right:
            position.x = parentSize.x - size.x;
            break;

        case Aligments.down:
            position.y = parentSize.y - size.y;
            break;

        case Aligments.up:
            position.y = 0;
            break;
        }

        PrepareAnimations();
        masterVolume    = GameObject.FindObjectOfType <AudioListener>();
        animationSpeed *= 100;
    }