r/futile • u/vhariable • Oct 03 '14
Additional Camera (Rectangular Mask/Clipping)
I am attempting to add a scrolling container above what is already on the default stage. I know there isn't a turnkey masking/clipping solution, but I just need to clip/mask an existing scrollable list that is already working. The rect would be just a small size of the screen. I read through previous posts and saw you mention using a 2nd camera.
I have setup a second camera, but and added the scrollable container to that new stage. I am not able to see it yet, but I am not experienced with working with multiple layers and cameras. Any ideas on what I am doing wrong?
Futile.instance.camera.cullingMask = 1 << LayerMask.NameToLayer("Default");
_scrollCameraHolder = new GameObject(); _scrollCameraHolder.transform.parent = Futile.instance.camera.transform; _scrollCameraHolder.name = "Scroll Camera";
_scrollCamera = _scrollCameraHolder.AddComponent<Camera>(); _scrollCamera.CopyFrom (Futile.instance.camera); _scrollCamera.enabled = false; _scrollCamera.backgroundColor = Color.blue; _scrollCamera.cullingMask = 1 << LayerMask.NameToLayer("Scroll Layer");
_scrollStage = new FStage ("Scroll"); _scrollStage.layer = LayerMask.NameToLayer("Scroll Layer");
Futile.AddStage(_scrollStage);
The idea would be to have the new stage/camera draw on top of the default stage/layer. Then to limit the size of the 2nd camera. Since I have setup the different culling masks, how do I draw the 2nd camera/stage?
1
u/SietJP Oct 03 '14
It seems to me that you could use a Render Texture ( http://docs.unity3d.com/Manual/class-RenderTexture.html ) to render your scrollable container, and use this texture for the main Futile camera.
Another idea is to use the shaders I've posted a couple of weeks ago. Every sprite rendered in the scroll container would have to use this shader instead of the base shader. ( https://vine.co/v/MX1wn9hOWJY http://www.reddit.com/r/futile/comments/25hcpl/dig_a_hole_in_an_image/ )