Author Topic: How can I do a preview?  (Read 5454 times)

TokyoDan

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 53
    • View Profile
How can I do a preview?
« on: May 08, 2014, 06:58:00 PM »
Hello Aren,

In my board game the boards are maps of 3D objects:
https://www.dropbox.com/s/k5ev9ho2iuqmjhs/board.png

Via the six board selection buttons on this screen I can select different board shapes and sizes :
https://www.dropbox.com/s/y7kdp0y68f8qtwp/selection.png

I want to be able to show a small preview (like a mini-map) of the corresponding board when I tap and hold on the board selection buttons.

What would be the best way to do this in NGUI? e.g. Should I use UITable? I don't need a detailed explanation. Just please point me in the direction of which NGUI classes/objects I should use.

Regards,
Dan
« Last Edit: May 08, 2014, 07:04:25 PM by TokyoDan »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How can I do a preview?
« Reply #1 on: May 09, 2014, 05:37:14 AM »
Depends on how flexible you want it to be. One way would be to have an off-screen camera draw the 3D objects into a texture that you would then display using UITexture. Another way would be to have static pre-generated textures loaded and swapped as necessary. Even if going down the "let's instantiate a bunch of widgets for the preview!" route, I wouldn't use a table. Your object positioning there is custom. I'd write a custom script to position the sprites.

TokyoDan

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 53
    • View Profile
Re: How can I do a preview?
« Reply #2 on: May 09, 2014, 06:23:13 AM »
Thanks Aren.

I already got the custom script which draws the mini-map (a flat cube as a base & background) by placing the 3d objects as positions on the flat cube, making them children of the flat cube, and then scaling everything down to a properly sized mini-map. But I like your idea of an off-screen camera drawing the 3D objects into a texture so I have one question…

How does one draw 3D objects into a texture? (I never heard of that)

Regards,
Dan

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How can I do a preview?
« Reply #3 on: May 09, 2014, 06:44:53 AM »
Look into render textures in Unity. You create a render texture, assign it to a camera, and disable the camera. When you want to update the render texture, call the camera's Render() function.

TokyoDan

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 53
    • View Profile
Re: How can I do a preview?
« Reply #4 on: May 10, 2014, 04:28:08 AM »
Will do. Thanks.