imagicbell / ublockly

reimplementation of google blockly for Unity
http://imagicbell.github.io/unity/2017/10/11/blockly-one.html
Apache License 2.0
140 stars 54 forks source link

Integration in Oculus Quest 2 #27

Closed HerrAugust closed 3 years ago

HerrAugust commented 3 years ago

Hi,

I would like to use this project in a virtual world created for Oculus Quest 2. Is there any way to visualize this program in a Canvas? I mean, I do not want the program to take all the space, I want to embed it in my virtual world, as shown in the attachment.

Thanks! Screenshot 2021-07-21 105307

imagicbell commented 3 years ago

Of course. It is all about how you set the canvas and camera of the workspace.

  1. set the RenderMode of Canvas to World space.
  2. set your 3D camera as the render camera of the Canvas.

image

HerrAugust commented 3 years ago

Hello,

Thank you for your feedback, actually I could make it work. However, it seems that drag&drop does not work properly and I run out of ideas. The video shows the not working parts, any idea for the drag&drop?

Thanks again!

https://user-images.githubusercontent.com/5053385/126512178-518b33d3-0fea-4d5a-9e95-42ee204ea9d0.mp4

imagicbell commented 3 years ago

It works fine with me, please see the video. I guess maybe there is something wrong with your pointer position map. https://user-images.githubusercontent.com/2181062/126595064-cd768336-9e40-4ae9-8b88-c8181b27661d.mov

HerrAugust commented 3 years ago

Hello and thank you for your feedback. Yes, with the mouse it works great. My problem comes when used on Oculus Quest 2 and using the controller with ray-casting.

https://user-images.githubusercontent.com/5053385/126512178-518b33d3-0fea-4d5a-9e95-42ee204ea9d0.mp4

HerrAugust commented 3 years ago

Just a quick discover, it seems that the blocks can be moved around with the head (but only with its rotation) once you put them on the programming box. The Oculus Quest 2 controllers do not work properly instead. Any tip?

imagicbell commented 3 years ago

Please check the position calculation code when dragging blocks in BlockView.cs: OnBeginDrag, OnDrag. I use a helper function RectTransformUtility.ScreenPointToLocalPointInRectangle to calculate the local position of blocks from mouse position. There might be some additional work to do with 3D conversion. I haven't tried Oculus Quest 2. Sorry that I couldn't help you more currently.