- Home /
Can I have a prefab appear on my screen like a gui texture does?
Hello there! I have some objects that I want to appear them on the screen but don't want them to be affected by the main camera. The whole purpose is that, it will appear some models on the side of the screen, and the player will drag them to plot on an another object. first I would use the image of my models as gui textures, but I want them in 3d, beacuase i'll rotate them around themselves untill the user grabs it. What might be a solution to this?
@moghes I tried this for the first time last week. I only have one object, but it does the same basic things you want. I ended up parenting a placement GO to the main camera. Then spawn an instance of my model at the placement. This may be tough will lots of objects, and it takes some time fiddling with the actual placement.
The better solution would be to have another camera that renders those objects to the main screen. Im not entirely sure how to do this, though im sure a little searching will provide the answers you would need. You will run into problems with the click drag portion in that case tho.
@hijinxbassist thank you, finally I solved everything! and concerning the drag and drop, you were right, it bothered me, but in my game, I am destroying my prefab and Instantiating a similar one at the mouse position and setting its layer to the default layer, also I had to use WorldToScreenPoint in the secondary layer and ScreenToWorldPoint to plot again in the default layer
Answer by moghes · May 30, 2012 at 11:04 PM
I resolved this issue with the help of hijinxbassist, so i'll explain for others who search for this problem. here's the steps: - click on the prefab that you want to appear on the top of everything else - go to the inspector and add a layer and call it "topLayer" or anything you wish - set the layer of your prefab to "topLayer" or the one you added. - create an another camera and in the inspector . set the 'Clear flags' to depth only . open the 'Culling Mask' drop down and tick besides the "topLayer" . set the depth to 1 since the main camera has a depth of 0 - just above the depth, set the position and size of the camera that you want it to appear on the top of the main camera view. - If your prefab appears also from the main camera, you can simply change the culling mask of the main camera by deselecting the layer you want to appear.
Your answer
Follow this Question
Related Questions
Multiplying GUIs 0 Answers
iPhone GUI Texture (TouchPad prefab) not working 2 Answers
Triggering Main Camera Script with GUITexture 1 Answer
GuiTexture and Split Screen 1 Answer
Camera problems 2 Answers