Esempio n. 1
0
    public GameObject GetPoolObjByType(PreLoadType type, Transform parent, UnityEngine.Vector3?scale = null)
    {
        GameObject obj  = null;
        string     path = "";

        if (poolObjs[type].Count > 0)
        {
            lock (poolObjs)
            {
                obj = poolObjs[type][0];
                poolObjs[type].RemoveAt(0);
            }
            //
            obj.transform.SetParent(parent);
        }
        else
        {
            path = poolInfo[type].path;
            obj  = Common.Generate(path, parent);
        }
        if (scale != null)
        {
            obj.transform.localScale = (Vector3)scale;
        }
        obj.SetActive(true);
        return(obj);
    }
Esempio n. 2
0
    public void SetParticle(PreLoadType type, Vector3 pos, bool isWorld = false)
    {
        Transform trans = null;

        switch (type)
        {
        case PreLoadType.ShootParticle:
            trans = transShoot;
            break;

        case PreLoadType.BoatDeadParticle:
            trans = transHurt;
            break;

        default:
            Debug.LogError("type:" + type + "特效未设置节点");
            break;
        }
        GameObject obj = null;

        obj = PoolManager.instance.GetPoolObjByType(type, trans);
        if (!isWorld)
        {
            obj.transform.localPosition = pos;
        }
        else
        {
            obj.transform.position = pos;
        }
    }
Esempio n. 3
0
 public void SetPoolObjByType(PreLoadType type, GameObject obj)
 {
     obj.SetActive(false);
     obj.transform.DOKill();
     obj.transform.parent        = transform;
     obj.transform.localPosition = Vector3.zero;
     obj.transform.localScale    = Vector3.one;
     lock (poolObjs)
     {
         if (!poolObjs[type].Contains(obj))
         {
             poolObjs[type].Add(obj);
         }
         else
         {
             Debug.Log("E" + type.ToString() + "/已在对象池中,请检查!父物体为:" + obj.transform.parent.name);
         }
     }
 }
Esempio n. 4
0
 protected void setType(PreLoadType type)
 {
     m_basicType   = BasePacketType.basePacketTypePreLoad;
     m_preLoadType = type;
 }