Пример #1
0
        //add by linaibin
        static internal void RegisterSpawnHandler(NetworkHash128 assetId, SpawnExDelegate 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_SpawnExHandlers[assetId] = spawnHandler;
            s_UnspawnHandlers[assetId] = unspawnHandler;
        }
Пример #2
0
        //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;
        }