Search Unity

Question Impossible to synchronize unity as a library with native content

Discussion in 'iOS and tvOS' started by unity_8EFB321EA1C418B40C65, Apr 18, 2021.

  1. unity_8EFB321EA1C418B40C65

    unity_8EFB321EA1C418B40C65

    Joined:
    Feb 25, 2021
    Posts:
    3
    I am using Unity as a library in an iOS project (credit to @DavidPeicho and @PavelLU). The unity content being displayed via metal is not synchronized with the other metal and core animation content I am showing at the same time, which makes unity appear slightly out of sync with everything else.

    I know this is expected behavior because unity is rendering its content into a CAMetalLayer which by default does not sync with anything. However, you are supposed to be able to configure a metal layer to sync with core animation's transactions, thereby synchronizing it with anything you are displaying via core animation and any other metal layers that are also configured in this manner.

    The issue is that I have no way to fully configure unity's metal layer for this purpose. Doing so requires following these instructions, but this requires writing some code that goes immediately after the MTLCommandBuffer commit which is nowhere to be found in unity's objective-c files. Maybe it occurs in one of the static libraries? In any case, I can't reach it. While I can set the metal layer's presentsWithTransaction property in MetalHelper.mm this is not enough; I need access to the commit call.

    Is there any way around this or any alternative technique I could try? Maybe swizzling? Hoping someone familiar with unity ios and metal can help.

    Unity Version: 2020.3.2f1
     
  2. Alexey

    Alexey

    Unity Technologies

    Joined:
    May 10, 2010
    Posts:
    1,624
    That's actually a good point. Can you create a bug and describe what do you want to do? Drop case number here, we'll get it from here and make it a feature request etc.
    I suppose exposing command buffer in some way would be a bit problematic, but making a setting of "sync to CoreAnimation" should be pretty easy
     
  3. unity_8EFB321EA1C418B40C65

    unity_8EFB321EA1C418B40C65

    Joined:
    Feb 25, 2021
    Posts:
    3
    @Alexey here is the case number: 1332601