其他分享
首页 > 其他分享> > Unity对子物体的深度优先遍历

Unity对子物体的深度优先遍历

作者:互联网

b站傅老师教的做下笔记


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public static class TransformHelpers{    
public static Transform DeepFind(this Transform parent,string targetName)    {        
	Transform tempTrans=null;        
	foreach(Transform child in parent){
	if(child.name==targetName)            
	{                
		return child;            
	} 
 	else {
 		tempTrans=DeepFind(child,targetName);
 		if(tempTrans!=null)                
 		{                    
 			return tempTrans;                
 		}           
  	}        
 }        
 return null;    
 }
 }
谁来,将海 发布了5 篇原创文章 · 获赞 0 · 访问量 100 私信 关注

标签:tempTrans,遍历,return,Transform,Unity,child,对子,null,targetName
来源: https://blog.csdn.net/qq_43262525/article/details/104450268