Search Unity

GetCorrespondingObjectFromSource issue

Discussion in 'Prefabs' started by Ng0ns, Jun 6, 2019.

  1. Ng0ns

    Ng0ns

    Joined:
    Jun 21, 2016
    Posts:
    44
    Hello good people.
    I'm trying to figure out how to get the original name of a prefab (through an instance of it).

    I would assume this did it when called on a instance, but all I get is null.
    Code (CSharp):
    1. PrefabUtility.GetCorrespondingObjectFromSource(gameObject).name
    What gives :)
     
  2. estebaniakl

    estebaniakl

    Joined:
    Jul 4, 2019
    Posts:
    5
    I have the same problem. Dont know yet how to solve it!! anyone please
     
  3. runevision

    runevision

    Unity Technologies

    Joined:
    Nov 28, 2007
    Posts:
    1,636
    That should work.

    You are not by any chance doing this in Play Mode? Prefab instances don't exist as such at runtime (including Play Mode); they're converted to regular GameObjects.

    If not that, then I can't say what's causing it without more information about that gameObject you're calling it on.