Not a Bug

setting RaycastResult values fail ONLY when it is in a List.

Vong 2 years ago updated by Lazlo Bonin (Lead Developer) 2 years ago 1

Edit: Solved - RaycastResult is a Struct

Encountered some weirdness where I could get/set values in a RaycastResult just fine.
But put that RaycastResult in to a List and, while I could still get values from it, I could no longer set values..

Attached image is me trying to isolate it as much as possible (hitting the Manual Events on the left first, from top-to-bottom, then the ones on the right) Hopefully reproducible. The mid-right test showing that referencing the Chained RaycastResult gave a different value than referencing it directly from the List..

Bolt Version:
Unity Version:
Scripting Backend:
.NET Version (API Compatibility Level):
Not a Bug

Hi Vong,

As you noticed, RaycastResult is a struct, it therefore has copy-on-write semantics, and what you're updating is a copy of the list item. Unfortunately this is by design in C# and not something we can fix.