I have been serializing Cinemachine components and unserializing them like so:
public static string[] GetCMSerializedOrdered(GameObject parent) {
CinemachineVirtualCameraBase[] bases =
parent.GetComponentsInChildren<CinemachineVirtualCameraBase>();
CinemachineFreeLook[] freeLooks =
parent.GetComponentsInChildren<CinemachineFreeLook>();
CinemachineVirtualCamera[] virtualCameras =
parent.GetComponentsInChildren<CinemachineVirtualCamera>();
CinemachinePipeline[] pipelines =
parent.GetComponentsInChildren<CinemachinePipeline>();
CinemachineOrbitalTransposer[] transporters =
parent.GetComponentsInChildren<CinemachineOrbitalTransposer>();
CinemachineComposer[] composers =
parent.GetComponentsInChildren<CinemachineComposer>();
List<string> components = new List<string>();
foreach (var item in bases) {
item.Follow = null;
item.LookAt = null;
components.Add(JsonUtility.ToJson(item));
}
foreach (var item in freeLooks) {
item.Follow = null;
item.LookAt = null;
components.Add(JsonUtility.ToJson(item));
}
foreach (var item in virtualCameras) {
item.Follow = null;
item.LookAt = null;
components.Add(JsonUtility.ToJson(item));
}
foreach (var item in pipelines) {
components.Add(JsonUtility.ToJson(item));
}
foreach (var item in transporters) {
components.Add(JsonUtility.ToJson(item));
}
foreach (var item in composers) {
components.Add(JsonUtility.ToJson(item));
}
return components.ToArray();
}
and as you can see i have to set Follow and LookAt as null, because if I unserialize them and they are not null, the reference that they hold will point either to nothing or to some random thing in the scene (which will brake Cinemachine into chaos).
Now I am facing the same issue with m_ComponentOwner which is serialized to handle copy/paste, but is not public or is there a function for me to null it (except DestroyPipeline, but i guess it would destroy too much, am i wrong?).
Anyone has a workaround? Can/Should i rebuild the dll’s? @Gregoryl