ReferenceEquals?
Am I missing something obvious?
This is Unity, TMPro.
If
text.textInfo.meshInfo[0].mesh
and text.mesh
are pointing to the same instance - how come the vertices property of the same instance doesn't return true
?25 Replies
Are those classes or structs
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
If they are structs, your dealing with value types, which get copied
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Vectors are structs
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
It's an array of value types though
Aren't arrays reference types?
Vertices is?
If text.textInfo.meshInfo[0].mesh and text.mesh are pointing to the same instanceif
mesh
is a value type, those are not "pointing" to the same instance
mesh
is the value itself
so reference equality for a value doesn't make senseMesh returns true
right
vertices
:p
but still
Unless I'm misinterpreting the result, looks like an array of structs, yeah
hm
possible that
vertices
is a property that happens to be returning a new instance of array everytime it's called?Your sure you are pointing at the same array?
This wouldn’t be the first time ive seen unity do strange things
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Ah, yeah, it's a getter that returns a copy apparently, had to view the actual implementation to see that
Idk why the IDE didn't show the doctsring, and why it's nowhere in the docs (nowhere I could find anyway)
yeahhhhh
unity is funky
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
UnityDoesWeirdShit++
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Yeah, the TMPro documentation is honestly kinda useless
I'm still in the process of trying to figure out what the difference between
text.textInfo.meshInfo[0].mesh.vertices
, text.mesh.vertices
and text.textInfo.meshInfo[0].vertices
isThe documentation for all of them is just this which is very helpful lol
One youtube video said this:
And I'm not really sure if that's true, if accessing the property always returns a copy - what's the point
Maybe one of these doesn't return a copy in some cases
Not according to the docstring though
text.textInfo.meshInfo[0].vertices
this one is an actual array within the meshInfo struct
I'll place a few breakpoints to hopefully figure out what it's doing under the hood
In any case
That's another can of worms
So what's the procedure here once a post has been solved, do I close it or do I leave it as it is?you can /close or just leave it