Search Unity

Feedback Need a callback when changing Transform

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

  1. Lesnikus5

    Lesnikus5

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

    https://forum.unity.com/threads/tra...etter-if-replaced-by-a-version-number.700004/
    https://forum.unity.com/threads/more-transform-callbacks.263448/
    https://forum.unity.com/threads/detecting-changes-to-transform.625309/
    https://forum.unity.com/threads/how-can-i-intercept-changes-to-a-transform.263361/
    https://forum.unity.com/threads/transform-modification-callback-support.280439/

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

    Code (csharp):
    1.  
    2. public GameObject exampleObject;
    3.  
    4. void Awake()
    5. {
    6.      exampleObject.transform.OnTransformChanged += ReactToChange;
    7. }
    8.  
    9. void ReactToChange(Transform tr)
    10. {
    11.      Debug.Log(tr.name + " 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