5.6.0 - Changing Text in new UI tools via script
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class Click : MonoBehaviour
{
public Text showCoins;
public float coin=0;
public int coinperclick=1;
void Update ()
{
showCoins.text = "Coins: " + coin.ToString();
}
public void click()
{
coin = coin + coinperclick;
}
}
Give me these error:
"Assertion failed on expression: 'm_CurrentEntriesPtr != NULL && m_IsGettingEntries' UnityEditorInternal.LogEntries:GetEntryInternal(Int32, LogEntry) UnityEditor.DockArea:OnGUI()"
Can someone help me solve these error?
Answer by UnityCoach · Apr 19, 2017 at 09:33 PM
It seems you had typed showCoins.Text
and not showCoins.text
. Anyway, you may also need to add .ToString()
to your float.
showCoins.text = "Coins: " + coin.ToString();
now only show this error 4 times: "Assertion failed on expression: 'm_CurrentEntriesPtr != NULL && m_IsGettingEntries' UnityEditorInternal.LogEntries:GetEntryInternal(Int32, LogEntry) UnityEditor.DockArea:OnGUI()" Did you know how to solve? And thank you for the help ;)
This is weird, I can tell there's nothing wrong in your code there. Is there anything else ?
The code is all there, but I will send a screenshot of my unity to see if something I am doing wrong.
It seems you didn't assign a Text reference. The message is weird though. It should simply say
unassigned exception