internal static void RegisterSpawnHandler(NetworkHash128 assetId, SpawnDelegate spawnHandler, UnSpawnDelegate unspawnHandler) { if (spawnHandler == null || unspawnHandler == null) { if (LogFilter.logError) { Debug.LogError("RegisterSpawnHandler custom spawn function null for " + assetId); } } else { if (LogFilter.logDebug) { Debug.Log(string.Concat(new object[] { "RegisterSpawnHandler asset '", assetId, "' ", spawnHandler.GetMethodName(), "/", unspawnHandler.GetMethodName() })); } NetworkScene.s_SpawnHandlers[assetId] = spawnHandler; NetworkScene.s_UnspawnHandlers[assetId] = unspawnHandler; } }
internal static void RegisterPrefab(GameObject prefab, SpawnDelegate spawnHandler, UnSpawnDelegate unspawnHandler) { NetworkIdentity component = prefab.GetComponent <NetworkIdentity>(); if (component == null) { if (LogFilter.logError) { Debug.LogError("Could not register '" + prefab.name + "' since it contains no NetworkIdentity component"); } } else if (spawnHandler == null || unspawnHandler == null) { if (LogFilter.logError) { Debug.LogError("RegisterPrefab custom spawn function null for " + component.assetId); } } else if (!component.assetId.IsValid()) { if (LogFilter.logError) { Debug.LogError("RegisterPrefab game object " + prefab.name + " has no prefab. Use RegisterSpawnHandler() instead?"); } } else { if (LogFilter.logDebug) { Debug.Log(string.Concat(new object[] { "Registering custom prefab '", prefab.name, "' as asset:", component.assetId, " ", spawnHandler.GetMethodName(), "/", unspawnHandler.GetMethodName() })); } NetworkScene.s_SpawnHandlers[component.assetId] = spawnHandler; NetworkScene.s_UnspawnHandlers[component.assetId] = unspawnHandler; } }
//add by linaibin static internal void RegisterPrefab(GameObject prefab, SpawnExDelegate spawnHandler, UnSpawnDelegate unspawnHandler) { NetworkIdentity identity = prefab.GetComponent <NetworkIdentity>(); if (identity == null) { if (LogFilter.logError) { Debug.LogError("Could not register '" + prefab.name + "' since it contains no NetworkIdentity component"); } return; } if (spawnHandler == null || unspawnHandler == null) { if (LogFilter.logError) { Debug.LogError("RegisterPrefab custom spawn function null for " + identity.assetId); } return; } if (!identity.assetId.IsValid()) { if (LogFilter.logError) { Debug.LogError("RegisterPrefab game object " + prefab.name + " has no prefab. Use RegisterSpawnHandler() instead?"); } return; } if (LogFilter.logDebug) { Debug.Log("Registering custom prefab '" + prefab.name + "' as asset:" + identity.assetId + " " + spawnHandler.GetMethodName() + "/" + unspawnHandler.GetMethodName()); } s_SpawnExHandlers[identity.assetId] = spawnHandler; s_UnspawnHandlers[identity.assetId] = unspawnHandler; }
static internal void RegisterSpawnHandler(NetworkHash128 assetId, SpawnDelegate spawnHandler, UnSpawnDelegate unspawnHandler) { if (spawnHandler == null || unspawnHandler == null) { if (LogFilter.logError) { Debug.LogError("RegisterSpawnHandler custom spawn function null for " + assetId); } return; } if (LogFilter.logDebug) { Debug.Log("RegisterSpawnHandler asset '" + assetId + "' " + spawnHandler.GetMethodName() + "/" + unspawnHandler.GetMethodName()); } s_SpawnHandlers[assetId] = spawnHandler; s_UnspawnHandlers[assetId] = unspawnHandler; }