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 /
  • Help Room /
avatar image
0
Question by hoomanBT · Jul 11, 2016 at 03:00 PM · camera script

help whit this camera script

this camera script allow me to show objects from specific cam my problem is i want to use more than one camera per object but this script allow just one cam per object unfortunately i dont have scripting experience to much can anyone help me to edit this script for support more than one cam per object?

alt text

     public class LimitVisibility : MonoBehaviour
     {
 
         /** The _Camera to limit the GameObject's visibility to */
         public _Camera limitToCamera;
         /** If True, then child GameObjects will be affected in the same way */
         public bool affectChildren = false;
         /** If True, then the object will not be visible even if the correct _Camera is active */
         [HideInInspector] public bool isLockedOff = false;
 
         private _Camera activeCamera;
         private bool isVisible = false;
 
 
         private void Start ()
         {
             activeCamera = KickStarter.mainCamera.attachedCamera;
 
             if (!isLockedOff)
             {
                 if (activeCamera == limitToCamera)
                 {
                     SetVisibility (true);
                 }
                 else if (activeCamera != limitToCamera)
                 {
                     SetVisibility (false);
                 }
             }
             else
             {
                 SetVisibility (false);
             }
         }
 
 
         /**
          * Updates the visibility based on the attached camera. This is public so that it can be called by StateHandler.
          */
         public void _Update ()
         {
             activeCamera = KickStarter.mainCamera.attachedCamera;
 
             if (!isLockedOff)
             {
                 if (activeCamera == limitToCamera && !isVisible)
                 {
                     SetVisibility (true);
                 }
                 else if (activeCamera != limitToCamera && isVisible)
                 {
                     SetVisibility (false);
                 }
             }
             else if (isVisible)
             {
                 SetVisibility (false);
             }
         }
 
 
         private void SetVisibility (bool state)
         {
             if (GetComponent <Renderer>())
             {
                 GetComponent <Renderer>().enabled = state;
             }
             else if (gameObject.GetComponent <SpriteRenderer>())
             {
                 gameObject.GetComponent <SpriteRenderer>().enabled = state;
             }
             if (gameObject.GetComponent <GUITexture>())
             {
                 gameObject.GetComponent <GUITexture>().enabled = state;
             }
 
             if (affectChildren)
             {
                 Renderer[] _children = GetComponentsInChildren <Renderer>();
                 foreach (Renderer child in _children)
                 {
                     child.enabled = state;
                 }
 
                 SpriteRenderer[] spriteChildren = GetComponentsInChildren <SpriteRenderer>();
                 foreach (SpriteRenderer child in spriteChildren)
                 {
                     child.enabled = state;
                 }
 
                 GUITexture[] textureChildren = GetComponentsInChildren <GUITexture>();
                 foreach (GUITexture child in textureChildren)
                 {
                     child.enabled = state;
                 }
             }
 
             isVisible = state;
         }
 
     }
 
 }

screenshot.png (21.9 kB)
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 Jessespike · Jul 11, 2016 at 06:15 PM

You can set the layer on the objects and instruct the camera to only render that layer, culling the rest.

https://docs.unity3d.com/ScriptReference/Camera-cullingMask.html

Comment
Add comment · Show 1 · 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 hoomanBT · Jul 11, 2016 at 06:39 PM 0
Share

tnx for your attention ''Jessespike'' because i use adventure creator asset and on 2.5d set cam culling mask is not work on it , i cant use Cam culling mask and layers so any help about this script or any other way ?

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

59 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

Related Questions

Find and turn off previous camera? 1 Answer

Where do you find camera target on tank game? 0 Answers

Center a Object at hit.point in Camera 2 Answers

Camera Collision Problem 0 Answers

Change the Height of TPSCamera at runtime 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