We want a method IfAbsentCompute<T>(ref T field, Action<T> getter) (or similar) which takes a reference to a field and if that field is equal to it's default (or unity-null) then the getter will be called and the field will be set to that result.
The main use case for this is in Start or Awake methods of cloned or .Instantiated game objects, for which many fields would already be present, and then unnecessesarily recreated.
We want a method
IfAbsentCompute<T>(ref T field, Action<T> getter)
(or similar) which takes a reference to a field and if that field is equal to it's default (or unity-null) then the getter will be called and the field will be set to that result.The main use case for this is in
Start
orAwake
methods of cloned or.Instantiate
d game objects, for which many fields would already be present, and then unnecessesarily recreated.