Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class CamCullingMaskController : MonoBehaviour
- {
- [SerializeField] List<string> layerName;
- [SerializeField] Camera camCustomCullingMask;
- [SerializeField] GameObject objToHide;
- private int objLayer;
- void Start()
- {
- objLayer = objToHide.layer;
- //Hide();
- //CustomCamLayerMask();
- }
- void Update()
- {
- if(Input.GetKeyDown(KeyCode.S))
- Toggle();
- print(objLayer);
- }
- // Turn on the bit using an OR operation:
- private void Show()
- {
- camCustomCullingMask.cullingMask |= 1 << LayerMask.NameToLayer("Water");
- }
- // Turn off the bit using an AND operation with the complement of the shifted int:
- private void Hide()
- {
- string objLayerName = LayerMask.LayerToName(objLayer);
- camCustomCullingMask.cullingMask &= ~(1 << LayerMask.NameToLayer(objLayerName));
- }
- // Toggle the bit using a XOR operation:
- private void Toggle()
- {
- camCustomCullingMask.cullingMask ^= 1 << LayerMask.NameToLayer("Water");
- }
- private void Hide2()
- {
- camCustomCullingMask.cullingMask = (1 << LayerMask.NameToLayer("Water"));
- }
- void CustomCamLayerMask()
- {
- camCustomCullingMask.cullingMask = (1 << LayerMask.NameToLayer("TransparentFX")) | (1 >> LayerMask.NameToLayer("UI")) |
- (1 >> LayerMask.NameToLayer("Water")) | (1 >> LayerMask.NameToLayer("Default"));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement