This is the full error (in this new scenario, it is a NullReferenceException):
NullReferenceException: Object reference not set to an instance of an object
FightScript.startFight_Click () (at Assets/Scripts/FightScript.cs:105)
UnityEngine.Events.InvokableCall.Invoke () (at C:/buildslave/unity/build/Runtime/Export/UnityEvent.cs:166)
UnityEngine.Events.UnityEvent.Invoke () (at C:/buildslave/unity/build/Runtime/Export/UnityEvent_0.cs:58)
UnityEngine.UI.Button.Press () (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/Button.cs:36)
UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/Button.cs:45)
UnityEngine.EventSystems.ExecuteEvents.Execute (IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/EventSystem/ExecuteEvents.cs:50)
UnityEngine.EventSystems.ExecuteEvents.Execute[IPointerClickHandler] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.EventFunction`1 functor) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/EventSystem/ExecuteEvents.cs:261)
UnityEngine.EventSystems.EventSystem:Update()
Here is the code:
public void startFight_Click() // line 100
{
...
Debug.Log(strengthHeroValue.ToString()); // line 105 here
...
}
strengthHeroValue is declared at the class level as public like this:
public Text strengthHeroValue;
In the UI, strengthHeroValue is assigned to a ValueText in the FightScript (Script) section.
I have a button called startButton and in the On Click() section, I chose FightController and then FightScript.startFight_Click() event.
When I double click on the error, it brings me to the startFight_Click() method which is line 100.
Thanks for your help.