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

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.

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


1 Like

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.

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. :frowning:



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.

@MiTschMR
still the same red errors.
I created asmdef.

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.

did you find any solution i have the same problem? My target Platform is also Android.

yes, solved,
you should surround your multiplay sdk code with #if UNITY_SERVER || UNITY_EDITOR ~ #endif

4 Likes

thanks

Could you specify the lines of code to put the “if” in. I am not very knowledgeable on the subject.

#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

1 Like

This fixed the thing for me. Multiplay code simply can’t be exported into Android builds. 10/10 thanks man!

I did it but it still gives me an error

1 Like

Make sure you’re wrapping the imports too