MirrorTest: CreateNetworked<T,U>

This commit is contained in:
vis2k 2021-05-19 19:37:42 +08:00
parent 152ffb11a7
commit f6c13424cf

View File

@ -55,6 +55,19 @@ protected void CreateNetworked<T>(out GameObject go, out NetworkIdentity identit
instantiated.Add(go);
}
// create GameObject + NetworkIdentity + 2x NetworkBehaviour<T>
// add to tracker list if needed (useful for cleanups afterwards)
protected void CreateNetworked<T, U>(out GameObject go, out NetworkIdentity identity, out T componentA, out U componentB)
where T : NetworkBehaviour
where U : NetworkBehaviour
{
go = new GameObject();
identity = go.AddComponent<NetworkIdentity>();
componentA = go.AddComponent<T>();
componentB = go.AddComponent<U>();
instantiated.Add(go);
}
// create GameObject + NetworkIdentity + NetworkBehaviour & SPAWN
// => ownerConnection can be NetworkServer.localConnection if needed.
protected void CreateNetworkedAndSpawn<T>(out GameObject go, out NetworkIdentity identity, out T component, NetworkConnection ownerConnection = null)