Hi all, I’m extremely new to Unity and code in general, and I have this issue that’s preventing me from opening my file. What I understand is that it’s an issue stemming from how Cinemachine and Adventure Creator are interacting under the hood, and I know there’s something that isn’t communicating correctly between two parts of the code, but I simply don’t know enough about coding in general to be able to fix it myself. Could somebody help explain what I need to change and why (in as lay-person words as possible)? I included a screenshot of the error and code below. Greatly appreciate any and all help!
The error says:
Assets\AdventureCreator\Downloads\Cinemachine integration\Scripts\CinemachineMixerController.cs(32,36): error CS0123: No overload for ‘OnFinishLoading’ matches delegate ‘EventManager.Delegate_Generic’
And the code looks like this:
using UnityEngine;
using Cinemachine;
namespace AC
{
[RequireComponent (typeof (CinemachineMixingCamera))]
public class CinemachineMixerController : MonoBehaviour
{
#region Variables
private float[] originalWeights = new float[0];
private float[] targetWeights = new float[0];
private float transitionTime = 0f;
private float transitionDuration = 0f;
private CinemachineMixingCamera cinemachineMixingCamera;
#endregion
#region UnityStandards
private void Awake ()
{
cinemachineMixingCamera = GetComponent<CinemachineMixingCamera> ();
}
private void OnEnable ()
{
EventManager.OnFinishLoading += OnFinishLoading;
}
private void OnDisable ()
{
EventManager.OnFinishLoading -= OnFinishLoading;
}
private void Update ()
{
if (transitionTime > 0f)
{
float lerpAmount = 1f - (transitionTime / transitionDuration);
int numCameras = targetWeights.Length;
float[] actualBlends = new float[numCameras];
for (int i = 0; i < numCameras; i++)
{
actualBlends[i] = Mathf.Lerp (originalWeights[i], targetWeights[i], lerpAmount);
cinemachineMixingCamera.SetWeight (i, actualBlends[i]);
}
transitionTime -= Time.deltaTime;
if (transitionTime <= 0f)
{
SnapToTarget ();
}
}
}
#endregion
#region PublicFunctions
public float SwitchCamera (int channel, float duration)
{
int numCameras = cinemachineMixingCamera.ChildCameras.Length;
originalWeights = new float[numCameras];
targetWeights = new float[numCameras];
bool weightsAreSame = true;
for (int i = 0; i < numCameras; i++)
{
originalWeights[i] = cinemachineMixingCamera.GetWeight (i);
targetWeights[i] = (i == channel) ? 1f : 0f;
if (originalWeights[i] != targetWeights[i])
{
weightsAreSame = false;
}
if (duration <= 0f)
{
cinemachineMixingCamera.SetWeight (i, targetWeights[i]);
}
}
if (duration <= 0f || weightsAreSame)
{
SnapToTarget ();
transitionTime = 0f;
return 0f;
}
transitionTime = transitionDuration = Mathf.Max (0f, duration);
return transitionTime;
}
#endregion
#region CustomEvents
private void OnFinishLoading (int saveID)
{
if (transitionTime > 0f)
{
transitionTime = 0f;
SnapToTarget ();
}
}
#endregion
#region PrivateFunctions
private void SnapToTarget ()
{
int numCameras = targetWeights.Length;
for (int i = 0; i < numCameras; i++)
{
cinemachineMixingCamera.SetWeight (i, targetWeights[i]);
}
}
#endregion
}
}