48 lines
1.2 KiB
C#
48 lines
1.2 KiB
C#
using UnityEngine;
|
|
using System.Collections;
|
|
using UnityEngine.UI;
|
|
|
|
public class StayFocusBehavior : MonoBehaviour
|
|
{
|
|
private bool firstChildPositionned;
|
|
private Vector3 firstChildStartPosition;
|
|
public Transform startBtn;
|
|
public Transform optionsBtn;
|
|
public Transform highscoresBtn;
|
|
public Transform quitBtn;
|
|
|
|
// Use this for initialization
|
|
void Start()
|
|
{
|
|
firstChildPositionned = false;
|
|
startBtn = transform.GetChild(0);
|
|
firstChildStartPosition = startBtn.position;
|
|
optionsBtn = transform.GetChild(1);
|
|
highscoresBtn = transform.GetChild(2);
|
|
quitBtn = transform.GetChild(3);
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
if (!firstChildPositionned)
|
|
{
|
|
var position = startBtn.position;
|
|
if (position != firstChildStartPosition)
|
|
{
|
|
firstChildPositionned = true;
|
|
SelectButton(startBtn);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void SelectButton(Transform transform)
|
|
{
|
|
var script = transform.GetComponent(typeof(MenuButtonBehavior)) as MenuButtonBehavior;
|
|
if (script != null)
|
|
{
|
|
script.AlignIcon();
|
|
}
|
|
}
|
|
}
|