Exemplo n.º 1
0
        public GameObject Pop(GameObject child_, GameObject toParent_)
        {
            if (!Contains(child_))
            {
                return(null);
            }

            m_objArr.Remove(child_);

            GameObjUtil.ChangeParent(child_, toParent_);
            return(child_);
        }
Exemplo n.º 2
0
        //-------∽-★-∽------∽-★-∽--------∽-★-∽CreateChild∽-★-∽--------∽-★-∽------∽-★-∽--------//

        static public GameObject CreateChildByName(GameObject parent_, string name_)
        {
            GameObject go = GameObjUtil.FindChild(parent_, name_);

            if (go == null)
            {
                //还没创建
                go = GameObjUtil.CreateGameobj(name_);
                GameObjUtil.ChangeParent(go, parent_);
            }

            return(go);
        }
Exemplo n.º 3
0
        static public T CreateChildByName <T>(GameObject parent_, string name_) where T : Component
        {
            GameObject go = GameObjUtil.FindChild(parent_, name_);

            if (go == null)
            {
                //还没创建
                go = GameObjUtil.CreateGameobj(name_);
                GameObjUtil.ChangeParent(go, parent_);
            }

            T cmpt = ComponentUtil.EnsureComponent <T>(go);

            return(cmpt);
        }
Exemplo n.º 4
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);
        }