Search Unity

Invalid state of a gameobject in the Inspector

Discussion in 'Editor & General Support' started by RicCx, Feb 9, 2018.

  1. RicCx

    RicCx

    Joined:
    May 3, 2016
    Posts:
    3
    Hello,

    In our project we found some GameObjects in a strange state, they look both active and inactive at the same time in the Inspector. Active because their checkbox is checked, but inactive because their "cube" icon is greyed out. I have attached an image to show this.

    UnityDisabledGoInspector.png

    These objects don't work properly in the player, like they are invisible but their scripts are partially running.
    By disabling and re-enabling them they get their coloured icon back, a blue cube in our case as they are part of a prefab.
    And it is strange that, even if we fix them by disabling and re-enabling them, they don't get saved when we save the scene, and we find them in the same undefined state when we reload the scene.

    It happens on both Unity 5.6 and 2017.

    I would like to know if this is a valid state for a GameObject and what it means, please. Or if it is a corrupted state and if you know how that can happen so we can avoid it.

    Thank you

    Riccardo
     
    Last edited: Feb 9, 2018
  2. RicCx

    RicCx

    Joined:
    May 3, 2016
    Posts:
    3
    After further investigation I realised this state in Inspector is valid, it simply means that GameObject.activeSelf == true and GameObject.activeInHierarchy == false.
    The problem is that we have a GameObject which is in this state, but all its parents are active as well. This means that we have a GameObject on a scene with all its parents active, that it is active itself, but which has his member activeInHierarchy set to false, which is obviously wrong.

    I don't know how it could get into this state, but it behaves very strangely and there is no way to fix it for good. If we fix it by re-activating the GameObjects and saving the scene, when we reload it the GameObject is again in this broken state.

    Riccardo