Пример #1
0
    public static void fitObjectToWidth(GameObject obj)
    {
        ScaleWidthScript screenScaleScript = Camera.main.GetComponent <ScaleWidthScript>();

        Sprite  sprite = obj.GetComponent <SpriteRenderer>().sprite;
        Vector3 scale  = new Vector3(screenScaleScript.targetWidth / (float)sprite.rect.width, screenScaleScript.targetWidth / (float)sprite.rect.width, 1.0f);

        obj.transform.localScale = scale;
    }
Пример #2
0
    public static void resizeObjectToScreen(GameObject obj)
    {
        ScaleWidthScript screenScaleScript = Camera.main.GetComponent <ScaleWidthScript>();

        Sprite  sprite = obj.GetComponent <SpriteRenderer>().sprite;
        Vector3 scale  = new Vector3(screenScaleScript.targetWidth, screenScaleScript.calculatedHeight, 1.0f);

        obj.transform.localScale = scale;
    }
Пример #3
0
    void Start()
    {
        scaledScreenScript = Camera.main.GetComponent <ScaleWidthScript>();

        Vector3 wallTriggerPosition = new Vector3(0, 0, -1);

        wallTriggerPosition.y = topSpawnerMultipler * scaledScreenScript.calculatedHeight;
        createWallTrigger(false, wallTriggerPosition);

        wallTriggerPosition.y = -(bottomSpawnerMultipler * scaledScreenScript.calculatedHeight);
        createWallTrigger(true, wallTriggerPosition);
    }