Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Avoiding code execution in UIBuilder

Discussion in 'UI Toolkit' started by James_SI, Jun 24, 2021.

  1. James_SI

    James_SI

    Joined:
    May 25, 2021
    Posts:
    7
    I'm creating a custom widget that does some attribute processesing work in their traits class and for various reasons I want to be able to block some code or change it's behaviour if it's run in the UI Builder (apart from anything else it doesn't actually work in UI Builder).

    Is there something I can test to distinguish between run-time and UI Builder execution?
     
  2. martinpa_unity

    martinpa_unity

    Unity Technologies

    Joined:
    Oct 18, 2017
    Posts:
    471
    Hi, there isn't any way to distinguish between run-time versus UI Builder. When the element is passed to the traits class, it is not added to the hierarchy yet. The uxml file is also not reloaded when going in "preview" mode.

    Can you elaborate on the various reasons?