FromBytes() public static method

public static FromBytes ( byte b ) : GameProgress,
b byte
return GameProgress,
示例#1
0
    void ProcessCloudData(byte[] cloudData)
    {
        if (cloudData == null)
        {
            Debug.Log("No data saved to the cloud yet...");
            return;
        }
        Debug.Log("Decoding cloud data from bytes.");
        GameProgress progress = GameProgress.FromBytes(cloudData);

        Debug.Log("Merging with existing game progress.");
        mProgress.MergeWith(progress);
    }
示例#2
0
    public byte[] OnStateConflict(int slot, byte[] local, byte[] server)
    {
        Debug.Log("Conflict callback called. Resolving conflict.");

        // decode byte arrays into game progress and merge them
        GameProgress localProgress = local == null ?
                                     new GameProgress() : GameProgress.FromBytes(local);
        GameProgress serverProgress = server == null ?
                                      new GameProgress() : GameProgress.FromBytes(server);

        localProgress.MergeWith(serverProgress);

        // resolve conflict
        return(localProgress.ToBytes());
    }