eses
December 20, 2020, 12:43pm
4
@xdzielony
I wouldn’t use that…
I think in editor it check all the cameras, which might be problematic.
And you shouldn’t probably do GetComponent in every Update… cache that to some field.
Also - when posting code, always use code tags, here is how:
If you see someone who needs to know about code tags, please link them to this post:
Please use code tags when posting code.
You can “tag” your code by typing [984347--130826--Screenshot 2015-03-16 10.33.58.png] around your code.
There is no overt “Code” tag button that automatically tags a selection as code.
That being said, however, we can Insert code directly into the post using the “Insert Code” button:
[image]
This will bring up an “Insert” window were we can paste our code and choose…
You can edit you message with that edit button…
I would use this instead:
screenPos = myCamera.WorldToViewportPoint(transform.position);
Then simply check if your position is less than 0 or more than 1 in either x or y.