Clear() public static method

public static Clear ( ) : void
return void
Exemplo n.º 1
0
    static void ClearLuaWraps()
    {
        string[] files = Directory.GetFiles(CustomSettings.saveDir, "*.cs", SearchOption.TopDirectoryOnly);

        for (int i = 0; i < files.Length; i++)
        {
            File.Delete(files[i]);
        }

        ToLuaExport.Clear();
        List <DelegateType> list = new List <DelegateType>();

        ToLuaExport.GenDelegates(list.ToArray());
        ToLuaExport.Clear();

        StringBuilder sb = new StringBuilder();

        sb.AppendLineEx("using System;");
        sb.AppendLineEx("using LuaInterface;");
        sb.AppendLineEx();
        sb.AppendLineEx("public static class LuaBinder");
        sb.AppendLineEx("{");
        sb.AppendLineEx("\tpublic static void Bind(LuaState L)");
        sb.AppendLineEx("\t{");
        sb.AppendLineEx("\t\tthrow new LuaException(\"Please generate LuaBinder files first!\");");
        sb.AppendLineEx("\t}");
        sb.AppendLineEx("}");

        string file = CustomSettings.saveDir + "LuaBinder.cs";

        using (StreamWriter textWriter = new StreamWriter(file, false, Encoding.UTF8))
        {
            textWriter.Write(sb.ToString());
            textWriter.Flush();
            textWriter.Close();
        }

        AssetDatabase.Refresh();
    }
Exemplo n.º 2
0
    public static void GenerateClassWraps()
    {
        if (!beAutoGen && EditorApplication.isCompiling)
        {
            EditorUtility.DisplayDialog("警告", "请等待编辑器完成编译再执行此功能", "确定");
            return;
        }

        if (!File.Exists(CustomSettings.saveDir))
        {
            Directory.CreateDirectory(CustomSettings.saveDir);
        }

        allTypes.Clear();
        BindType[] list = GenBindTypes(CustomSettings.customTypeList);

        for (int i = 0; i < list.Length; i++)
        {
            ToLuaExport.allTypes.Add(list[i].type);
        }

        for (int i = 0; i < list.Length; i++)
        {
            ToLuaExport.Clear();
            ToLuaExport.className     = list[i].name;
            ToLuaExport.type          = list[i].type;
            ToLuaExport.isStaticClass = list[i].IsStatic;
            ToLuaExport.baseType      = list[i].baseType;
            ToLuaExport.wrapClassName = list[i].wrapName;
            ToLuaExport.libClassName  = list[i].libName;
            ToLuaExport.extendList    = list[i].extendList;
            ToLuaExport.Generate(CustomSettings.saveDir);
        }

        Debug.Log("Generate lua binding files over");
        ToLuaExport.allTypes.Clear();
        allTypes.Clear();
        AssetDatabase.Refresh();
    }
Exemplo n.º 3
0
    public static void Binding()
    {
        BindType[] list = WrapFile.getBinds();

        for (int i = 0; i < list.Length; i++)
        {
            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);
        }

        GenLuaBinder();
        // 暂不需要生成委托工厂
        //GenLuaDelegates();
        Debug.Log("Generate lua binding files over");
        AssetDatabase.Refresh();
    }
Exemplo n.º 4
0
    static void GenLuaDelegates()
    {
        // 如果 beAutoGen 为假且脚本正在编译中就弹窗警告
        if (!beAutoGen && EditorApplication.isCompiling)
        {
            EditorUtility.DisplayDialog("警告", "请等待编辑器完成编译再执行此功能", "确定");
            return;
        }

        // 重置 ToLuaExport
        ToLuaExport.Clear();
        // 新建一个委托类型信息类 list,并将 CustomSettings.customDelegateList 中所有元素添加进来
        List <DelegateType> list = new List <DelegateType>();

        list.AddRange(CustomSettings.customDelegateList);
        // 以 HashSet<Type> 形式获取 CustomSettings.customTypeList 中所有委托类型元素(字段、属性、方法参数)的类型
        HashSet <Type> set = GetCustomTypeDelegates();

        // 如果委托 list 中找不到当前类型的委托类型信息类,就新建一个并添加到 HashSet 中
        foreach (Type t in set)
        {
            if (null == list.Find((p) => { return(p.type == t); }))
            {
                list.Add(new DelegateType(t));
            }
        }

        // 生成 "DelegateFactory.cs" 脚本
        ToLuaExport.GenDelegates(list.ToArray());
        // 释放资源
        set.Clear();
        ToLuaExport.Clear();
        // 刷新 AssetDatabase、打印消息
        AssetDatabase.Refresh();
        Debug.Log("Create lua delegate over");
    }
Exemplo n.º 5
0
        private void ExportType(BindType bindType)
        {
            var type = bindType.type;

            if (!NeedExportType(type))
            {
                return;
            }

            ToLuaExport.Clear();
            ToLuaExport.className     = bindType.name;
            ToLuaExport.type          = bindType.type;
            ToLuaExport.isStaticClass = bindType.IsStatic;
            ToLuaExport.baseType      = bindType.baseType;
            ToLuaExport.wrapClassName = bindType.wrapName;
            ToLuaExport.libClassName  = bindType.libName;
            ToLuaExport.extendList    = bindType.extendList;

            ExportType(type);

            ToLuaExport.Clear();

            AddType(type.BaseType);
        }
Exemplo n.º 6
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.º 7
0
 public void GenDelegate()
 {
     ToLuaExport.Clear();
     ToLuaExport.GenDelegates(GetAllBuildedDelegate().ToArray(), delegateFactoryFilePath);
     ToLuaExport.Clear();
 }
Exemplo n.º 8
0
    public static void GenerateSublimeCompletion()
    {
        if (!beAutoGen && EditorApplication.isCompiling)
        {
            EditorUtility.DisplayDialog("警告", "请等待编辑器完成编译再执行此功能", "确定");
            return;
        }

        if (!File.Exists(CustomSettings.saveDir))
        {
            Directory.CreateDirectory(CustomSettings.saveDir);
        }


        ToLuaExport.autocomp.Clear();

        allTypes.Clear();
        BindType[] typeList = CustomSettings.customTypeList;

        BindType[] list = GenBindTypes(typeList);
        ToLuaExport.allTypes.AddRange(baseType);

        for (int i = 0; i < list.Length; i++)
        {
            ToLuaExport.allTypes.Add(list[i].type);
        }

        for (int i = 0; i < list.Length; i++)
        {
            ToLuaExport.Clear();
            ToLuaExport.className     = list[i].name;
            ToLuaExport.type          = list[i].type;
            ToLuaExport.isStaticClass = list[i].IsStatic;
            ToLuaExport.baseType      = list[i].baseType;
            ToLuaExport.wrapClassName = list[i].wrapName;
            ToLuaExport.libClassName  = list[i].libName;
            ToLuaExport.extendList    = list[i].extendList;
            ToLuaExport.GenerateComp(CustomSettings.saveDir);
        }


        string file = "./../../SublimeTolua/quickxlib/tolua.sublime-completions";

        using (StreamWriter textWriter = new StreamWriter(file, false, Encoding.UTF8))
        {
            textWriter.Write("{\n\"scope\": \"source.lua\",\n\"completions\":\n[");
            textWriter.Write(ToLuaExport.autocomp.ToString());

            textWriter.Write("]\n}\n");

            textWriter.Flush();
            textWriter.Close();
        }


        Debug.Log("Generate sublime completion files over");
        ToLuaExport.allTypes.Clear();
        allTypes.Clear();



        AssetDatabase.Refresh();
    }