Last active
August 29, 2015 14:12
-
-
Save kankikuchi/f1b5ac204ddea5e174d4 to your computer and use it in GitHub Desktop.
特定のカメラに写ってるかの判定【Unity】
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using UnityEngine; | |
| using System.Collections; | |
| public class IsRendered : MonoBehaviour { | |
| //メインカメラに付いているタグ名 | |
| private const string MAIN_CAMERA_TAG_NAME = "MainCamera"; | |
| //カメラに表示されているか | |
| private bool _isRendered = false; | |
| private void Update () { | |
| if(_isRendered){ | |
| Debug.Log ("カメラに映ってるよ!"); | |
| } | |
| _isRendered = false; | |
| } | |
| //カメラに映ってる間に呼ばれる | |
| private void OnWillRenderObject(){ | |
| //メインカメラに映った時だけ_isRenderedを有効に | |
| if(Camera.current.tag == MAIN_CAMERA_TAG_NAME){ | |
| _isRendered = true; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment