コード例 #1
0
ファイル: MapManager.cs プロジェクト: TenYearsADream/Frame
        /// <summary>
        /// 摧毁场景物体
        /// </summary>
        /// <param name="id"></param>
        public static void DestoryMapGameObjectInScene(int id)
        {
            if (mapInstanceBuffer.ContainsKey(id))
            {
                List <GameObject> listObjs = mapInstanceBuffer[id];
                mapInstanceBuffer.Remove(id);
                for (int i = 0; i < listObjs.Count; i++)
                {
                    PoolObjectManager.DestroyObject(listObjs[i]);
                }
            }
            if (mapRoot == null)
            {
                mapRoot = GameObject.Find(MapUseConstValues.MapRootObjectName);
            }
            if (mapRoot == null)
            {
                return;
            }
            Transform idRoot = mapRoot.transform.Find(id.ToString());

            if (idRoot != null)
            {
                if (Application.isPlaying)
                {
                    UnityEngine.Object.Destroy(idRoot.gameObject);
                }
                else
                {
                    UnityEngine.Object.DestroyImmediate(idRoot.gameObject);
                }
            }
        }
コード例 #2
0
    public static void DestroyObject(string id)
    {
        GameObject obj = null;

        if (itemDic.ContainsKey(id))
        {
            obj = itemDic[id];
            itemDic.Remove(id);
        }
        if (obj)
        {
            PoolObjectManager.DestroyObject(obj);
        }
    }