//CopyComponent

ublic static T CopyComponent<T>(T original, GameObject destination) where T : Component
    {
        Type type = original.GetType();
        Component copy = destination.AddComponent(type);
        System.Reflection.FieldInfo[] fields = type.GetFields();
        foreach (System.Reflection.FieldInfo field in fields)
        {
            field.SetValue(copy, field.GetValue(original));
        }
        return copy as T;
    }

 

相关文章:

  • 2021-12-02
  • 2021-12-26
  • 2022-12-23
  • 2022-12-23
  • 2021-10-08
  • 2021-09-09
猜你喜欢
  • 2022-12-23
  • 2021-08-08
  • 2021-05-31
  • 2021-06-21
  • 2022-12-23
  • 2021-07-16
  • 2022-12-23
相关资源
相似解决方案