developer-7 avatar image
developer-7 asked

PlayFab.ServerModels stops existing when I change the build type to Dedicated Server on Unity

Im using Unity 2021.3.5f and RiptideNetworking to make my multiplayer game. Befora I was doing the server on my own machine to test the connection between players on different networks and it works. Now I want to use this custom server built on Unity to the PlayFab. I follow the documentation, installed the latest SDK available and made the integration with Unity, but befora building I wanted to change from the normal build to a dedicated Server build to upload to PlayFab. But everytime I change the build type it says that the PlayFab.ServerModels library can't be found, it gives me the following error:

Assets\Scripts\ServerScripts\NetworkManager.cs(8,15): error CS0234: The type or namespace name 'ServerModels' does not exist in the namespace 'PlayFab' (are you missing an assembly reference?)

The error dosen't happen while the build type is on the default platform (Windowns, Linux, Mac). The script also dosen't have any errors, and removing the library reference just makes the lines that use it the error. I use it in the following script:

using RiptideNetworking;
using RiptideNetworking.Utils;
using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
using PlayFab.MultiplayerAgent;
using PlayFab.ServerModels;
using PlayFab;

//Ambos Enums devem existir no Servidor e no Client, serve para enumerar e nomear os pacotes que vão ser enviados
//Cada pacote terá um nome e uma finalidade de envio e recibo de informação
public enum ServerToClientId : ushort
    returnConnection = 1,
public enum ClientToServerId : ushort{
    checkConnection = 1,


public class NetworkManager : MonoBehaviour
    //Parte do código referente ao Singleton,sem o Awake
    private static NetworkManager _singleton;

    public static NetworkManager Singleton{
        get => _singleton;
        private set{
            if(_singleton == null){
                _singleton = value;
            else if(_singleton != value){
                //Debug.Log($"{nameof(NetworkManager)} instance already exists, destroying duplicate!");

    //Variável Server do próprio Riptide
    public Server Server {get; private set;}
    //Porta e máximo de client, declaradas como ushort por boas práticas do riptide
    [SerializeField] private ushort port;
    [SerializeField] private ushort maxClientCount;
    //Quantidade atual de Jogadores e quantidade de Batalhas
    [SerializeField] private int currentClients;
    [SerializeField] private int currentBattles;

    //Void Awake do Singleton
    private void Awake(){
        Singleton = this;

    private void Start(){

        //Ao iniciar deixar o target de Frame Rate em 60 para estabilidade
        Application.targetFrameRate = 60;
        //Chamada do Riptide responsável por futuramente pode retornar logs
        RiptideLogger.Initialize(Debug.Log, Debug.Log, Debug.LogWarning, Debug.LogError, false);

        //Iniciar um novo servidor com a porta e máximo de clients
        Server = new Server();
	    Server.Start(port, maxClientCount);

        //O += faz se possível uma função chamar a outra, sempre que PlayerLeft for chamado o Disconnected tbm será
        Server.ClientDisconnected += PlayerLeft;

    #region PlayFab
	private void StartPlayFabServer()
		PlayFabMultiplayerAgentAPI.IsDebugging = true;
		PlayFabMultiplayerAgentAPI.OnMaintenanceCallback += OnMaintenance;
		PlayFabMultiplayerAgentAPI.OnShutDownCallback += OnShutdown;
		PlayFabMultiplayerAgentAPI.OnServerActiveCallback += OnServerActive;
		PlayFabMultiplayerAgentAPI.OnAgentErrorCallback += OnAgentError;
	private IEnumerator ReadyForPlayers()
		yield return new WaitForSeconds(.5f);
	private void OnServerActive()
		Debug.Log("Server Started From Agent Activation");
	private void OnShutdown()
		Debug.Log("Server shutdown ");
	private void OnMaintenance(DateTime? NextMaintenance)
		Debug.Log("Server On Maintenance. Next Maintenance - " + NextMaintenance.Value.ToLongDateString());
	private void OnAgentError(string error)
		Debug.Log("Server error " + error);
	IEnumerator ShutdownServerInXTime()
		yield return new WaitForSeconds(300f);
	private void StartShutdownProcess()
		Debug.Log("Server is shutting down");
	IEnumerator ShutDownServer()
		yield return new WaitForSeconds(5f);
    private void FixedUpdate(){

        //Tick de escuta do Servidor
        //Número de Jogadores é igual ao count da lista de Player no Script Player
        currentClients = Player.list.Count;
        //Número de Batalhar é igual ao count da lista de Batalhas no Script Battles Singleton
        currentBattles = Battles.Singleton.battleCount;


    //Ao fechar o jogo o servidor irá fechar no último frame, também uma boa prática
    private void OnApplicationQuit(){

    //Função do Próprio Riptide que é chamado ao Riptide identificar que um Client Sair
    //Assim que ele sair remove da Lista de Players
    private void PlayerLeft(object sender, ClientDisconnectedEventArgs e)

unity3dsdksCustom Game Servers
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

Xiao Zha avatar image
Xiao Zha answered

The error message means you are using Server API calls, but you haven’t enabled the Server API in the project. You can try navigating to [Project Settings]->[Player]->[Other Settings]->[Scripting Define Symbols] and entering "ENBLE_PLAYFABSERVER_API". Please feel free to let me know if the problem persists.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

developer-7 avatar image developer-7 commented ·

I got that like 1h after the post, but thanks a lot for the awnser. And it fixed right away after adding it. For some reason after a pull from the Git repositorie the API was deactivated.

0 Likes 0 ·
nwayoofighter2023 avatar image nwayoofighter2023 commented ·

it can't fixed i add ENBLE_PLAYFABSERVER_API to other setting

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.