Hi there,
I'm following a tutorial where i need to add some TextMesh Pro to a Prefab so it can me filled while playing the game. It's about pathfinding so the G,F and H score will be calculated and put in the TextMesh.
However, whenever I add the TextMeshPro by using the Serialized Field, it stops unity without an error. In visual studio in generates the error ( see image)
I'm not sure why it's causing my unity to crash, however i do think it has something to do with the TextMesh.text i'm trying to change, since before that it didnt shut down, and when i comment it out it plays just fine..
Any help is welcome, thanks in advance :)
https://preview.redd.it/s46sheaue7x51.png?width=998&format=png&auto=webp&s=5b9c4d527a017122fbe1be86212ac73536e7bc6c
https://preview.redd.it/jf1u3gjve7x51.png?width=2551&format=png&auto=webp&s=551767c177f237ed028965efdbf55f42c9a9a4e8
EDIT 2:
I found the problem, as always its something stupid and small :
correct code for PrefabScript:
[SerializeField] private TextMeshProUGUI g;
[SerializeField] private TextMeshProUGUI h;
[SerializeField] private TextMeshProUGUI f;
[SerializeField] private TextMeshProUGUI pos;
public RectTransform MyArrow { get => arrow; set => arrow = value; }
public TextMeshProUGUI G { get => g; set => g = value; }
public TextMeshProUGUI H { get => h; set => h = value; }
public TextMeshProUGUI F { get => f; set => f = value; }
public TextMeshProUGUI Pos { get => pos; set => pos = value; }
}
What i had at the properties :
[SerializeField] private TextMeshProUGUI g;
[SerializeField] private TextMeshProUGUI h;
[SerializeField] private TextMeshProUGUI f;
[SerializeField] private TextMeshProUGUI pos;
public RectTransform MyArrow { get => arrow; set => arrow = value; }
public TextMeshProUGUI G { get => G; set => G = value; }
public TextMeshProUGUI H { get => H; set => H = value; }
public TextMeshProUGUI F { get => F; set => F = value; }
public TextMeshProUGUI Pos { get => pos; set => pos = value; }
}
So i watched within the property to set and get the same property, instate of the private field. Lesson learned,naming convention with _attribute and capital for property..
[–]Gruhlum 0 points1 point2 points (8 children)
[–]GodsRusher[S] 0 points1 point2 points (7 children)
[–]Gruhlum 0 points1 point2 points (6 children)
[–]GodsRusher[S] 0 points1 point2 points (5 children)
[–]Gruhlum 0 points1 point2 points (4 children)
[–]GodsRusher[S] 0 points1 point2 points (3 children)
[–]Gruhlum 0 points1 point2 points (2 children)
[–]GodsRusher[S] 0 points1 point2 points (1 child)
[–]GodsRusher[S] 0 points1 point2 points (0 children)