Created
April 26, 2016 14:53
-
-
Save tsubaki/6a0896ac17fcc2463ceca687b7547c07 to your computer and use it in GitHub Desktop.
画面外と中を判定するやつ
This file contains 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 UnityEngine.UI; | |
public class InOutTest : MonoBehaviour { | |
[SerializeField] Transform target; | |
[SerializeField] Camera targetCamera; | |
[SerializeField] Text text; | |
private Rect rect = new Rect(0, 0, 1, 1); | |
void Update () | |
{ | |
var viewport = targetCamera.WorldToViewportPoint(target.position); | |
text.text = rect.Contains(viewport) ? "IN" : "OUT"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment