Drag items world to ui issue

Hi all,

Trying to transition to Unity UI from 2dtoolkit finally and wanted to ask some questions / if this is the right approach…

  1. I have some buttons in game, I want some to float above the game fixed to the camera, and other buttons to sit below the sort order of some items in the 2d scene, but still stay fixed to the camera.

Right now I have one camera for the gui and a Canvas linked via Screen Space, and a game camera that has a Canvas as a child linked via World Space. The game camera is the parent of the world space canvas, because I couldn’t figure out how to make the world space canvas stick with the game camera as it moved (without scripting, I mean in options).

I am using a ui camera and a game camera as sometimes the game camera is switched to a different cam that has no world space buttons visible, but I always want the ui camera to show on top.

This approach look ok or any potential issues?

With the game camera and world space canvas, I want to be able to drop 2d items from the game using the mouse over a Button to trigger an action. What’s the best way to do this? The button doesn’t have 2d physics box does it?

Can I make invisible buttons? When I disable the Image script on a button, the button action no longer works.

Many thanks
Chris

I can answer 3 pretty quick. Just set the alpha on the image to 0 and it will be an invisible button.

Trying to explain myself better, please see image attached to this post.

  • have a ui camera and a screen space canvas with a blue button

  • have a game camera, with green objects that i want to be able to move in front of the orange button

  • the orange button needs to sit in sort order above other objects in the scene (dark green)

  • if the orange button is part of the game camera in a world space canvas, when i zoom the camera it changes the size of the button

any thoughts would be great, thanks

2943554--217888--Screen Shot 2017-02-01 at 18.00.24.png

@coshea_1

Hi there!

Do you have a special need for having orange button on game camera?

I’ve got no idea what it’s for, is it part of world, i.e. local to some spot in 3D world… that would explain it…

but anyway, other than that if you need to show some UI item in front of other objects, if it’s UI object, you can just change it’s Transform’s order in hierarchy using SetAsLastSibling… If it’s 3D object, then I don’t have an answer.

@coshea_1

Actually, if you need to sort world space UI relative to world objects, like having a floater above item that renders over all world objects, but floats in world space…

It’s a matter of creating two cameras, then other renders UI and only UI, and main camera renders 3D objects; then UI piggybacks main camera transform, then make main camera farther away in it’s sorting order…