I have a text component that is changed in my script, however the change does not appear on the canvas until after I stop running the game. How do I get the change to appear at runtime?
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine.Networking;
using System;
using UnityEngine.Networking.NetworkSystem;
using UnityEngine.UI;
public class Player : NetworkBehaviour {
public Text turn_count_drop; //assigned in unity
int turnCount = 0;
[SyncVar (hook = "ChangeMyTurn")]
public bool myTurn = false;
void ChangeMyTurn(bool value){
Debug.Log("CHANGE MY TURN CALLED");
turnCount += 1;
Debug.Log(turnCount);
turn_count_drop.text = turnCount.ToString();
myTurn = value;
}
}
I get the “CHANGE MY TURN CALLED” and turnCount messages in console.