Author Topic: camera culling mask - show and hide UI  (Read 3552 times)

reis

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 15
    • View Profile
camera culling mask - show and hide UI
« on: June 16, 2014, 06:28:27 AM »
Hi guys,

I'm just looking for a simple way to be able to take a photo without the UI being in the way.
I'm using Prime 31 plugin with NGUI.

I know I could use the NGUI Camera's culling mask, onClick set the culling mask to 0 then turn it back on.
I'm just unsure how to go about it as I cant use a non-static object to select camera as the take photo code is in a coroutine as I get the error

Quote
An object reference is required to access non-static member

I have got this so far,

  1. public Camera hideUI;
  2.  
  3. public static IEnumerator TakeScreenshot(MonoBehaviour mono )
  4.  {
  5.  if( Application.platform == RuntimePlatform.IPhonePlayer )
  6.                         {
  7.  
  8.                            int previousMask = hideUI.cullingMask;
  9.  
  10.                            hideUI.cullingMask = 0;
  11.  
  12.                            //take screenshot code from prime31
  13.  
  14.                            hideUI.cullingMask = previousMask;
  15.                      }
  16.  
  17.  
  18.  

I'm just a bit unsure how I find the camera's name that I need to refer to - unless theres a better way around this please let me know! Thanks guys.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: camera culling mask - show and hide UI
« Reply #1 on: June 16, 2014, 08:56:41 AM »
It tells you what the problem is. Your TakeScreenshot method is static, yet you have a "hideUI" variable in your script. Static functions can only access other static variables. It's not an NGUI question but a basic C# question.

Try getting rid of it, and replacing "hideUI" with UICamera.list[0].camera.
  1. int previousMask = UICamera.list[0].camera.cullingMask;
  2. UICamera.list[0].camera.cullingMask = 0;
  3. UICamera.list[0].camera.cullingMask = previousMask;

reis

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 15
    • View Profile
Re: camera culling mask - show and hide UI
« Reply #2 on: June 16, 2014, 09:28:23 AM »
Thanks Araon, I know its a basic C# question thats why I said at the bottom I'm just unsure what the camera was called when calling it from a static function - Thank you for your help!