Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Feedback Need a callback when changing Transform

Discussion in 'Editor & General Support' started by Lesnikus5, May 15, 2020.

  1. Lesnikus5


    May 20, 2016
    I really need a onTransformChanged() callback when changing the Transform. You can see that there are many requests for this function:

    I'll take an example of how this could be used:

    Code (csharp):
    2. public GameObject exampleObject;
    4. void Awake()
    5. {
    6.      exampleObject.transform.OnTransformChanged += ReactToChange;
    7. }
    9. void ReactToChange(Transform tr)
    10. {
    11.      Debug.Log( + " position was changed");
    12. }
    I hope one of the developers read this and put it in the "to do" list.

    Now about why I need it personally.
    I want to implement CullingGroup for dynamic objects (including rigidbody). To update the positions of the BoundingSpheres, I could use a callback when changing the transforms of the objects, then this would not affect the performance as much as manually scanning each object in the list and checking its transform.hasChanged in each frame.
    Last edited: May 15, 2020