Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Bentoon · Dec 12, 2016 at 10:48 PM · cameralayersculling mask

camera culling mask Layers

Hello

I am trying to switch the main camera culling mask

depending on what you collide with...

This is the script on the box:

Almost works.... but not

 using UnityEngine;
 using System.Collections;
 
 public class boxCollision : MonoBehaviour
 {
 
     public bool boxToggle = false;
     public int cullMask = 11;
 
     void Update()
     {
         //Transform thisTransform = this.gameObject.transform;
         //UpdateVRCameraTransform(thisTransform);
 
         //TOGGLE CULLING MASK
         if (boxToggle == false)
         {
             Camera.main.cullingMask = 1 << cullMaskTHREAD;
             //   ;
         }
         else { Camera.main.cullingMask = 1 << cullMask; }
     }
 
     void OnCollisionEnter(Collision collision)
     {
         boxToggle = true;
        Camera.main.cullingMask = 1 << cullMask;
 
     }
 }
 



Thanks!

~be

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by getyour411 · Dec 13, 2016 at 01:50 AM

"but not" isn't a very good description so I don't know what's happening here; try this link to make working with layermasks easier (Scroll down)

http://answers.unity3d.com/questions/8715/how-do-i-use-layermasks.html

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Bentoon · Dec 13, 2016 at 04:58 AM 0
Share

@getyour411 Thanks, but even with other ter$$anonymous$$ology it only works once That article was helpful, but the updated script still doesn't work : The script works on on object but not on any of the others (which are exactly the same)..?

 public class boxCollision1 : $$anonymous$$onoBehaviour
 {
 
     public bool boxToggle = false;
 
     public Layer$$anonymous$$ask defaultLayer;
     public Layer$$anonymous$$ask myLayer;
 
 
     void start()
     {
         defaultLayer = (1 << Layer$$anonymous$$ask.NameToLayer("THREAD"));
         myLayer = (1 << Layer$$anonymous$$ask.NameToLayer("ROO$$anonymous$$"));
     }
 
 
     void Update()
     {
 
         //TOGGLE CULLING $$anonymous$$AS$$anonymous$$
         if (boxToggle == false)
         {
             Camera.main.culling$$anonymous$$ask = defaultLayer;
         }
         else { Camera.main.culling$$anonymous$$ask = myLayer; }
     }
 
     void OnTriggerEnter(Collider other)
     {
         Debug.Log("collision");
         boxToggle = true;
     }
 
     }


I know the layers are called correctly because I can switchthem on the object that works...

Any advice id helpful

Thanks!

~be

avatar image getyour411 Bentoon · Dec 13, 2016 at 05:11 AM 0
Share

Start() not start() see if that fixes things

avatar image Bentoon getyour411 · Dec 13, 2016 at 05:44 PM 0
Share

@getyour411 Thanks - but it only works once, even if I copy the object exactly - it wont work on the 2nd one... I even copied the script and changed the variable names and that wont work ...

Weird

Show more comments

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

82 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

If camera renders Skybox some objects don't get shown 1 Answer

I can't hide a RawImagen in a camera view 1 Answer

Camera culling without layer mask 0 Answers

How can you hide Canvas objects using Camera Culling Mask? 1 Answer

How to show part of the screen only for specified sorting layer? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges