Search Unity

Prefab not visible when building

Discussion in 'Prefabs' started by CDAfonso, Sep 23, 2019.

  1. CDAfonso

    CDAfonso

    Joined:
    Sep 16, 2019
    Posts:
    26
    Hello,

    I have this instantiated Prefab that is visible in scene and game view, but when i build & run, it doesn't show up.
    It shows on the camera view also.


    Any clues about what's happening?
     
  2. nersons_skatt

    nersons_skatt

    Joined:
    Dec 11, 2020
    Posts:
    9
    I have the exact same issue. In addition, for me, the prefab is shown if it is loaded from the start, but not if it is instantiated during runtime. So anything I add to the scene in the editor is shown. But if I Instantiate the exact same prefab from code, it is not shown in my builds, just in scene view and game view in the editor. Very frustrating. Let me know if you find any way to resolve this issue....
     
  3. nersons_skatt

    nersons_skatt

    Joined:
    Dec 11, 2020
    Posts:
    9
    Hi again. Your post is from 2019, but in case anybody else is reading, this is probably due to the execution order of scripts may vary between the editor and the builds. For me, the objects I was trying to instantiate was UI elements, and they should belong to a canvas parent. However, the canvas transform was assigned in the Start() method of a script, while the cards were being created before that script executed its Start(). That means the cards were instantiated, but did not have its coordinates in relation to the canvas, but in world space. I could probably have noticed this by adding using LookAt with the camera, to see that the cards were actually there, but in a weird place.
     
  4. zoudarren7

    zoudarren7

    Joined:
    Jul 24, 2019
    Posts:
    11
    thank u papi