zoukankan      html  css  js  c++  java
  • unity的AddComponent(string)提示已过时的解决方法

    由于之前的AddComponent(string name)过时了,听说是性能方面的问题,所以被废弃了,但是我可以使用AddComponent(System.Type t)。下面上代码

    Type t = Type.GetType(“CustomClassName”);
    /*这个type如果是使用我们自己的类,那么直接这么用好了。
    但是如果是系统的类的话,比如Button什么的,
    那么直接用类名可能是找不到的,要带上命名空间,但是系统函数的命名空间分的很细,不好找,所以请用下面这个方式获取名字: string className = typeof(Button).AssemblyQualifiedName;
    */ gameObject.AddComponent(t);
  • 相关阅读:
    StackView
    横竖屏
    Html
    UILabel
    NSString
    NSPredicate|谓词
    iphone
    函数
    UIBezierPath
    UICollectionView
  • 原文地址:https://www.cnblogs.com/Transmuter/p/11098443.html
Copyright © 2011-2022 走看看