Search Unity

Question GetInstanceID != EditorApplication.hierarchyWindowItemOnGUI

Discussion in 'Editor & General Support' started by Vifi, Jul 7, 2022.

  1. Vifi

    Vifi

    Joined:
    Aug 5, 2013
    Posts:
    28
    Hi! I am writting this tool to mark prefab changes in hierarchy view. (I know Unity now has one but i want it to expand to mark also exacly item that has changes instead of just prefab root).

    So my tool is working on InstanceID. I am taking it from object that has to be marked, store it and then comparing it with instanceID provided by EditorApplication.hierarchyWindowItemOnGUI delegate.

    Well... it doesn't work. It seems to work with prefab roots and other objects, but with prefab childrens not.

    Here is some example:

    I have prefab instance with root of GameObject. Its childrens are simple Plane and Sphere whitch is also Prefab on its own. Both chlidren has some changes in them relative to GameObject prefab.

    My array with marked objects looks like this: It is name, GetInstanceID() method, and if it should be marked or not.

    1. Code (CSharp):
      1. Marked Objects:
      2.    GameObject: -14274 True
      3.    Plane: 114764 True
      4.    Sphere: 114798 True
    On the other hand EditorApplication.hierarchyWindowItemOnGUI iterate through hierarchy gives me:

    1. Code (CSharp):
      1. Item: -14274: GameObject
      2. Item: -14278: Plane
      3. Item: -14298: Sphere
    It is ID and name of gameObject i took from "EditorUtility.InstanceIDToObject(instanceID);"

    I could do it by comapring gameObjects but i think that would be not optimal.

    Do any of you know what is going on and how to fix it?

    Thanks in advance! Cheeers!