Search Unity

Problem with PrefabUtility editor script

Discussion in 'Editor & General Support' started by JonnyHilly, Jan 21, 2021.

  1. JonnyHilly

    JonnyHilly

    Joined:
    Sep 4, 2009
    Posts:
    749
    I made an Editor script to search through all game assets, looking for prefabs with TextMeshProUGUI components on them,
    Then it loops through all the prefabs, loads the PrefabAsset contents, then adds my component to the same game object (that has the TMP script on it), then saves it using PrefabUtility.ApplyPrefabInstance.
    then unloads the loaded prefab.

    This works fine for most all of the assets in the project... except for 20 or so, it logs an error...
    "referencing an asset from the previous import. This should not happen"

    What does this mean, and why? why is the code good for nearly all assets except for these please?
    Is it a unity bug? is it when there are nested prefabs, or prefabs with several occurrences of TextMeshProUGI on the same prefab ?
    or maybe nested prefabs, where the nested prefab also has TextMeshProUGUI ?

    Is there a way to find if the TextMeshProUGUI is on a Nested child component ?
    Unity 1019.3

    thanks in advance for any ideas or help