예제 #1
0
    private void Awake()
    {
        screenSize       = GetComponentInParent <ScreenSizeChecker>();
        canvasRectTransf = GetComponentInParent <RectTransform>();
        livesImages      = new GameObject[3];

        for (int i = 0; i < livesImages.Length; i++)
        {
            livesImages[i]      = Instantiate <GameObject>(lifePrefab);
            livesImages[i].name = $"Life{i + 1}";
            livesImages[i].transform.SetParent(transform);

            //livesImages[i].transform.position =
            //    new Vector3( - (Screen.width / 3) * 2,
            //    (Screen.height / 3) * (- i + 1), 0);
            livesImages[i].transform.position = new Vector3(
                -(screenSize.GetScreenToWorldWidth / 6) * 2.25f,
                screenSize.GetScreenToWorldHeight / 3 * (-i + 1), 0);
        }
    }
예제 #2
0
 // Awake is called when the script instance is being loaded.
 void Awake()
 {
     screenSize     = GetComponentInParent <ScreenSizeChecker>();
     spriteRenderer = GetComponent <SpriteRenderer>();
 }