Horje
You can get events when an object is visible within a certain camera, and when it enters or leaves, using these functions: Code Example
You can get events when an object is visible within a certain camera, and when it enters or leaves, using these functions:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
 
public class CameraFrustumTracking : MonoBehaviour
{
    public Camera displayCamera;
 
    public GameObject []Targets;
 
    // Start is called before the first frame update
    void Start()
    {
        if (displayCamera == null)
        {
            displayCamera = Camera.main;
        }
 
        Targets = GameObject.FindGameObjectsWithTag("Target");
    }
 
    // Update is called once per frame
    void Update()
    {
        foreach (GameObject target in Targets)
        {
 
            Plane[] planes = GeometryUtility.CalculateFrustumPlanes(displayCamera);
            if (GeometryUtility.TestPlanesAABB(planes, target.GetComponent<Collider>().bounds))
            {
                print("The object" + target.name + "has appeared");
                target.GetComponent<MeshRenderer>().enabled = true;
            }
            else
            {
                //print("The object" + target.name + "has disappeared");
                target.GetComponent<MeshRenderer>().enabled = false;
            }
 
        }
    }
}




Csharp

Related
mssql list tables Code Example mssql list tables Code Example
asp.net listbox disable selection Code Example asp.net listbox disable selection Code Example
how to make a system to check if i see certain object in unity Code Example how to make a system to check if i see certain object in unity Code Example
c# datagridview filter Code Example c# datagridview filter Code Example
browser folder in wpf Code Example browser folder in wpf Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
11