Add a single unified “OnNetworkStarted” event to NetworkManager
Los mantenedores suelen responder en 3 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 42/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Área
- api, networking
Línea de trabajo
Comienza en NetworkManager, especialmente en internal Initialize(bool server), e inspecciona las rutas de ciclo de vida existentes OnServerStarted y OnClientConnectedCallback, así como las pruebas relacionadas. Se considera completado cuando se genera un único evento una sola vez después de que la pila de red y el transporte estén listos en los modos de servidor, cliente y host, cubriendo el comportamiento con varias instancias de NetworkManager y recargas del editor.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
The problem
There’s no single event that fires once when networking starts, regardless of mode
Currently you need to handle both OnServerStarted and OnClientConnectedCallback, which leads to redundant or missing calls depending on the mode (client/server)
Using per-connection callbacks for this is unreliable, and managing timing around the singleton or validation properties(e.g IsListening) adds unnecessary complexity
Unless i am missing something, to me this dont feels right
Current workflow
The current workaround is using coroutines or polling to wait until the singleton exists and the NetworkManager is listening.
This adds overhead and makes initialization logic fragile, even more for singleplayer sessions where the code may keep waiting forever as no connections are made
Example (based on forums suggestions):
void OnEnable()
{
StartCoroutine(SubscribeToNetworkManagerEvents());
}
IEnumerator SubscribeToNetworkManagerEvents()
{
yield return new WaitUntil(() => NetworkManager.Singleton); //This is fragile, and may add other problems, and no mention to cancelations
NetworkManager.Singleton.OnClientConnectedCallback += OnClientConnectedCallback; //called on clients but unclear about standalone server
NetworkManager.Singleton.OnServerStarted += OnServerStarted; //never called on non host client
}
void OnDestroy()
{
if (NetworkManager.Singleton)
{
NetworkManager.Singleton.OnClientConnectedCallback -= OnClientConnectedCallback;
NetworkManager.Singleton.OnServerStarted -= OnServerStarted;
}
initialized = false;
}
void OnClientConnectedCallback(parameters)
{
RegisterMessageHandler();
}
void OnServerStarted(parameters)
{
RegisterMessageHandler();
}
bool initialized;
//Both on client connected callback and server started calls this other method
void RegisterMessageHandler()
{
if(initialized)
return;
//For example
NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler("a", B);
// In this case, Singleton can be null and CustomMessagingManager also can be null, thats why we need the yield
initialized = true;
}
These yields are required only because there is no dedicated lifecycle event indicating when the NetworkManager and its subsystems (like CustomMessagingManager) are fully initialized
As result, developers must manually simulate this missing initialization phase using coroutines or polling, which makes code more complex
Posible solution
Add new public static Action<NetworkManager> OnNetworkStarted event to NetworkManager
Triggered once when the network stack has been initialized and the transport is ready, regardless of whether it’s running as server, client, or host.
Passing the Network manager initialized (as after working on the last pull request, i saw on the tests part and other parts of code might exist more than one NetworkManager)
This would change the workflow to a much more convenient one like this
NetworkManager networkManager;
void OnEnable()
{
NetworkManager.OnNetworkStarted += OnNetworkStarted;
}
void OnNetworkStarted(NetworkManager networkManager)
{
this.networkManager = networkManager;
networkManager.CustomMessagingManager.RegisterNamedMessageHandler("a", B);
}
void OnDestroy()
{
if (networkManager)
networkManager.CustomMessagingManager.UnregisterNamedMessageHandler("a");
}
[!NOTE]
WhileNetworkBehaviour.OnNetworkSpawncan be used for components, this event would support use cases where no scene objects are involved (e.g ScriptableObjects or systems initialized outside scene contexts). It provides a clean, unified hook for all modes.This change would mostly take 2 lines
public static Action<NetworkManager> OnNetworkStartedon NetworkManager classOnNetworkStarter?.Invoke(This);at the very end of NetworkManager'sinternal void Initialize(bool server)methodIt only may cause problems on having it static with the editor reloading feature, but that could be arranged cleaning the event with the
[RuntimeInitializeOnLoadAttribute]
- Lenguaje dominante
- C#
- Estrellas
- 2.3k
- Forks
- 465
- Merge medio
- 3 d 12 h
- PR fusionados (30 d)
- 39
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de Unity-Technologies/com.unity.netcode.gameobjects
-
TimeSyncMessage is sent reliably, so a late one resets the client clock backwards and stalls its NetworkTransformsPosiblemente ocupada @reginaldalfret la tomó hace 8 días. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 52/100
Unity-Technologies/com.unity.netcode.gameobjects#4249 ·
Los mantenedores suelen responder en 3 días
-
NetworkTransform: half-float base update dropped as out of order when UseUnreliableDeltas is on, so later deltas decode ~2 m offPosiblemente ocupada @NoelStephensUnity la tomó hace 8 días. Abiertoport:3.x-completed priority:medium stat:imported type:bug
Dificultad 4/5 3-5 días Aptitud para principiantes 57/100
Unity-Technologies/com.unity.netcode.gameobjects#4248 ·
Los mantenedores suelen responder en 3 días
-
Tracking type:feature-2.x
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
Unity-Technologies/com.unity.netcode.gameobjects#3870 · 5 comentarios ·
Los mantenedores suelen responder en 3 días
-
Please error, or at least warn, when a managed type is included in INetworkSerializeByMemcpyAbiertoTracking type:feature
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
Unity-Technologies/com.unity.netcode.gameobjects#3830 · 7 comentarios ·
Los mantenedores suelen responder en 3 días
-
Client NetworkObjects experience Awake, Start, OnEnable, and TriggerEnter, CollisionEnter at world 0,0,0 upon instantiationQuizá libre de nuevo @NoelStephensUnity la tomó hace 492 días y no hay ningún pull request abierto. Abiertopriority:medium stat:imported type:bug
Unity-Technologies/com.unity.netcode.gameobjects#3553 · 3 comentarios · 2 reacciones · 1 asignado ·
Los mantenedores suelen responder en 3 días
Todos los issues de Unity-Technologies/com.unity.netcode.gameobjects
Issues similares
-
hand-to-AI
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
CactuseSecurity/firewall-orchestrator#5803 ·
Los mantenedores suelen responder en 1 día
-
Typed MINID rejects numeric thresholds with a leading plus sign accepted by Redis and ValkeyAbiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
Los mantenedores suelen responder en 1 día
-
DXF with empty names failsAbiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 3 días
-
bug python
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
ilia-sokolov/OfficeAgent.NET#89 ·
Los mantenedores suelen responder en 13 días