BaseTool icon indicating copy to clipboard operation
BaseTool copied to clipboard

Add AutoField<T> to retrieve components automatically

Open DarkRewar opened this issue 9 months ago • 1 comments

Create class that retrieves by GetComponent the field it is looking for when code needs to access it.

public class MyComponent : MonoBehaviour
{
    public AutoField<Rigidbody> Rigidbody;

    public void Start()
    {
        // will retrieve rigidbody automatically if not found
        Rigidbody.velocity = transform.forward;
    }
}

DarkRewar avatar May 03 '24 12:05 DarkRewar