Exemple #1
0
 void UpdateRegisterTypes()
 {
     List<Type> systemType = new List<Type>();
     List<Type> unityType = new List<Type>();
     List<Type> customType = new List<Type>();
     WrapReflectionTools.GetAllTypes(systemType, unityType, customType);
     string[] output = WrapTextTools.RegisterTypeToString(systemType, unityType, customType);
     //TODO
     string text = File.ReadAllText(WrapConfigFolder + "/RegisterTypesTemplate.txt", System.Text.Encoding.UTF8);// (Resources.Load("WrapPartTemplate") as TextAsset).text;
     text = text.Replace("{RegisterSystemTypes}", output[0]);
     text = text.Replace("{RegisterUnityTypes}", output[1]);
     text = text.Replace("{RegisterCustomTypes}", output[2]);
     if(!Directory.Exists(RegisterGenFolder)){
         Directory.CreateDirectory(RegisterGenFolder);
     }
     WrapTextTools.WriteAllText(RegisterGenFolder, "RegisterTypes.cs", text);
     AssetDatabase.Refresh();
 }
Exemple #2
0
    void UpdateWrapPart(string assemblyName, string classname, string manifest, List<string> typeDic, string[] propertys, 
        string wrapNew, string wrapSCall, string wrapMCall, string[] wrapIndex, string[] wrapOp)
    {
        string classWrapName = assemblyName.Replace(".","") + classname.Replace(".","");   //类似UnityEngineVector3,不带点

        string text = File.ReadAllText(WrapConfigFolder + "/WrapPartTemplate.txt", System.Text.Encoding.UTF8);// (Resources.Load("WrapPartTemplate") as TextAsset).text;

        string types = "";
        for(int i = 0; i < typeDic.Count; i++) {
            types += "\t\t" + typeDic[i] + "\n";
        }
        text = text.Replace("{TypesArray}", types);

        text = text.Replace("{WrapName}", classWrapName);
        text = text.Replace("{WrapSGet}", propertys[0]);
        text = text.Replace("{WrapSSet}", propertys[1]);
        text = text.Replace("{WrapMGet}", propertys[2]);
        text = text.Replace("{WrapMSet}", propertys[3]);

        text = text.Replace("{WrapNew}", wrapNew);
        text = text.Replace("{WrapSCall}", wrapSCall);
        text = text.Replace("{WrapMCall}", wrapMCall);

        text = text.Replace("{WrapIGet}", wrapIndex[0]);
        text = text.Replace("{WrapISet}", wrapIndex[1]);

        text = text.Replace("{WrapAdd}", wrapOp[0]);
        text = text.Replace("{WrapSub}", wrapOp[1]);
        text = text.Replace("{WrapMul}", wrapOp[2]);
        text = text.Replace("{WrapDiv}", wrapOp[3]);
        text = text.Replace("{WrapMod}", wrapOp[4]);

        //TODO OP 逻辑比较
         //  (op_Addition,op_subtraction,op_Multiply,op_Division,op_Modulus,op_GreaterThan,op_LessThan,op_GreaterThanOrEqual,op_LessThanOrEqual,op_Equality,op_Inequality

        if(string.IsNullOrEmpty(assemblyName)) {
            WrapTextTools.WriteAllText(WrapGenFolder, classname + ".cs", text);
            WrapTextTools.WriteAllText(WrapGenFolder, classname + ".txt", manifest);
        }
        else {
            WrapTextTools.WriteAllText(WrapGenFolder + "/" + assemblyName, classname + ".cs", text);
            WrapTextTools.WriteAllText(WrapGenFolder + "/" + assemblyName, classname + ".txt", manifest);
        }
    }