IsObsolete() public static method

public static IsObsolete ( MemberInfo mb ) : bool
mb MemberInfo
return bool
Exemplo n.º 1
0
    static void GenEnumApi(ToLuaMenu.BindType bt)
    {
        //创建api类
        var api = GetClassApi(bt.name);

        foreach (var f in ToLuaExport.type.GetFields(BindingFlags.GetField | BindingFlags.Public | BindingFlags.Static))
        {
            if (ToLuaExport.IsObsolete(f))
            {
                continue;
            }
            api.AddValue(f.Name, bt.name);
        }
        api.AddMethod("IntToEnum");
    }
Exemplo n.º 2
0
 private bool IsObsolete(MethodInfo memberInfo)
 {
     if (memberInfo.Name.StartsWith("get_"))
     {
         return(true);
     }
     if (memberInfo.Name.StartsWith("set_"))
     {
         return(true);
     }
     if (memberInfo.Name.StartsWith("op_"))
     {
         return(true);
     }
     return(ToLuaExport.IsObsolete(memberInfo));
 }
Exemplo n.º 3
0
    static void InitMethods()
    {
        bool flag = false;

        if (baseType != null || isStaticClass)
        {
            binding |= BindingFlags.DeclaredOnly;
            flag     = true;
        }

        List <MethodInfo> list = new List <MethodInfo>();

        list.AddRange(type.GetMethods(BindingFlags.Instance | binding));

        Type tempType = type.BaseType;

        while (tempType.BaseType != null)
        {
            list.AddRange(tempType.GetMethods(BindingFlags.Instance | binding));
            tempType = tempType.BaseType;
        }

        for (int i = list.Count - 1; i >= 0; --i)
        {
            //去掉操作符函数
            if (list[i].Name.StartsWith("op_") || list[i].Name.StartsWith("add_") || list[i].Name.StartsWith("remove_"))
            {
                if (!IsNeedOp(list[i].Name))
                {
                    list.RemoveAt(i);
                }

                continue;
            }

            //扔掉 unity3d 废弃的函数
            if (ToLuaExport.IsObsolete(list[i]))
            {
                list.RemoveAt(i);
            }
            else
            {
                AutoCompleteExport.AddExportMethod(exportName, list[i]);
            }
        }
    }
Exemplo n.º 4
0
    static void GenEnum()
    {
        fields = type.GetFields(BindingFlags.GetField | BindingFlags.Public | BindingFlags.Static);
        List <FieldInfo> list = new List <FieldInfo>(fields);

        for (int i = list.Count - 1; i > 0; i--)
        {
            if (ToLuaExport.IsObsolete(list[i]))
            {
                list.RemoveAt(i);
            }
        }

        fields = list.ToArray();
        for (int i = 0; i < fields.Length; i++)
        {
            AutoCompleteExport.AddExportEnum(exportName, fields[i]);
        }
    }
Exemplo n.º 5
0
    public static void U3dBinding()
    {
        List <string> dropList = new List <string>
        {
            //特殊修改
            "UnityEngine.Object",

            //一般情况不需要的类, 编辑器相关的
            "HideInInspector",
            "ExecuteInEditMode",
            "AddComponentMenu",
            "ContextMenu",
            "RequireComponent",
            "DisallowMultipleComponent",
            "SerializeField",
            "AssemblyIsEditorAssembly",
            "Attribute",  //一些列文件,都是编辑器相关的
            "FFTWindow",

            "Types",
            "UnitySurrogateSelector",
            "TypeInferenceRules",
            "ThreadPriority",
            "Debug",        //自定义debugger取代
            "GenericStack",

            //异常,lua无法catch
            "PlayerPrefsException",
            "UnassignedReferenceException",
            "UnityException",
            "MissingComponentException",
            "MissingReferenceException",

            //RPC网络
            "RPC",
            "Network",
            "MasterServer",
            "BitStream",
            "HostData",
            "ConnectionTesterStatus",

            //unity 自带编辑器GUI
            "GUI",
            "EventType",
            "EventModifiers",
            //"Event",
            "FontStyle",
            "TextAlignment",
            "TextEditor",
            "TextEditorDblClickSnapping",
            "TextGenerator",
            "TextClipping",
            "TextGenerationSettings",
            "TextAnchor",
            "TextAsset",
            "TextWrapMode",
            "Gizmos",
            "ImagePosition",
            "FocusType",


            //地形相关
            "Terrain",
            "Tree",
            "SplatPrototype",
            "DetailPrototype",
            "DetailRenderMode",

            //其他
            "MeshSubsetCombineUtility",
            "AOT",
            "Random",
            "Mathf",
            "Social",
            "Enumerator",
            "SendMouseEvents",
            "Cursor",
            "Flash",
            "ActionScript",


            //非通用的类
            "ADBannerView",
            "ADInterstitialAd",
            "Android",
            "jvalue",
            "iPhone",
            "iOS",
            "CalendarIdentifier",
            "CalendarUnit",
            "CalendarUnit",
            "FullScreenMovieControlMode",
            "FullScreenMovieScalingMode",
            "Handheld",
            "LocalNotification",
            "Motion",   //空类
            "NotificationServices",
            "RemoteNotificationType",
            "RemoteNotification",
            "SamsungTV",
            "TextureCompressionQuality",
            "TouchScreenKeyboardType",
            "TouchScreenKeyboard",
            "MovieTexture",

            //我不需要的
            //2d 类
            "AccelerationEventWrap", //加速
            "AnimatorUtility",
            "AudioChorusFilter",
            "AudioDistortionFilter",
            "AudioEchoFilter",
            "AudioHighPassFilter",
            "AudioLowPassFilter",
            "AudioReverbFilter",
            "AudioReverbPreset",
            "AudioReverbZone",
            "AudioRolloffMode",
            "AudioSettings",
            "AudioSpeakerMode",
            "AudioType",
            "AudioVelocityUpdateMode",

            "Ping",
            "Profiler",
            "StaticBatchingUtility",
            "Font",
            "Gyroscope",                      //不需要重力感应
            "ISerializationCallbackReceiver", //u3d 继承的序列化接口,lua不需要
            "ImageEffectOpaque",              //后处理
            "ImageEffectTransformsToLDR",
            "PrimitiveType",                  // 暂时不需要 GameObject.CreatePrimitive
            "Skybox",                         //不会u3d自带的Skybox
            "SparseTexture",                  // mega texture 不需要
            "Plane",
            "PlayerPrefs",

            //不用ugui
            "SpriteAlignment",
            "SpriteMeshType",
            "SpritePackingMode",
            "SpritePackingRotation",
            "SpriteRenderer",
            "Sprite",
            "UIVertex",
            "CanvasGroup",
            "CanvasRenderer",
            "ICanvasRaycastFilter",
            "Canvas",
            "RectTransform",
            "DrivenRectTransformTracker",
            "DrivenTransformProperties",
            "RectTransformAxis",
            "RectTransformEdge",
            "RectTransformUtility",
            "RectTransform",
            "UICharInfo",
            "UILineInfo",

            //不需要轮子碰撞体
            "WheelCollider",
            "WheelFrictionCurve",
            "WheelHit",

            //手机不适用雾
            "FogMode",

            "UnityEventBase",
            "UnityEventCallState",
            "UnityEvent",

            "LightProbeGroup",
            "LightProbes",

            "NPOTSupport", //只是SystemInfo 的一个枚举值

            //没用到substance纹理
            "ProceduralCacheSize",
            "ProceduralLoadingBehavior",
            "ProceduralMaterial",
            "ProceduralOutputType",
            "ProceduralProcessorUsage",
            "ProceduralPropertyDescription",
            "ProceduralPropertyType",
            "ProceduralTexture",

            //物理关节系统
            "JointDriveMode",
            "JointDrive",
            "JointLimits",
            "JointMotor",
            "JointProjectionMode",
            "JointSpring",
            "SoftJointLimit",
            "SpringJoint",
            "HingeJoint",
            "FixedJoint",
            "ConfigurableJoint",
            "CharacterJoint",
            "Joint",

            "LODGroup",
            "LOD",

            "DataUtility",          //给sprite使用的
            "CrashReport",
            "CombineInstance",
        };

        List <BindType> list     = new List <BindType>();
        Assembly        assembly = Assembly.Load("UnityEngine");

        Type[] types = assembly.GetExportedTypes();

        for (int i = 0; i < types.Length; i++)
        {
            //不导出: 模版类,event委托, c#协同相关, obsolete 类
            if (!types[i].IsGenericType && types[i].BaseType != typeof(System.MulticastDelegate) &&
                !typeof(YieldInstruction).IsAssignableFrom(types[i]) && !ToLuaExport.IsObsolete(types[i]))
            {
                list.Add(_GT(types[i]));
            }
            else
            {
                Debug.Log("drop generic type " + types[i].ToString());
            }
        }

        for (int i = 0; i < dropList.Count; i++)
        {
            list.RemoveAll((p) => { return(p.type.ToString().Contains(dropList[i])); });
        }

        //for (int i = 0; i < list.Count; i++)
        //{
        //    if (!typeof(UnityEngine.Object).IsAssignableFrom(list[i].type) && !list[i].type.IsEnum && !typeof(UnityEngine.TrackedReference).IsAssignableFrom(list[i].type)
        //        && !list[i].type.IsValueType && !list[i].type.IsSealed)
        //    {
        //        Debug.Log(list[i].type.Name);
        //    }
        //}

        for (int i = 0; i < list.Count; i++)
        {
            try
            {
                ToLuaExport.Clear();
                ToLuaExport.className     = list[i].name;
                ToLuaExport.type          = list[i].type;
                ToLuaExport.isStaticClass = list[i].IsStatic;
                ToLuaExport.baseClassName = list[i].baseName;
                ToLuaExport.wrapClassName = list[i].wrapName;
                ToLuaExport.libClassName  = list[i].libName;
                ToLuaExport.Generate(null);
            }
            catch (Exception e)
            {
                Debug.LogWarning("Generate wrap file error: " + e.ToString());
            }
        }

        GenLuaBinder();
        Debug.Log("Generate lua binding files over, Generate " + list.Count + " files");
        AssetDatabase.Refresh();
    }
Exemplo n.º 6
0
 private bool IsObsolete(MemberInfo memberInfo)
 {
     return(ToLuaExport.IsObsolete(memberInfo));
 }