Exemplo n.º 1
0
        //-------∽-★-∽------∽-★-∽--------∽-★-∽数据操作∽-★-∽--------∽-★-∽------∽-★-∽--------//

        /// <summary>
        /// 回收对象
        /// </summary>
        /// <param name="obj_"></param>
        public void Push(GameObject child_)
        {
            if (Contains(child_))
            {
                return;
            }

            GameObjUtil.RecordLocalMatrix(child_.transform);  //记录位置
            child_.transform.parent = m_transform;
            GameObjUtil.ApplyLocalMatrix(child_.transform);   //恢复位置

            m_objArr.Add(child_);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 替换子对象
        /// </summary>
        /// <param name="name_"></param>
        /// <param name="replace_"></param>
        public void ReplaceChildByName(string name_, GameObject replace_)
        {
            GameObject child = GetChildByName(name_, true);

            if (child == null)
            {
                return;
            }

            GameObject parent = GameObjUtil.GetParent(child);

            GameObjUtil.RecordLocalMatrix(child.transform);
            GameObjUtil.ApplyLocalMatrix(replace_.transform);

            GameObjUtil.Delete(child);  //删除原来的子对象
            GameObjUtil.ChangeParent(replace_, parent);
        }