Hi,
I came across an interesting issue today while building custom CinemachineExtensions. I need my Extension to run before the Confiner2D-Extension, so that I don’t modify the position after the confinement took place.
From what I understood the execution-order of these extensions is based on the order you add them to your VCam. If I add them in the correct order it works, but as soon as I change something in my code (causing the compile process) the order is flipped. The Confiner suddenly runs before my extension, although it is still last in the Inspector and in the Asset-File. From what I found out by debugging Cinemachine it seems to be related to my VCam being inside of a Prefab. But I’m not familiar enough with Cinemachine’s inner workings to really find out what is going on.
I created a Test-Project where this can be easily reproduced (for me at last).
It contains a “SampleScene” which contains a Brain, a VCam and a Square-Sprite for reference.
The VCam has 2 Extensions attached to it: CamSampleExtension and CamSampleExtension2. The code of both is identical, I just needed 2, so that I can add them both to the same VCam. The first extension sets the cam-position to (0,0,-10), while the second extension sets it to (0,0,-1). Because of the execution order of both extensions, the cube is really near to the camera in the game-view (because -1 gets set AFTER -10).
If I then go into code and add a space somewhere (to trigger the compile process), the order gets switched, so the cube is now really small in the game-view (because now -10 wins).
To repair this “broken” state you have to delete the VCam-prefab and add it again to the Scene again.
The issue persists this with both Cinemachine 2.9.2 and 2.8.9
I also attached a video of me showcasing the issue at the root of the attached zip-file.
Would really appreciate if someone could take a look at this <3
Thank you all and happy holidays
Leo
8680878–1170306–CinemachineVcamPrefabExtensionOrder.zip (1.36 MB)