internal static void RegisterSpawnHandler(NetworkHash128 assetId, QSpawnDelegate spawnHandler, UnSpawnDelegate unspawnHandler)
 {
     if (spawnHandler == null || unspawnHandler == null)
     {
         Debug.LogError($"RegisterSpawnHandler custom spawn function null for {assetId}");
     }
     else
     {
         spawnHandlers[assetId]   = spawnHandler;
         unspawnHandlers[assetId] = unspawnHandler;
     }
 }
        internal static bool GetSpawnHandler(NetworkHash128 assetId, out QSpawnDelegate handler)
        {
            bool result;

            if (spawnHandlers.ContainsKey(assetId))
            {
                handler = spawnHandlers[assetId];
                result  = true;
            }
            else
            {
                handler = null;
                result  = false;
            }
            return(result);
        }
        internal static void RegisterPrefab(GameObject prefab, QSpawnDelegate spawnHandler, UnSpawnDelegate unspawnHandler)
        {
            var component = prefab.GetComponent <QNetworkIdentity>();

            if (component == null)
            {
                Debug.LogError($"Could not register '{prefab.name}' since it contains no NetworkIdentity component");
            }
            else if (spawnHandler == null || unspawnHandler == null)
            {
                Debug.LogError($"RegisterPrefab custom spawn function null for {component.AssetId}");
            }
            else if (!component.AssetId.IsValid())
            {
                Debug.LogError($"RegisterPrefab game object {prefab.name} has no prefab. Use RegisterSpawnHandler() instead?");
            }
            else
            {
                spawnHandlers[component.AssetId]   = spawnHandler;
                unspawnHandlers[component.AssetId] = unspawnHandler;
            }
        }
Esempio n. 4
0
 public static void RegisterSpawnHandler(NetworkHash128 assetId, QSpawnDelegate spawnHandler, UnSpawnDelegate unspawnHandler) => QNetworkScene.RegisterSpawnHandler(assetId, spawnHandler, unspawnHandler);
Esempio n. 5
0
 public static void RegisterPrefab(GameObject prefab, QSpawnDelegate spawnHandler, UnSpawnDelegate unspawnHandler) => QNetworkScene.RegisterPrefab(prefab, spawnHandler, unspawnHandler);