Skip to content

Commit 0cc6391

Browse files
committed
Removed SetActive calls
1 parent 164a713 commit 0cc6391

1 file changed

Lines changed: 0 additions & 72 deletions

File tree

com.unity.netcode.gameobjects/Tests/Runtime/TestHelpers/NetcodeIntegrationTest.cs

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -2197,42 +2197,8 @@ protected GameObject CreateNetworkObjectPrefab(string baseName)
21972197
}
21982198

21992199
#if UNIFIED_NETCODE
2200-
2201-
private GameObject CreatePrefab(string directoryPath, GameObject go)
2202-
{
2203-
if (!Directory.Exists(directoryPath))
2204-
Directory.CreateDirectory(directoryPath);
2205-
var assetPath = $"{directoryPath}/{go.name}.prefab";
2206-
if (AssetDatabase.AssetPathExists(assetPath))
2207-
AssetDatabase.DeleteAsset(assetPath);
2208-
Assert.IsFalse(AssetDatabase.AssetPathExists(assetPath), $"path already exists for asset {assetPath}");
2209-
var prefab = PrefabUtility.SaveAsPrefabAsset(go, assetPath);
2210-
2211-
var networkPrefab = new NetworkPrefab() { Prefab = prefab };
2212-
2213-
var authorityNetworkManager = GetAuthorityNetworkManager();
2214-
var clients = m_ClientNetworkManagers;
2215-
// We could refactor this test framework to share a NetworkPrefabList instance, but at this point it's
2216-
// probably more trouble than it's worth to verify these lists stay in sync across all tests...
2217-
authorityNetworkManager.NetworkConfig.Prefabs.Add(networkPrefab);
2218-
authorityNetworkManager.NetworkConfig.Prefabs.Remove(go);
2219-
foreach (var clientNetworkManager in clients)
2220-
{
2221-
if (clientNetworkManager == authorityNetworkManager)
2222-
{
2223-
continue;
2224-
}
2225-
clientNetworkManager.NetworkConfig.Prefabs.Add(new NetworkPrefab() { Prefab = prefab });
2226-
clientNetworkManager.NetworkConfig.Prefabs.Remove(go);
2227-
}
2228-
Object.DestroyImmediate(go);
2229-
2230-
return prefab;
2231-
}
2232-
22332200
protected void SetupGhostAdapterForNetworkObjectPrefab(ref GameObject prefabObject)
22342201
{
2235-
prefabObject.SetActive(false);
22362202
var adapter = prefabObject.AddComponent<GhostAdapter>();
22372203
var bridge = prefabObject.AddComponent<NetworkObjectBridge>();
22382204
var no = prefabObject.GetComponent<NetworkObject>();
@@ -2241,48 +2207,14 @@ protected void SetupGhostAdapterForNetworkObjectPrefab(ref GameObject prefabObje
22412207
no.HadBridge = true;
22422208
no.NetworkObjectBridge = bridge;
22432209

2244-
/*prefabObject = CreatePrefab("Assets/Temp", prefabObject);*/
2245-
22462210
GhostPrefabReference.s_IsPostProcessing = true;
22472211
adapter.prefabReference = ScriptableObject.CreateInstance<GhostPrefabReference>();
22482212
adapter.prefabReference.name = "GhostPrefabReference";
22492213

22502214
adapter.prefabReference.Prefab = prefabObject;
22512215
adapter.prefabReference.Ghost = adapter;
22522216
GhostPrefabReference.s_IsPostProcessing = false;
2253-
2254-
//prefabObject.SetActive(true);
2255-
UpdateGhostPrefabs();
2256-
}
2257-
2258-
void UpdateGhostPrefabs()
2259-
{
2260-
foreach (var prefabObject in GameObject.FindObjectsByType<GhostAdapter>())
2261-
{
2262-
var reference = prefabObject.GetComponent<GhostPrefabReference>();
2263-
if (!reference || reference.Prefab != prefabObject.gameObject)
2264-
{
2265-
continue;
2266-
}
2267-
2268-
foreach (var world in World.All)
2269-
{
2270-
// check all possible worlds for the prefab that was just created and reenable it there too, since normal prefab creation would think the prefab is inactive
2271-
// and automatically set the associated entity disabled too
2272-
var link = GhostEntityMapping.LookupEntityReferencePrefab(prefabObject.GetEntityId(), world.Unmanaged);
2273-
if (link.WasInitialized)
2274-
{
2275-
link.World.EntityManager.SetEnabled(link.Entity, true);
2276-
// also have to override this in tests, since prefab registration will have had the wrong value during registration
2277-
var pendingGameObjectSpawn =
2278-
link.World.EntityManager.GetComponentData<PendingClientGameObjectSpawn>(link.Entity);
2279-
pendingGameObjectSpawn.ShouldBeActive = true;
2280-
link.World.EntityManager.SetComponentData(link.Entity, pendingGameObjectSpawn);
2281-
}
2282-
}
2283-
}
22842217
}
2285-
22862218
#endif
22872219

22882220
/// <summary>
@@ -2404,7 +2336,6 @@ private GameObject SpawnObject(NetworkObject prefabNetworkObject, NetworkManager
24042336
Assert.IsTrue(prefabNetworkObject.GlobalObjectIdHash > 0, $"{nameof(GameObject)} {prefabNetworkObject.name} has a {nameof(NetworkObject.GlobalObjectIdHash)} value of 0! Make sure to make it a valid prefab before trying to spawn!");
24052337
NetCode.Netcode.Instance.m_ActiveWorld = owner.NetcodeWorld;
24062338
var newInstance = Object.Instantiate(prefabNetworkObject.gameObject);
2407-
newInstance.SetActive(true);
24082339
var networkObjectToSpawn = newInstance.GetComponent<NetworkObject>();
24092340
SpawnObjectInstance(networkObjectToSpawn, owner, destroyWithScene, isPlayerObject);
24102341
return newInstance;
@@ -2453,9 +2384,6 @@ public NetcodeIntegrationTest()
24532384
{
24542385
var topologyType = OnGetNetworkTopologyType();
24552386
InitializeTestConfiguration(topologyType, null);
2456-
#if UNIFIED_NETCODE
2457-
UnifiedBootStrap.OnInitialized += UpdateGhostPrefabs;
2458-
#endif
24592387
}
24602388

24612389
/// <summary>

0 commit comments

Comments
 (0)