Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Add missing events to Unity (eg for transform.position / rotation or gameObject.parent)

Discussion in 'Assets and Asset Store' started by ChrisHandzlik, May 17, 2020.

  1. ChrisHandzlik

    ChrisHandzlik

    Joined:
    Dec 2, 2016
    Posts:
    198
    If you were ever looking for a way to write more event driven code in Unity you probably found that it's not so easy at least not with some very basic classes like Transforms.

    This tool will help you to add those events directly to Unity classes. It's highly customisable and you can specify targets yourself, just a few examples

    - Transform position / rotation / scale would be handled with
    Code (CSharp):
    1. transform.SetPositionExecuting += (sender, e) => <your handler code>
    2. transform.SetRotationExecuting += (sender, e) => <your handler code>
    3. transform.SetScaleExecuting += (sender, e) => <your handler code>
    - GameObject.parent would be handled with
    Code (CSharp):
    1. gameObject.SetParentExecuting += (sender, e) => <your handler code>


    All open source and can be found here
    https://github.com/handzlikchris/Unity.MissingUnityEvents
     
  2. Michael-Ryan

    Michael-Ryan

    Joined:
    Apr 10, 2009
    Posts:
    184
    The tool works well. Thanks for making it available.

    In some UI code, I was setting the anchorPosition of a ScrollRect's Content object to 0,0, but a few frames later, the anchorPosition was different. I couldn't figure out what was causing it and suspected it was something in Unity's UI layout code.

    It turns out Unity's ScrollRect component was changing the anchorPosition in ScrollRect.LateUpdate(). Without this tool, it would have been difficult or impossible to determine the cause.
     
    ChrisHandzlik likes this.
  3. ChrisHandzlik

    ChrisHandzlik

    Joined:
    Dec 2, 2016
    Posts:
    198
    I've been working on a visual transform debugger, that makes this tool incredibly simple to use and adds a nice GUI to use.

    It's now available on asset store

     
    Last edited: Nov 15, 2021