Futile icon indicating copy to clipboard operation
Futile copied to clipboard

It should be easy to use Futile as a UI layer for 3D games

Open MattRix opened this issue 12 years ago • 9 comments

Figure out what needs to be changed/tweaked so that it's easy to use Futile as UI for 3D games. Also, make a quick under-10-minute video showing how to create text atlases and stuff to make it work.

MattRix avatar Aug 28 '12 20:08 MattRix

You need a way to specify which camera layer (culling mask) the Futile objects use. Also, an easy way to set the Futile camera's clear flags and depth. With those two things it should be easy to get Futile rendering on top of a 3D scene.

darktable avatar Aug 29 '12 17:08 darktable

Yep that's what I was thinking. I mean really Prime31's UIToolkit already does the same thing so I'll probably just do it the same way, I don't think it'll be too tricky.

MattRix avatar Aug 29 '12 20:08 MattRix

I didn't look at UIToolkit but I did quickly hack the ability into Futile for my own personal use. There are probably issues with this approach but it works for my quick prototype:

// --- Right after you call Futile.instance.Init --- //
Futile.instance.camera.clearFlags = CameraClearFlags.Nothing;
Futile.instance.camera.cullingMask = 1 << 11;  //11 - the layer you want to put futile objects on

// --- In FRenderLayer.cs after line 59 where _gameObject is instantiated --- //
_gameObject.layer = (int)(Math.Log(Futile.instance.camera.cullingMask)/Math.Log(2));

Of course there are more efficient ways of going about this and I wouldn't hack this together on any project you want to last but it works fine for a weekend throw away project.

Hopefully this helps someone for the time being!

mbaker3 avatar Oct 16 '12 19:10 mbaker3

Cool, thanks for letting me know, I'll look into it!

MattRix avatar Oct 18 '12 02:10 MattRix

mbaker3's approach worked well for me, with the side effect of having Futile content appear in the MainCamera port too.

I added a named layer via the Unity UI called Futile (in slot 11, same as mbaker3's code), so that I could easily remove that layer from the MainCamera culling mask.

cocoademon avatar Nov 14 '12 06:11 cocoademon

I did a 2 camera approach for a "3D in the background" & "2D in the foreground" game:

  1. Unity 3D camera. Depth=0, Clear flags=Solid color
  2. Futil camera in Futile.cs: Depth=(unchanged, since it's >0), Clear flags=Depth

ghost avatar Feb 12 '13 14:02 ghost

Cool, good to know :)

MattRix avatar Feb 12 '13 15:02 MattRix

I gave every stage a SetCullingLayer...it basically sets this value on every renderlayer (and gameobjectnode) for that stage, the ones that exist and are added later. This makes it easier to support multiple cameras when mixing 2d and 3d and also sets you up for a srollable window for the listview thingy that people want, whether it'll be with masking or with a viewport rect. Also works well for multiplayer and hiding futile layers in your main camera.

bizziboi avatar Mar 01 '13 05:03 bizziboi

Someone made a video here of how to do this: https://twitter.com/xiotex/status/320880272864325632

MattRix avatar Apr 07 '13 15:04 MattRix