Search Unity

3D prefab from Blender invisible in Game view after instantiating

Discussion in 'Scripting' started by petediddy, Apr 8, 2015.

  1. petediddy

    petediddy

    Joined:
    Mar 17, 2015
    Posts:
    19
    I created a mesh in Blender and imported to Unity as a prefab. I'm now instantiating the prefab from a script, and I can see the instance in the Scene view in Unity Editor, but it doesn't show up in the Game view... the prefab is made up of a handful of 3D native objects in Blender, and when imported to Unity, each of the child shapes has a mesh renderer. Any ideas why I can't see the instance in the Game View? Probably something dumb... thanks in advance! I'm attaching a screenshot of the editor showing the issue. You can see the tiny instance in the bottom of the Scene view, but it's not showing in Game view.

    After doing some digging, I realized I needed to parent the instance of the prefab, and I've also added a scale adjustment to increase the size (it was really tiny without the adjustment... still too small, but at least I can tell it's being instantiated in the Scene view at this scale). Here's the instantiate command, along with the parent command for the instantiated object and the scale adjustment.

    Code (csharp):
    1.  
    2. GameObjectmyMonkeyHead = Instantiate(monkeyHead);
    3. myMonkeyHead.transform.parent = panelRef.transform;
    4. myMonkeyHead.transform.localScale = newVector3(10, 10, 10);
    5.  
    -pete
     

    Attached Files:

  2. hpjohn

    hpjohn

    Joined:
    Aug 14, 2012
    Posts:
    2,190
    Is the object in sight of the MainCamera?
    The UI Canvas is not meant to have world objects in it, and it doesn't have an associated rendering camera to pick up those other objects
     
    petediddy likes this.
  3. petediddy

    petediddy

    Joined:
    Mar 17, 2015
    Posts:
    19
    That was it - thanks hpjohn! ... just needed to move the main camera to pick up the object, as it was instantiating on almost the exact same position as the camera and the camera's viewport was missing it. Thank you so much!