zoukankan      html  css  js  c++  java
  • xlua笔记(二)

    xlua中不支持通过子物体获取组件

    所以在需要一些没有的功能的时候需要自己对类扩展方法,或者自己写方法  需要添加 [LuaCallCSharp]

    泛型方法必须满足:

    1.泛型方法必须带约束

    2.并且且必须为Class

    3.并且泛型方法必须带有泛型参数

    扩展方法

    支持对自定义类的扩展方法

    支持对自定义类的泛型扩展方法, 但是扩展类型必须是约束类型 如:

    public static T Extension1<T>(this T a) where T : Foo1Parent
    {
    Debug.Log(string.Format("Extension1<{0}>", typeof (T)));
    return a;
    }

    public static T Extension2<T>(this T a, GameObject b) where T : Foo1Parent
    {
    Debug.Log(string.Format("Extension2<{0}>", typeof (T)), b);
    return a;
    }

    public static void Extension2<T1, T2>(this T1 a, T2 b) where T1 : Foo1Parent where T2 : Foo2Parent
    {
    Debug.Log(string.Format("Extension2<{0},{1}>", typeof (T1), typeof (T2)));
    }

    不能像下边这样,对GameObject扩展但是约束为Component

    public static T UnsupportedExtension<T>(this GameObject obj) where T : Component
    {
      return obj.GetComponent<T>();
    }

    本博客所有内容均为原创,转载请注明出处.
  • 相关阅读:
    指针+[][]T 类型
    linux适用小工具-tmux
    wrk+lua进行压力测试
    brew更换为国内源
    k8s证书更新
    ssh隧道
    kubeadm安装集群系列(kubeadm 1.15.1)
    harbor清理存储
    第十周课程总结
    第九周课程总结&第七次实验报告
  • 原文地址:https://www.cnblogs.com/what-lee/p/10107419.html
Copyright © 2011-2022 走看看