1.2 KiB
1.2 KiB
#unity/日常积累
GameObject go = AssetDatabase.LoadAssetAtPath("Assets/Prefabs/Point_1.prefab", typeof(GameObject)) as GameObject;
Component[] aaa = go.GetComponents(typeof(Component));
for (int i = 0; i < aaa.Length; i++)
{
if (aaa[i].GetType().Name == "TessObject")
{
FieldInfo[] proper = aaa[i].GetType().GetFields(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public | BindingFlags.NonPublic);
for (int j = 0; j < proper.Length; j++)
{
Type gameObject = typeof(GameObject);
if (proper[j].FieldType == gameObject)
{
GameObject sss =
PrefabUtility.GetCorrespondingObjectFromOriginalSource(
proper[j].GetValue(aaa[i]) as GameObject);
string rootPath = AssetDatabase.GetAssetPath(sss);
Debug.Log("path:" + rootPath);
}
}
Debug.Log(aaa[i].GetType().Name);
}
}