Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  3. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Disabling entity that has rectTransform throws error

Discussion in 'Project Tiny' started by TrashestCoder, Jan 23, 2019.

  1. TrashestCoder

    TrashestCoder

    Joined:
    Jan 27, 2017
    Posts:
    14
    This function:
    world.addComponent(answer3Button,ut.Disabled);
    should disable entity "answer3Button", but if entity has rectTransform component instead of Transform component I get this error:
    upload_2019-1-23_17-2-51.png
    Am I missing something, maybe there are better ways disabling enity?
     
  2. Nkon

    Nkon

    Unity Technologies

    Joined:
    Jun 12, 2017
    Posts:
    65
    Hi there,

    I tried to reproduce this but so far I didn't have any luck.

    My setup was very simple, I had an UICanvas, and inside of it a sprite (with RectTransform and Sprite2DRenderer components). With this setup I was able to disable the sprite without any errors, by adding the ut.Disabled component to it.

    I also tried adding children with various components to the sprite, but didn't get any errors even in this case.

    I suppose you are doing something a bit more complicated. Could you give more details about the entities you're trying to disable? For example:
    - What components do they have?
    - Do they have child entities?
    - What components do the children have?

    The error you posted concerns an entity with the name 'Answer 1' but your code example seems to disable something that is referenced by answer3Button. Are you sure it is the same entity?

    Also, could you give a rough outline of the systems that are operating on the buttons and their children? More code examples about this would help us to better understand the issue.

    Cheers!
     
  3. TrashestCoder

    TrashestCoder

    Joined:
    Jan 27, 2017
    Posts:
    14
    Thanks for in depth response it helped me a lot at finding solution!

    Disabling started working when entity didn't have childs. Once I add one child the same error pops up. So solution that helped me prevent this issue was disabling childs first and only then disabling father.