unity3d
public class LookGameObjFunc{ public static GameObject FindGameObjByPath(string name, GameObject obj) { string[] strNamePath = name.Split(new char[]{'/'},System.StringSplitOptions.RemoveEmptyEntries); if(strNamePath.Length < 0) return null; GameObject tranName = obj; for(int index = 0; index < strNamePath.Length; ++index) { FindGameObjbyName(strNamePath[index],ref tranName); } return tranName; } private static void FindGameObjbyName(string name, ref GameObject tranf) { foreach(Transform child in tranf.transform) { Debug.Log('childName:' + child.name); if(child.name.Equals(name)) { tranf = child.gameObject; return; } }}}
在unity3dStart函数中调用:GameObject Ui = GameObject.Find('ninjia'); string strPathName = 'Bip01/Bip01 Pelvis//Bip01 Spine/Bip01 Spine1/Bip01 Neck/Bip01 R Clavicle/Bip01 R UpperArm/Bip01 R Forearm/wuqi_bone1'; GameObject tmp = LookGameObjFunc.FindGameObjByPath(strPathName,Ui); Debug.Log(tmp.name);
最后的结果:
大家可以在此基础上根据自己的情况进行修改
代码适用于C#