Advertisement
apieceoffruit

Untitled

Jul 26th, 2021
812
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.66 KB | None | 0 0
  1. using Photon.Pun;
  2. using UnityEngine;
  3. namespace JasonStorey
  4. {
  5.     public class PhotonPrefabRegistry : MonoBehaviour
  6.     {
  7.         [SerializeField]
  8.         GameObject[] things;
  9.  
  10.         void Start ()
  11.         {
  12.             var pool = PhotonNetwork.PrefabPool as DefaultPool;
  13.             if (pool == null)
  14.                 return;
  15.  
  16.             AddToPool(things, pool);
  17.         }
  18.  
  19.         void AddToPool(GameObject[] prefabList, DefaultPool pool)
  20.         {
  21.             if (prefabList == null)
  22.                 return;
  23.            
  24.             foreach (var prefab in prefabList)
  25.                 pool.ResourceCache.Add(prefab.name, prefab);
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement