Version: Unity 7.0 Alpha (7000.0)
LanguageEnglish
  • C#

RefRW<T0>.ValueRW

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

public ref T ValueRW;

Description

Returns a writable reference to the component value itself.

This value is a reference to the actual component data. It is safe to use this field directly, e.g. "Data.ValueRW.SomeField = 123". It is also safe to make a copy of this value, e.g. "var myComponent = Data.ValueRW". Keeping a ref ("ref var myref = Data.ValueRW" is inherently unsafe as any structural change may invalidate this reference, and there is no way to detect this. It is safe to use this reference locally if you can guarantee that no structural changes will occur in between acquiring it and using it. Do not hold on to such a reference for any extended amount of time.