using System.Reflection;
using UnityEngine;
using System;
public static object GetComponentByName(GameObject targetGameObject, string componentName)
{
Type componentType = Type.GetType(componentName);
object component = targetGameObject.GetComponents(componentType)[0];
return component;
}
Unity 根据组件名称获得组件(Component)
最新推荐文章于 2024-08-25 22:39:22 发布