'Driven by' - is there a way to do this from our own scripts?

Would it be possible to, for a component I write that controls the position of a RectTransform, have the controls grayed out just like when they are ‘driven’ by other builtin components?

Better yet, could we also do this with regular Transforms? It’d be a really nice improvement to the workflow.

It looks like there is a DrivenRectTransformTracker that you can add your RectTransforms to to disable. It looks like that’s RectTransform specific though.

Yes, use the DrivenRectTransformTracker to drive RectTransforms.

Every time the layout is updated, you should first call Clear on it, and then add the RectTransforms you want to drive, one by one. Then you can set the properties on the RectTransforms you’ve set as driven.

Make sure to also call Clear in OnDisable of your component.

The ability to set properties as driven is specific to RectTransform and can’t be used for anything else in Unity.

2 Likes