Forum rules - please read before posting.

Nintendo Switch as target platform causes compile errors

edited August 2021 in Technical Q&A

Hello,
we're planning to deploy our AC game on Nintendo Switch and we wanted to run some tests on the official devkit to see how to handle controls, but as soon as we change build platform to the Switch, we get a copile error saying it cannot find the type VideoPlayerData in the FileFormatHandler_Json file. I looked into it and it seems that with the "UNITY_SWITCH" compile flag active a huge chunk of code gets cut out by the absence of the usually present "ALLOW_VIDEO" flag, which is controlled by the following preprocessor directive:

#if !UNITY_SWITCH
#define ALLOW_VIDEO
#endif

What am I supposed to do to make it work? (I'm using AC 1.73.6 on Unity 2020.3.8f1

Comments

  • What is the compilation error, exactly?

    In the past, Unity's VideoPlayer component was not supported by the Switch - at least, as I understood it.

    It looks like this is no longer the case, however. See this recent thread regarding how to lift the restriction - if you can confirm to me that it succesfully compiles, I can look into making a similar change in the next release.

  • edited August 2021

    The type or namespace name 'VideoPlayerData' could not be found (are you missing a using directive or an assembly reference?) is the error I get. I don't use the video player as for now, thus I cannot confirm if it works as intended on Switch. But I can confirm that replacing the #if-#endif directives with just #define ALLOW_VIDEO makes everything compile just fine.

    If it can help, the issue came from the fact that in the FileFormatHandler_Json (in the DeserializeObjectJson(string jsonString) method) the following piece of code is gated behind the #if ALLOW_VIDEO directive:

    #if ALLOW_VIDEO
    if (jsonData is VideoPlayerData && !jsonString.Contains ("isPlaying"))
    {
        return null;
    }
    #endif
    

    but towards the end of the method there is yet another similar if block which is NOT gated behind the same directives:

    if (jsonData is VideoPlayerData && !jsonString.Contains ("clipAssetID"))
    {
        return null;
    }
    

    This means the first if block doesn't cause any issues, since the #if-#endif directiv prevents it from being compiled, but the last one is the responsible for the compile error mentioned at the start.

  • Thanks for the details.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.