예제 #1
0
        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");
                }
                return;
            }
            if (spawnHandler == null || unspawnHandler == null)
            {
                if (LogFilter.logError)
                {
                    Debug.LogError("RegisterPrefab custom spawn function null for " + component.assetId);
                }
                return;
            }
            if (!component.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:" + component.assetId + " " + spawnHandler.GetMethodName() + "/" + unspawnHandler.GetMethodName());
            }
            s_SpawnHandlers[component.assetId]   = spawnHandler;
            s_UnspawnHandlers[component.assetId] = unspawnHandler;
        }
예제 #2
0
 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;
     }
 }
예제 #3
0
        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.Method.Name, "/", unspawnHandler.Method.Name }));
                }
                s_SpawnHandlers[component.assetId]   = spawnHandler;
                s_UnspawnHandlers[component.assetId] = unspawnHandler;
            }
        }
 static internal bool GetSpawnHandler(NetworkHash128 assetId, out SpawnDelegate handler)
 {
     if (s_SpawnHandlers.ContainsKey(assetId))
     {
         handler = s_SpawnHandlers[assetId];
         return(true);
     }
     handler = null;
     return(false);
 }
예제 #5
0
        internal static bool GetSpawnHandler(NetworkHash128 assetId, out SpawnDelegate handler)
        {
            bool result;

            if (NetworkScene.s_SpawnHandlers.ContainsKey(assetId))
            {
                handler = NetworkScene.s_SpawnHandlers[assetId];
                result  = true;
            }
            else
            {
                handler = null;
                result  = false;
            }
            return(result);
        }
예제 #6
0
 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;
 }
예제 #7
0
 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;
     }
 }
 static public void RegisterSpawnHandler(NetworkHash128 assetId, SpawnDelegate spawnHandler, UnSpawnDelegate unspawnHandler)
 {
     NetworkScene.RegisterSpawnHandler(assetId, spawnHandler, unspawnHandler);
 }
 static public void RegisterPrefab(GameObject prefab, SpawnDelegate spawnHandler, UnSpawnDelegate unspawnHandler)
 {
     NetworkScene.RegisterPrefab(prefab, spawnHandler, unspawnHandler);
 }