Beispiel #1
0
 static internal bool GetSpawnHandler(NetworkHash128 assetId, out SpawnDelegate handler)
 {
     if (s_SpawnHandlers.ContainsKey(assetId))
     {
         handler = s_SpawnHandlers[assetId];
         return(true);
     }
     handler = null;
     return(false);
 }
Beispiel #2
0
 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);
 }
Beispiel #3
0
 internal void SetDynamicAssetId(NetworkHash128 newAssetId)
 {
     if (!m_AssetId.IsValid() || m_AssetId.Equals(newAssetId))
     {
         m_AssetId = newAssetId;
     }
     else
     {
         if (LogFilter.logWarn)
         {
             Debug.LogWarning("SetDynamicAssetId object already has an assetId <" + m_AssetId + ">");
         }
     }
 }
Beispiel #4
0
 static internal bool GetPrefab(NetworkHash128 assetId, out GameObject prefab)
 {
     if (!assetId.IsValid())
     {
         prefab = null;
         return(false);
     }
     if (s_GuidToPrefab.ContainsKey(assetId) && s_GuidToPrefab[assetId] != null)
     {
         prefab = s_GuidToPrefab[assetId];
         return(true);
     }
     prefab = null;
     return(false);
 }
Beispiel #5
0
        // ------------------------ NetworkScene pass-throughs ---------------------

        static internal string GetStringForAssetId(NetworkHash128 assetId)
        {
            GameObject prefab;

            if (NetworkScene.GetPrefab(assetId, out prefab))
            {
                return(prefab.name);
            }

            SpawnDelegate handler;

            if (NetworkScene.GetSpawnHandler(assetId, out handler))
            {
                return(handler.GetMethodName());
            }

            return("unknown");
        }
Beispiel #6
0
        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;
        }
Beispiel #7
0
 public void Write(NetworkHash128 value)
 {
     Write(value.i0);
     Write(value.i1);
     Write(value.i2);
     Write(value.i3);
     Write(value.i4);
     Write(value.i5);
     Write(value.i6);
     Write(value.i7);
     Write(value.i8);
     Write(value.i9);
     Write(value.i10);
     Write(value.i11);
     Write(value.i12);
     Write(value.i13);
     Write(value.i14);
     Write(value.i15);
 }
Beispiel #8
0
        static internal void RegisterPrefab(GameObject prefab, NetworkHash128 newAssetId)
        {
            NetworkIdentity view = prefab.GetComponent <NetworkIdentity>();

            if (view)
            {
                view.SetDynamicAssetId(newAssetId);

                if (LogFilter.logDebug)
                {
                    Debug.Log("Registering prefab '" + prefab.name + "' as asset:" + view.assetId);
                }
                s_GuidToPrefab[view.assetId] = prefab;
            }
            else
            {
                if (LogFilter.logError)
                {
                    Debug.LogError("Could not register '" + prefab.name + "' since it contains no NetworkIdentity component");
                }
            }
        }
Beispiel #9
0
 static public void UnregisterSpawnHandler(NetworkHash128 assetId)
 {
     s_SpawnHandlers.Remove(assetId);
     s_UnspawnHandlers.Remove(assetId);
 }
Beispiel #10
0
 static public void UnregisterSpawnHandler(NetworkHash128 assetId)
 {
     NetworkScene.UnregisterSpawnHandler(assetId);
 }
Beispiel #11
0
 static public void RegisterSpawnHandler(NetworkHash128 assetId, SpawnDelegate spawnHandler, UnSpawnDelegate unspawnHandler)
 {
     NetworkScene.RegisterSpawnHandler(assetId, spawnHandler, unspawnHandler);
 }
Beispiel #12
0
 // this assigns the newAssetId to the prefab. This is for registering dynamically created game objects for already know assetIds.
 static public void RegisterPrefab(GameObject prefab, NetworkHash128 newAssetId)
 {
     NetworkScene.RegisterPrefab(prefab, newAssetId);
 }
Beispiel #13
0
        void AssignAssetID(GameObject prefab)
        {
            string path = AssetDatabase.GetAssetPath(prefab);

            m_AssetId = NetworkHash128.Parse(AssetDatabase.AssetPathToGUID(path));
        }