Author Topic: NGUI - real WYSIWYG in scene view  (Read 4637 times)

NikolayLezhnev

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 1
  • Posts: 4
    • View Profile
NGUI - real WYSIWYG in scene view
« on: June 27, 2014, 03:41:11 AM »
Unity in editor mode with active 'SceneView' and hidden 'GameVeiw' always report Screen.width and Screen.height as 640x480. Camera.pixelRect also return rect with the same size. Camera.ViewportToWorldPoint and Camera.ScreenToWorldPoint return result for 640x480.
You can see this problem in video: https://www.youtube.com/watch?v=_CqKkphYflE
As result, in 'Scene view' you have different NGUI UI image, not the same as GameView.
To fix this behaviour, I made changes in NGUITools.cs, UIRoot.cs and UIAnchor.cs (see attached NguiWysiwig2.diff)
And I added AlignCameraToUI - it's constraints 'Scene View' camera to UI bounds and give you exactly the same picture, as 'Game View'. You can Turn on/off it in menu "NGUI/Extras/Enable Align to camera to UI"
I hope to see similar changes in next releases of NGUI.
Sorry for poor english.


Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: NGUI - real WYSIWYG in scene view
« Reply #1 on: June 27, 2014, 08:07:38 AM »
Looks cool!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI - real WYSIWYG in scene view
« Reply #2 on: June 27, 2014, 12:16:13 PM »
Thanks. I've used your code to implement a similar solution that fixes regular anchors (as you only adjusted legacy anchors), fixes clipping region previews, takes fixed size UIRoot into account, camera clip rect, and a few other things -- so with the next release NGUI should be able to handle hiding game view behind scene view without any issues.

NikolayLezhnev

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 1
  • Posts: 4
    • View Profile
Re: NGUI - real WYSIWYG in scene view
« Reply #3 on: June 28, 2014, 10:42:54 AM »
Thanks. I've used your code to implement a similar solution that fixes regular anchors (as you only adjusted legacy anchors), fixes clipping region previews, takes fixed size UIRoot into account, camera clip rect, and a few other things -- so with the next release NGUI should be able to handle hiding game view behind scene view without any issues.
Thank you. Did you look on AlignCameraToUI.cs?
It's constrain scene view to UI, I think it's may be useful feature for NGUI

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI - real WYSIWYG in scene view
« Reply #4 on: June 28, 2014, 04:43:06 PM »
Can you elaborate on that? What do you mean by constraining the scene view to UI?

NikolayLezhnev

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 1
  • Posts: 4
    • View Profile
Re: NGUI - real WYSIWYG in scene view
« Reply #5 on: June 29, 2014, 04:59:08 AM »
Can you elaborate on that? What do you mean by constraining the scene view to UI?
In AlignCameraToUI.cs I get UI camera position and orthographic size, and set it to "scene view" camera (if scene view is ortographic). As result, you see in "scene view" exactly the same picture, as in "game view". If you add this script to project, you can switch it in menu "NGUI/Extras/Enable Align to camera to UI"
You can see what I mean: http://www.youtube.com/watch?v=slgnzTwLCE0

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI - real WYSIWYG in scene view
« Reply #6 on: June 29, 2014, 08:55:54 PM »
Ooh, I like that.. thanks!