So I’m new to C# as I’ve only used JS before now I’m currently converting my JS based battle system to C# using the new uGUI as I was told it will make performance better.
I’ve come up with this so far does what I want but doesn’t wait 2 seconds at all its unless it is and 2 seconds is really fast. Can anyone help with the problem? I know they is unwanted stuff there I’m still getting use to using c#
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class displayTextScript : MonoBehaviour {
public GameObject textGuiObj;
public Text gameText;
public int playerHealth;
public Button gameButton;
public bool turnForAttack = false;
public int turn = 1;
public int phase = 0;
GameObject Button;
// Use this for initialization
void Start () {
gameText.text = ("Attack");
//gameButton.interactable = false;
Test();
}
// Update is called once per frame
void Update () {
Test();
}
public void Clicked() {
turn = 0;
phase = 1;
Example () ;
}
public void Test ()
{
if(turn > phase)
{
print("player attack");
gameButton.interactable = true;
}
else if(phase > turn)
{
gameButton.interactable = false;
print("This is the enemy turn");
Example () ;
phase = 0;
turn = 2;
}
else
{
gameButton.interactable = false;
print("something");
}
}
IEnumerator Example() {
print(Time.time);
yield return new WaitForSeconds(5);
print(Time.time);
}
}