//Grows out the size of the list and instantiates more objects if more are needed. Size doubles each time until max size is reached. private void Grow() { int growSize = 0; if (m_Pool.Count == 0) //if instantiating objects for the first time, use the initial size provided { growSize = m_InitialSize; } else if (m_Pool.Count >= m_MaxSize) //if pool has already passed the max size, it will not be able to grow anymore { growSize = m_MaxSize; } else { growSize = Mathf.Min(m_Pool.Count * 2, m_MaxSize); //otherwise, double the size of the pool } //instantiate over the network, set object to inactive and add to the pool for (int i = m_Pool.Count; i < growSize; i++) { GameObject gameObject = PhotonNetwork.Instantiate(m_ObjectName, new Vector3(0, 0, 0), Quaternion.identity, 0, null); string uniqueName = gameObject.name.Replace("(Clone)", ObjectPoolManager.UniqueObjectName.ToString()); ObjectPoolManager.UniqueObjectName++; LiamBehaviour behaviour = gameObject.GetComponent <LiamBehaviour>(); if (behaviour != null) { behaviour.SetActive(false); behaviour.SetName(uniqueName); } else { gameObject.SetActive(false); } m_Pool.Add(gameObject); if (m_DontDestroyOnLoad) { GameManager.Instance.DontDestroyNetworkObject(gameObject); } } }
public ComponentInterpolator(LiamBehaviour netObject, Component component) { m_NetObject = netObject; m_Component = component; }