using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Cinemachine;
using System.Linq;
public class CamerasInfo : MonoBehaviour
{
public List<CinemachineFreeLook> FreeLook;
public List<CinemachineVirtualCamera> Virtual;
public List<Camera> AllCameras;
public List<string> currentActiveCameras;
// Start is called before the first frame update
void Start()
{
Cameras();
}
// Update is called once per frame
void Update()
{
}
public void Cameras()
{
FreeLook = FindObjectsOfType<CinemachineFreeLook>().ToList();
Virtual = FindObjectsOfType<CinemachineVirtualCamera>().ToList();
for(int i = 0; i < Virtual.Count; i++)
{
if (!Virtual[i].name.StartsWith("CM"))
Virtual.RemoveAt(i);
}
AllCameras = Camera.allCameras.ToList();
foreach (CinemachineFreeLook freelook in FreeLook)
{
if (freelook.isActiveAndEnabled)
currentActiveCameras.Add(freelook.Name);
}
foreach (CinemachineVirtualCamera vir in Virtual)
{
if (vir.isActiveAndEnabled)
currentActiveCameras.Add(vir.Name);
}
for(int i = 0; i < AllCameras.Count; i++)
{
if (AllCameras[i].isActiveAndEnabled)
currentActiveCameras.Add(AllCameras[i].name);
}
}
}
At this part in this case there are 8 cameras listen in virtual :
for(int i = 0; i < Virtual.Count; i++)
{
if (!Virtual[i].name.StartsWith("CM"))
Virtual.RemoveAt(i);
}
But it's removing only 3 cameras instead 6. In the end I should left with only two cameras that starts with CM but in the editor there are 5 cameras :
It's not removing the Bottom Top and Middle :

