Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We’re making changes to the Unity Runtime Fee pricing policy that we announced on September 12th. Access our latest thread for more information!
    Dismiss Notice
  3. Dismiss Notice

Bug I can not build my project once I install com.unity.services.multiplay

Discussion in 'Game Server Hosting' started by sava-game, Apr 5, 2023.

  1. sava-game

    sava-game

    Joined:
    Feb 14, 2023
    Posts:
    20
    I am working on PvP with Multipaly & Matchmaker Unity game services.
    To do this, I installed packages for them.(I attached screenshot of my package manager window).
    and services are working in Unity editor.
    But when I am building it to target platform or building addressable(I am using Addressable to manage assets), I am getting red errors.

    error CS0234: The type or namespace name 'Multiplay' does not exist in the namespace 'Unity.Services' (are you missing an assembly reference?)

    and check this video for a quick reference.
    https://drive.google.com/file/d/14iOQuslU8eRP5Xal45wA-BuBfhw3hsQI/view?usp=share_link

    What's wrong with me? How to resolve it?
    I hope you help me if you have time.
    Thank you.
     

    Attached Files:

    Bruny-Games likes this.
  2. MiTschMR

    MiTschMR

    Joined:
    Aug 28, 2018
    Posts:
    336
    Please share a screenshot of your assembly definition file for your scripts/multiplay folder. It may be only set to Editor instead of any platform.
     
  3. sava-game

    sava-game

    Joined:
    Feb 14, 2023
    Posts:
    20
    Thank you @MiTschMR
    I did not create asmdef file in Scripts/Multiplay foler.
    and I renamed it to PvP
    I will share you screenshot of them, please review them and send me your feedback.
    I am really upset due to these errors, it is wasting my time 2 days. :(
     

    Attached Files:

  4. MiTschMR

    MiTschMR

    Joined:
    Aug 28, 2018
    Posts:
    336
    I think, that’s the error. You need to have an asmdef file with a reference to the Multiplay asmdef.

    A bit about asmdef files. They are enclosing code into its own assembly. If you want to access code of that assembly, you need your own with a link to that, so it knows where to look.

    Please try it. If not, please share the lines of code that are affected.
     
  5. sava-game

    sava-game

    Joined:
    Feb 14, 2023
    Posts:
    20
    @MiTschMR
    still the same red errors.
    I created asmdef.
     

    Attached Files:

  6. sava-game

    sava-game

    Joined:
    Feb 14, 2023
    Posts:
    20
    I think it is related to target platform.
    Now I am working on Android project, and my unity is set to Android.
    please check the screenshot.
     

    Attached Files:

  7. Bruny-Games

    Bruny-Games

    Joined:
    Jan 5, 2023
    Posts:
    4
    did you find any solution i have the same problem? My target Platform is also Android.
     
  8. sava-game

    sava-game

    Joined:
    Feb 14, 2023
    Posts:
    20
    yes, solved,
    you should surround your multiplay sdk code with #if UNITY_SERVER || UNITY_EDITOR ~ #endif
     
    TenaciousDan, Ariba2000 and Brogan89 like this.
  9. Bruny-Games

    Bruny-Games

    Joined:
    Jan 5, 2023
    Posts:
    4
  10. Rauljl

    Rauljl

    Joined:
    Oct 1, 2018
    Posts:
    5
    Could you specify the lines of code to put the "if" in. I am not very knowledgeable on the subject.
     
  11. sava-game

    sava-game

    Joined:
    Feb 14, 2023
    Posts:
    20
    #if UNITY_SERVER || UNITY_EDITOR
    using UnityEngine;
    using System.Threading.Tasks;
    using Unity.Netcode;


    namespace xxx.yyy.zzz.aaa.vvv
    {
    public class Bootstrapper : MonoBehaviour
    {
    [SerializeField]
    ServerSingleton m_ServerPrefab;
    ApplicationData m_AppData;
    [SerializeField]
    NetworkManager m_NetworkManagerPrefab;
    void Start()
    {
    LaunchInMode();
    }


    void LaunchInMode()
    {
    #pragma warning disable 4014
    LaunchServer();
    #pragma warning restore 4014

    }


    async Task LaunchServer()
    {
    // Debug.Log("You called server");
    m_AppData = new ApplicationData();
    var serverSingletone = Instantiate(m_ServerPrefab);
    var networkManger = Instantiate(m_NetworkManagerPrefab);
    await serverSingletone.CreateServer(networkManger);
    var defaultGameInfo = new GameInfo
    {
    gameMode = GameMode.Starting,
    map = Map.PracticeWreckyards,
    gameQueue = GameQueue.Casual
    };
    // NetworkManager.Singleton.StartServer();
    await serverSingletone.Manager.StartGameServerAsync(defaultGameInfo);
    }
    }
    }
    #endif