using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class Game : MonoBehaviour
{
public Text scoreText;
private int score = 0;
private int bonus = 1;
[Header("Магазин")]
public int[] shopCosts;
public int[] shopBonuses;
public GameObject shopPan;
private void Update()
{
scoreText.text = score + " печенек";
}
public void shopPan_ShowAndHide()
{
shopPan.SetActive(!shopPan.activeSelf);
}
public void shopBttn_addBonus(int index) // Удалён ToString()
{
if (score >= shopCosts[index])
{
bonus *= shopBonuses[index];
score -= shopCosts[index];
}
else
{
Debug.Log("no");
}
}
public void HireFWorker()
{
StartCoroutine(BonusPerSec()); // Удалён ToString()
}
IEnumerator BonusPerSec()
{
while(true)
{
score += 1;
yield return new WaitForSeconds(1);
}
}
public void OnClick()
{
score += bonus;
scoreText.text = score + " печенек";
}
}
Уже 3 раза переписал данную часть кода по туториалу, но ни как не исправяется.
Помогите кто шарит.
Вот код:
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class Game : MonoBehaviour
{
public Text scoreText;
private int score = 0;
private int bonus = 1;
[Header("Магазин")]
public int[] shopCosts;
public int[] shopBonuses;
public GameObject shopPan;
private void Update()
{
scoreText.text = score + " печенек";
}
public void shopPan_ShowAndHide()
{
shopPan.SetActive(!shopPan.activeSelf);
}
ToString(public void shopBttn_addBonus(int index))
{
if (score >= shopCosts[index])
{
bonus *= shopBonuses[index];
score -= shopCosts[index];
}
else
{
Debug.Log("no");
}
}
public void HireFWorker()
{
ToString(StartCoroutine(BonusPerSec));
}
IEnumerator BonusPerSec()
{
while(true)
{
score += 1;
yield return new WaitForSeconds(1);
}
}
public void OnClick ()
{
score += bonus;
scoreText.text = score + " печенек"; scoreText.text = score + " печенек";
}
}