Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    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:
    21
    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:
    514
    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:
    21
    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:
    514
    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:
    21
    @MiTschMR
    still the same red errors.
    I created asmdef.
     

    Attached Files:

  6. sava-game

    sava-game

    Joined:
    Feb 14, 2023
    Posts:
    21
    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:
    21
    yes, solved,
    you should surround your multiplay sdk code with #if UNITY_SERVER || UNITY_EDITOR ~ #endif
     
  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:
    21
    #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
     
    vagamesint likes this.
  12. ANLevant

    ANLevant

    Joined:
    Jun 10, 2014
    Posts:
    32
    This fixed the thing for me. Multiplay code simply can't be exported into Android builds. 10/10 thanks man!
     
  13. AlexaRebecca

    AlexaRebecca

    Joined:
    Dec 14, 2018
    Posts:
    26
    I did it but it still gives me an error
     
    ANLevant likes this.
  14. ANLevant

    ANLevant

    Joined:
    Jun 10, 2014
    Posts:
    32
    Make sure you're wrapping the imports too