Search Unity

How to make this layer not render at start?

Discussion in 'Scripting' started by NutellaDaddy, Jan 12, 2014.

  1. NutellaDaddy

    NutellaDaddy

    Joined:
    Oct 22, 2013
    Posts:
    288
    I have this script that makes it so that when you click on options than the options will render the layer with options and the main part of the start menu won't. The options just stay there mingling in with the words on the front screen. If I deactivate the objects in the scene then it won't show up ,but the front screen still disapears. Do I need to add a renderer to the text or something?



    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class StartMenuControl : MonoBehaviour
    5. {
    6.     public bool isStart;
    7.     public bool isLoad;
    8.     public bool isOptions;
    9.     public bool isQuit;
    10.        
    11.     void OnMouseUp()
    12.         {
    13.     if (isQuit == true)
    14.         {
    15.             Application.Quit ();
    16.         }
    17.     else if (isOptions == true)
    18.         {
    19.             //How to make the options render when you click options
    20.             Camera.main.cullingMask |=(1<<LayerMask.NameToLayer (" Options Screen"));
    21.                Camera.main.cullingMask = ~(1<<LayerMask.NameToLayer("Main Screen"));
    22.         }
    23.     }
    24. }
     
  2. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,697
    I am having trouble understanding your english.

    Maybe this will help.

    Code (csharp):
    1.  
    2. void Start(){
    3. if(someBool==false)
    4. someRenderer.enabled = false;
    5. else if(someBool==true)
    6. someRenderer.enabled = true;
    7. }
    8.  

    Or, perhaps more closely...
    Code (csharp):
    1.  
    2. void Start (){
    3. if(someBool==false)
    4. thisObject.layer = layerNotRenderedByCam;
    5. else if(someBool==true)
    6. thisObject.layer = layerIsRenderedByCam;
    7. }
    8.  
     
    Last edited: Jan 13, 2014
  3. NutellaDaddy

    NutellaDaddy

    Joined:
    Oct 22, 2013
    Posts:
    288
    This didn't work
     
    Last edited: Jan 13, 2014