Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

My GameObject is invisible?

Discussion in 'Scripting' started by MindGem, Jan 20, 2018.

  1. MindGem

    MindGem

    Joined:
    May 11, 2017
    Posts:
    84
    I'm trying to learn how to add Drag&drop on a GameObject and I manage to do it with an image but if I try it on a GameObejct is disappear, and not when I click it as it was the position that was out of range but in edit mode as well. Why is that, what am I doing wrong.

    In my 2D scene. I have a canvas. Inside the canvas I have my default image (white square)
    and also I created an empty gameobject and added a sprite image inside of it.

    In edit mode I see them both when zoomed out but when I zoom in on them at a sertain point the gameobject will go invisible.

    Anyone know what this is?

    I made a few second long video showing this.
    http://graffiticreator.net/orders/invisible.mp4
     
  2. WarmedxMints

    WarmedxMints

    Joined:
    Feb 6, 2017
    Posts:
    1,035
    Look at the Z position of the child objects.
     
  3. MindGem

    MindGem

    Joined:
    May 11, 2017
    Posts:
    84
    They're different. What is the Z position suppose to be?

    I tried setting them all to the same. x71,y71,z0.
    no difference.
     
  4. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    I wouldn't recommend putting sprites on the canvas; just use the canvas for UI stuff.
    I know that's not a full answer maybe, as I do not know why it disappears, but it's good practice, imho.
     
  5. WarmedxMints

    WarmedxMints

    Joined:
    Feb 6, 2017
    Posts:
    1,035
    Uncheck the 2D view and pan your camera around, that should reveal the issue for you.
     
  6. MindGem

    MindGem

    Joined:
    May 11, 2017
    Posts:
    84
    Okay. That is what Im trying to figure out, what to use.

    So what I want to do is have a character, a head, a torso, legs and arms inside something. So later I can
    instantiate several of it and in run mode manipulate the colors of each limb. something like a dress doll.

    How do I go about doing that?
    I'm not asking for a long description, just..what do I put my images in?
    And how do I make sure my limbs are at the correct place in relation to eachother.
    I want to do this in 2d.
     
  7. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    You could do it in the canvas, I suppose. There they would have to be images, though. (UI->Image). Image is a script, and it does take a sprite; it's just that it's designed to work with the canvas.

    I think it might be better to just do it in the world, though. That's where sprites are supposed to be. I'm pretty sure about that. :) These sprites I mention are the (Create -> 2D -> Sprite). :)

    If it's just for 'dressing' and not playing, I'd say either is okay. If it's for playing, I would lean towards the sprite in the world as opposed to the canvas.
     
  8. maumitak

    maumitak

    Joined:
    Nov 25, 2021
    Posts:
    1
    i am a beginer my prototype 1 road is there on the camera but not on scene view can anyone help
     
  9. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,599
    Please don't repost to four-year-old unrelated threads. Start your own fresh post, it is FREE.

    When you post, keep this in mind:

    How to report your problem productively in the Unity3D forums:

    http://plbm.com/?p=220

    In order to make a useful post, here is how to study your current setup, otherwise nobody here can help you:

    You must find a way to get the information you need in order to reason about what the problem is.

    What is often happening in these cases is one of the following:

    - the code you think is executing is not actually executing at all
    - the code is executing far EARLIER or LATER than you think
    - the code is executing far LESS OFTEN than you think
    - the code is executing far MORE OFTEN than you think
    - the code is executing on another GameObject than you think it is
    - you're getting an error or warning and you haven't noticed it in the console window

    To help gain more insight into your problem, I recommend liberally sprinkling Debug.Log() statements through your code to display information in realtime.

    Doing this should help you answer these types of questions:

    - is this code even running? which parts are running? how often does it run? what order does it run in?
    - what are the values of the variables involved? Are they initialized? Are the values reasonable?
    - are you meeting ALL the requirements to receive callbacks such as triggers / colliders (review the documentation)

    Knowing this information will help you reason about the behavior you are seeing.

    You can also put in Debug.Break() to pause the Editor when certain interesting pieces of code run, and then study the scene

    You could also just display various important quantities in UI Text elements to watch them change as you play the game.

    If you are running a mobile device you can also view the console output. Google for how on your particular mobile target.

    Another useful approach is to temporarily strip out everything besides what is necessary to prove your issue. This can simplify and isolate compounding effects of other items in your scene or prefab.

    Here's an example of putting in a laser-focused Debug.Log() and how that can save you a TON of time wallowing around speculating what might be going wrong:

    https://forum.unity.com/threads/coroutine-missing-hint-and-error.1103197/#post-7100494