Skip to content

6) Unity 4 Compatability

Nicholas Ventimiglia edited this page Jan 2, 2016 · 4 revisions

Unity 4 is missing two features used in the project. Here is how to fix them.

1) Json Serialization

The lobby system requires a json serializer. You will need to include a json serializer and patch the code. Json serialization is used in two locations

LobbyExample:DoRPC()

void DoRPC() {
            #if UNITY_4_7
            UnityEngine.Debug.LogWarning("Please Add a JsonSerializer Here.");
            #else
            _lobby.SendLobbyRPC(new CustomRPC
            {
                Message = JsonUtility.ToJson(new CustomRPC { Message = "Hello" })
            });
            #endif
}

LobbyService:Init()

Init() {
            #if UNITY_4_7
            Debug.LogWarning("Please Add a JsonSerializer Here.");
            #else
            _toJson = JsonUtility.ToJson;
            _fromJson = JsonUtility.FromJson;
            #endif
        }

2) XCode compatibility

The Unity 5 project include a helper to include XCode dependencies. In Unity 4, you will need to add them manually.

info.plist

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>  
    <key>NSExceptionDomains</key>
    <dict>
        <key>realtime.co</key>
        <dict>
            <!--Include to allow subdomains-->
            <key>NSIncludesSubdomains</key>
            <true/>
            <!--Include to allow HTTP requests-->
            <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
            <true/>
        </dict>
    </dict>
</dict>

Build Properties, Other Flags

-ObjC

Framework Dependencies

Security.framework
libicucore.tbd
Clone this wiki locally