internal static bool InvokeUnSpawnHandler(NetworkHash128 assetId, GameObject obj) { if (NetworkScene.s_UnspawnHandlers.ContainsKey(assetId) && NetworkScene.s_UnspawnHandlers[assetId] != null) { UnSpawnDelegate unSpawnDelegate = NetworkScene.s_UnspawnHandlers[assetId]; unSpawnDelegate(obj); return(true); } return(false); }
static internal bool InvokeUnSpawnHandler(NetworkHash128 assetId, GameObject obj) { if (s_UnspawnHandlers.ContainsKey(assetId) && s_UnspawnHandlers[assetId] != null) { UnSpawnDelegate handler = s_UnspawnHandlers[assetId]; handler(obj); return(true); } return(false); }
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); } return; } if (LogFilter.logDebug) { Debug.Log("RegisterSpawnHandler asset '" + assetId + "' " + spawnHandler.GetMethodName() + "/" + unspawnHandler.GetMethodName()); } s_SpawnHandlers[assetId] = spawnHandler; s_UnspawnHandlers[assetId] = unspawnHandler; }
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.Method.Name, "/", unspawnHandler.Method.Name })); } s_SpawnHandlers[assetId] = spawnHandler; s_UnspawnHandlers[assetId] = unspawnHandler; } }
static internal void RegisterPrefab(GameObject prefab, SpawnDelegate 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.Method.Name + "/" + unspawnHandler.Method.Name); } s_SpawnHandlers[identity.assetId] = spawnHandler; s_UnspawnHandlers[identity.assetId] = unspawnHandler; }
//add by linaibin static public void RegisterSpawnHandler(NetworkHash128 assetId, SpawnExDelegate spawnHandler, UnSpawnDelegate unspawnHandler) { NetworkScene.RegisterSpawnHandler(assetId, spawnHandler, unspawnHandler); }
//add by linaibin static public void RegisterPrefab(GameObject prefab, SpawnExDelegate spawnHandler, UnSpawnDelegate unspawnHandler) { NetworkScene.RegisterPrefab(prefab, spawnHandler, 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; } }
internal static void RegisterPrefab(GameObject prefab, SpawnDelegate spawnHandler, UnSpawnDelegate unspawnHandler) { NetworkIdentity component = prefab.GetComponent <NetworkIdentity>(); if ((Object)component == (Object)null) { if (!LogFilter.logError) { return; } Debug.LogError((object)("Could not register '" + prefab.name + "' since it contains no NetworkIdentity component")); } else if (spawnHandler == null || unspawnHandler == null) { if (!LogFilter.logError) { return; } Debug.LogError((object)("RegisterPrefab custom spawn function null for " + (object)component.assetId)); } else if (!component.assetId.IsValid()) { if (!LogFilter.logError) { return; } Debug.LogError((object)("RegisterPrefab game object " + prefab.name + " has no prefab. Use RegisterSpawnHandler() instead?")); } else { if (LogFilter.logDebug) { Debug.Log((object)("Registering custom prefab '" + prefab.name + "' as asset:" + (object)component.assetId + " " + spawnHandler.Method.Name + "/" + unspawnHandler.Method.Name)); } NetworkScene.s_SpawnHandlers[component.assetId] = spawnHandler; NetworkScene.s_UnspawnHandlers[component.assetId] = unspawnHandler; } }
internal static void RegisterSpawnHandler(NetworkHash128 assetId, SpawnDelegate spawnHandler, UnSpawnDelegate unspawnHandler) { if (spawnHandler == null || unspawnHandler == null) { if (!LogFilter.logError) { return; } Debug.LogError((object)("RegisterSpawnHandler custom spawn function null for " + (object)assetId)); } else { if (LogFilter.logDebug) { Debug.Log((object)("RegisterSpawnHandler asset '" + (object)assetId + "' " + spawnHandler.Method.Name + "/" + unspawnHandler.Method.Name)); } NetworkScene.s_SpawnHandlers[assetId] = spawnHandler; NetworkScene.s_UnspawnHandlers[assetId] = unspawnHandler; } }