Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

unity check if camera can see object

public static class CameraEx
{
    public static bool IsObjectVisible(this UnityEngine.Camera @this, Renderer renderer)
    {
        return GeometryUtility.TestPlanesAABB(GeometryUtility.CalculateFrustumPlanes(@this), renderer.bounds);
    }
}

// UnityEngine.Camera cam1;
// UnityEngine.Camera cam2;

void Update()
{
    bool isVisibleForCamera1 = cam1.IsObjectVisible(GetComponent<MeshRenderer>());
    bool isVisibleForCamera2 = cam2.IsObjectVisible(GetCoponent<SpriteRenderer>());
}

Comment

PREVIOUS NEXT
Code Example
Csharp :: how to get keyboard input in unity 
Csharp :: convert object to httpcontent c# 
Csharp :: update listbox using class c# 
Csharp :: asp.net mvc image upload 
Csharp :: .net core web app get dll name 
Csharp :: else if c# 
Csharp :: ternary operator c# 
Csharp :: how to check if List<T element contains an item with a Particular Property Value in c# 
Csharp :: C# async to sync 
Csharp :: c# get type of class 
Csharp :: c# today without time 
Csharp :: c# generate guid from hash 
Csharp :: checking a gamobjects layer 
Csharp :: solid principles c# 
Csharp :: c# convert enumb to int array 
Csharp :: unity toint 
Csharp :: cast char[] to string c# 
Csharp :: create new .net core project visual studio 
Csharp :: create new object from generic c# 
Csharp :: c# backup sql 
Csharp :: linq from multiple tables 
Csharp :: c# xml get child node by name 
Csharp :: pyqt minimize to tray icon 
Csharp :: how to reload app.config file at runtime in c# 
Csharp :: static class can have non static member in c# 
Csharp :: c# get witdh of matrix 
Csharp :: XMLWriter write xml C# 
Csharp :: c# write iformfile 
Csharp :: how to get mouse position c# 
Csharp :: C# xamaring form change text on label 
ADD CONTENT
Topic
Content
Source link
Name
6+2 =