Exemplo n.º 1
0
        private void DoSpawnObject(string _poolName, InstanceObjecHandler _instanceHandler, OnAwakeHandler _awakeHandler)
        {
            if (NetworkServer.active)
            {
                GetObject(_poolName);
                GameObject _go = m_tempObject;

                if (_go != null)
                {
                    // 如果物体池中有同类物体,则将该物体取出,并设置为active
                    RpcSetActive(_go, true);
                    _awakeHandler(_go);
                }
                else
                {
                    // 物体池没有此类物体,Spwan 新物体
                    NetworkServer.Spawn(_instanceHandler());
                }
            }
        }
Exemplo n.º 2
0
 // Spawn物体,并带一个标签名字存入物体池
 public void SpawnObject(string _poolName, InstanceObjecHandler _instanceHandler, OnAwakeHandler _awakeHandler)
 {
     DoSpawnObject(_poolName, _instanceHandler, _awakeHandler);
 }