IEnumerator func_Trash(Transform obj)
{
bool flage = true;
while (flage)
{
for (int i = 0; i < obj.childCount; i++)
{
if (obj.GetChild(i).name.Contains("$AssimpFbx$"))
{
List<Transform> changeParent = new List<Transform>();
for (int x = 0; x < obj.GetChild(i).childCount; x++)
{
changeParent.Add(obj.GetChild(i).GetChild(x).transform);
}
foreach (Transform ttt in changeParent)
{
ttt.parent = obj;
}
Destroy(obj.GetChild(i).gameObject);
}
else
{
StopCoroutine(trash);
trash = func_Trash(obj.GetChild(i));
StartCoroutine(trash);
}
}
yield return new WaitForEndOfFrame();
if (obj.childCount == 0)
{
flage = false;
}
else
{
StopCoroutine(trash);
trash = func_Trash(obj.GetChild(0));
StartCoroutine(trash);
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TriLib.Samples;
using SimpleFileBrowser;
public class LoadFBX : MonoBehaviour {
public FileBrowser m_FileBrowser;
public AssetLoaderWindow m_AssetLoaderWindow;
public GameObject TEST;
// Use this for initialization
IEnumerator trash;
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetKeyDown("1"))
{
Debug.Log(" 1 ");
trash = func_Trash(TEST.transform);
StartCoroutine(trash);
}
}
public GameObject func_Load(string mPath)
{
//return m_AssetLoaderWindow.func_LoadInternal(mPath);//Path로 바로 불러오는 버전
Debug.Log("path :"+m_FileBrowser.func_GetPath());
return m_AssetLoaderWindow.func_LoadInternal(m_FileBrowser.func_GetPath());
}
public void func_Load_Button()
{
TEST = func_Load("sssss");
trash = func_Trash(TEST.transform);
StartCoroutine(trash);
}
//해당하는 이름이 포함되는 녀석 제거 재귀함수
IEnumerator func_Trash(Transform obj)
{
bool flage = true;
while (flage)
{
for (int i = 0; i < obj.childCount; i++)
{
if (obj.GetChild(i).name.Contains("$AssimpFbx$"))
{
List<Transform> changeParent = new List<Transform>();
for (int x = 0; x < obj.GetChild(i).childCount; x++)
{
changeParent.Add(obj.GetChild(i).GetChild(x).transform);
}
foreach (Transform ttt in changeParent)
{
ttt.parent = obj;
}
Destroy(obj.GetChild(i).gameObject);
}
else
{
StopCoroutine(trash);
trash = func_Trash(obj.GetChild(i));
StartCoroutine(trash);
}
}
yield return new WaitForEndOfFrame();
if (obj.childCount == 0)
{
flage = false;
}
else
{
StopCoroutine(trash);
trash = func_Trash(obj.GetChild(0));
StartCoroutine(trash);
}
}
}
}
댓글 없음:
댓글 쓰기