Open DarkRewar opened 5 months ago
Two problems:
AutoField<T>
?Let's admit that AutoField<T>
could be like this:
[Serializable]
public class AutoField<T> where T : Component
{
[SerializeField]
private MonoBehaviour _parent; // How do we get it?
private T _value;
public T Value
{
get
{
if (_value == null)
{
_value = _parent.GetComponent<T>();
}
return _value;
}
}
public AutoField()
{
// maybe we can access parent object here? But how?
}
}
AutoField<T>.[Value]
?On option was to create an implicit operator, but it doesn't seem to work...
public static implicit operator T(AutoField<T> instance) => instance.Value;
Create class that retrieves by
GetComponent
the field it is looking for when code needs to access it.