gameObject.transform.localPosition from different thread

Dear All,
I can understand that modifying a transform from a different thread is forbidden (honestly I used Open Scene Graph library without such architectural limitations!). But, why also getting data of a transform it not possible? What’s the problem if the returned values are copied? Please tell me that’s a solution because this seems crazy to me.

Regards,
Gianni

So, nobody works with multi threading?

UP

Can you give some information about what you’d be doing with the data? Perhaps copying it yourself to use in the other thread, or a coroutine solution might be suitable.

I have a Thrift server in another thread. A different application uses Thrift calls to get values from Unity. One of them returns the position of a GameObject. I must return a value from the Thrift call otherwise the calling application hangs.

I can of course duplicate values, and indeed it is what I had to do, but I’m sorry I don’t like that at all. Data duplication implies synchronization, that may be an hard job in some cases.
Anyway the point is simple from my point of view: why is not possible to get the transform position in read only mode? Even if Unity code is (surprisingly!) not thread safe, it would be better to return something (I mean the transform position) instead of forbid a call .

The Unity API is simply not thread safe. So the reading of a Vector3 cannot be guaranteed as being successful. You could potentially read mixed values by reading at the same time as the Unity thread is updating it.

Having said that, what error message are you getting when you read the Vector3?

This is not surprising. Remember that Unity is going for all out speed. Thread safety isn’t free, it comes with performance costs and considerations of its own.