| | |
| | | { |
| | | gameObject = obj; |
| | | camera = Camera.main; |
| | | foreach (var cam in Camera.allCameras) { |
| | | foreach (var cam in Camera.allCameras) |
| | | { |
| | | // skip the main camera |
| | | // we want to use specified camera first then fallback to main camera if no other cameras |
| | | // for further advanced cases, we could test whether the game object is visible within the camera |
| | | if (cam == Camera.main) { |
| | | if (cam == Camera.main) |
| | | { |
| | | continue; |
| | | } |
| | | if ((cam.cullingMask & (1 << gameObject.layer)) != 0) { |
| | | if ((cam.cullingMask & (1 << gameObject.layer)) != 0) |
| | | { |
| | | camera = cam; |
| | | } |
| | | } |