![]() ![]() To learn more about HTML and CSS, head on over to w3schools (HTML) and w3schools (CSS) to learn more. If you’re new to Unity development, check out this great Getting Started in Unity tutorial. In that case, you can create your own raycast system for dragging, like already mentioned in previous answer.Note: This tutorial assumes that you know the basics of Unity development, HTML and CSS. Here I'm dragging sprites using the same UI events, using IBeginDragHandler, IDragHandler, IEndDragHandler:Īs you are talking about "2D perspective" this should work.īut if you are going for full 3D world, I can't recall if there was some obstacles with above method. ![]() Drop should also work, but note / you are not going to have the luxury of having Canvas Groups and such, so you'll have to use layers to avoid hitting dragged object (for example). ![]() Note - as you are not working with Canvas, you'll probably have to convert screen positions to world positions (like I did below). GraphicRaycaster.Īfter this you can detect clicks with the same UI events (BeginDrag, Drag). ![]() Then add a Physics2D or Physics raycaster to your camera depending on what colliders you are going to use on your objects.UI doesn't need these, it has its own "raycaster" i.e. Add EventSystem to your scene simply add some UI element, this will automatically add EventSystem, get rid of the Canvas afterwards, of course you can manually add EventSystem component too.Ģ. IMO there may not be need for going around existing event system, if you need some simple solution, so maybe try this first?ġ. Hi I decided to bring my cards outside of the UI into the 3D World using a 2D perspective (should I use an orthographic camera?)."Īctually events work outside of UI - this is explained in the documentation IIRC. I have several doubts on the camera setup, perspective and other things which are not an issue when you deal with a Canvas an UI Images instead of Sprites. What are my options here? are they built-it methods equivalents to those for UI? does this rely entirely on the usage of ray casting? Let's say I have my 3D URP project, with your regular UI, my camera pointing to some plane or region in the space (either orthographically or with perspective) and then I have my hand on the 3D space which is a bunch of Sprite objects then I want to drop these cards into another region of the screen (World space, no UI) or be able to hold the card in my hand and drag it until it collides with a region or another card in which case I run some method to either drop the card or trigger an action. So I cannot figure out what is the appropriate way to handle this. Apologies if this is an extremely noob question but everything I gathered on forums seems to be either not to be working, obsolete code, or uses UI. Unfortunately, I decided to bring my cards outside of the UI into the 3D World using a 2D perspective (should I use an orthographic camera?).Ĭan someone ELI5, how the Drag and Drop and Input.mouse events work with Sprites and Game Objects in general within Unity. I used to have a Canvas on my prototype card game, where I could listen to events from Input.mouse and then use eventData and all the plethora of methods to simply drag and drop and make an UI object follow the mouse. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |