Пример #1
0
    private void Awake()
    {
        carSelected = PlayerPrefs.GetString("carSelected", "Derby");
        DontDestroyOnLoad(this);

        if (carSelectedObject == null)
        {
            carSelectedObject = this;
        }
        else
        {
            Destroy(gameObject);
        }
    }
Пример #2
0
    public void SelectObject(GameObject gameObject)
    {
        SelectedCar = gameObject;
        SelectedCar.SetActive(true);

        Vector3 camForward = Camera.main.transform.forward;

        camForward = new Vector3(camForward.x, 0, camForward.z).normalized;

        Quaternion carRot = Quaternion.LookRotation(-camForward);

        SelectedCar.transform.rotation = carRot;

        CarSelected?.Invoke(gameObject);
    }
Пример #3
0
 private void Awake()
 {
     _carSelected = FindObjectOfType <CarSelected>();
 }