浏览代码

update

/main
siyao 3 年前
当前提交
094322f0
共有 7 个文件被更改,包括 57 次插入19 次删除
  1. 12
      Assets/HuaweiService/Editor/cloud_db/ClassTemplate.cs
  2. 27
      Assets/HuaweiService/Editor/cloud_db/CloudDBSetting.cs
  3. 8
      Assets/HuaweiService/Editor/cloud_db/GenCode.cs
  4. 6
      Assets/HuaweiService/cloud_db/CloudDBZoneConfig.cs
  5. 4
      Assets/HuaweiService/cloud_db/CloudDBZoneQuery.cs
  6. 6
      Assets/HuaweiService/cloud_db/Text.cs
  7. 13
      Assets/HuaweiService/fundation/HmsUtil.cs

12
Assets/HuaweiService/Editor/cloud_db/ClassTemplate.cs


case "Long":
typeStr = "long";
break;
case "Text":
typeStr = "Text";
break;
if (defaultValue.Length > 0) {
defaultValue = $"{defaultValue}";
}
if(defaultValue.Length > 0) defaultValue = $"\"{defaultValue}\"";
break;
case "Double":
typeStr = "double";

return typeStr;
}
public string getInitializer() {
public string getInitializer () {
string typeStr = "value";
switch (fieldType) {
case "Integer":

break;
case "Double":
typeStr = "new Double(value)";
break;
case "Text":
typeStr = "new Text()";
break;
case "Float":
typeStr = "new Float(value)";

27
Assets/HuaweiService/Editor/cloud_db/CloudDBSetting.cs


using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using Newtonsoft.Json;
using UnityEditor.SceneManagement;
using UnityEngine;
namespace HuaweiService.CloudDB.Editor {

GUILayout.Space (10);
exportDir = EditorGUILayout.TextField ("Export Path", exportDir);
GUILayout.Space (20);
if (GUILayout.Button ("Choose ObjectType File")) {
chooseFile ();
}
GUILayout.Space (10);
if (GUILayout.Button ("Choose Export Directory")) {
chooseModelDir ();
}
GUILayout.Space (10);
if (GUILayout.Button ("Generate Code")) {
genCode ();
}

void genCode () {
GenCode gen = new GenCode ();
gen.Init (javaPackageName, objectTypeFilePath, namespaceName, exportDir);
}
void chooseFile () {
string path = EditorUtility.OpenFilePanel ("Choose ObjectType JSON file", "", "json");
if (path.Length != 0) {
objectTypeFilePath = path;
}
}
void chooseModelDir () {
string path = EditorUtility.OpenFolderPanel ("Choose Model Directory", "", "model");
if (path.Length != 0) {
exportDir = path+"/model";
}
}
}
}

8
Assets/HuaweiService/Editor/cloud_db/GenCode.cs


string fieldType = field.getFieldType ();
string initialzer = field.getInitializer ();
fs.WriteLine ($"\t\tpublic {fieldType} {fieldName}" + " {");
fs.WriteLine ($"\t\t\tget {{ return Call<{fieldType}> (\"get{fieldName}\");}}");
fs.WriteLine ($"\t\t\tset {{ Call (\"set{fieldName}\" , {initialzer}); }}");
if (!fieldType.Equals ("Text")) {
fs.WriteLine ($"\t\t\tget {{ return Call<{fieldType}> (\"get{fieldName}\");}}");
fs.WriteLine ($"\t\t\tset {{ Call (\"set{fieldName}\" , {initialzer}); }}");
} else {
fs.WriteLine ($"\t\t\tget; set;");
}
fs.WriteLine ("\t\t}");
}

6
Assets/HuaweiService/cloud_db/CloudDBZoneConfig.cs


}
public class CloudDBZoneAccessProperty :HmsClass<CloudDBZoneAccessProperty_Data>
{
public static CloudDBZoneAccessProperty CLOUDDBZONE_PUBLIC => HmsUtil.GetStaticValue<CloudDBZoneAccessProperty>("CLOUDDBZONE_PUBLIC");
public static CloudDBZoneAccessProperty CLOUDDBZONE_PUBLIC => HmsUtil.GetStaticValue<CloudDBZoneAccessProperty>("CLOUDDBZONE_PUBLIC", name);
public CloudDBZoneAccessProperty (): base() { }
}

}
public class CloudDBZoneSyncProperty :HmsClass<CloudDBZoneSyncProperty_Data>
{
public static CloudDBZoneSyncProperty CLOUDDBZONE_LOCAL_ONLY => HmsUtil.GetStaticValue<CloudDBZoneSyncProperty>("CLOUDDBZONE_LOCAL_ONLY");
public static CloudDBZoneSyncProperty CLOUDDBZONE_LOCAL_ONLY => HmsUtil.GetStaticValue<CloudDBZoneSyncProperty>("CLOUDDBZONE_LOCAL_ONLY", name);
public static CloudDBZoneSyncProperty CLOUDDBZONE_CLOUD_CACHE => HmsUtil.GetStaticValue<CloudDBZoneSyncProperty>("CLOUDDBZONE_CLOUD_CACHE");
public static CloudDBZoneSyncProperty CLOUDDBZONE_CLOUD_CACHE => HmsUtil.GetStaticValue<CloudDBZoneSyncProperty>("CLOUDDBZONE_CLOUD_CACHE", name);
public CloudDBZoneSyncProperty (): base() { }
}

4
Assets/HuaweiService/cloud_db/CloudDBZoneQuery.cs


}
public class CloudDBZoneQueryPolicy :HmsClass<CloudDBZoneQueryPolicy_Data>
{
public static CloudDBZoneQueryPolicy POLICY_QUERY_FROM_LOCAL_ONLY => HmsUtil.GetStaticValue<CloudDBZoneQueryPolicy>("POLICY_QUERY_FROM_LOCAL_ONLY");
public static CloudDBZoneQueryPolicy POLICY_QUERY_FROM_LOCAL_ONLY => HmsUtil.GetStaticValue<CloudDBZoneQueryPolicy>("POLICY_QUERY_FROM_LOCAL_ONLY", name);
public static CloudDBZoneQueryPolicy POLICY_QUERY_FROM_CLOUD_ONLY => HmsUtil.GetStaticValue<CloudDBZoneQueryPolicy>("POLICY_QUERY_FROM_CLOUD_ONLY");
public static CloudDBZoneQueryPolicy POLICY_QUERY_FROM_CLOUD_ONLY => HmsUtil.GetStaticValue<CloudDBZoneQueryPolicy>("POLICY_QUERY_FROM_CLOUD_ONLY", name);
public CloudDBZoneQueryPolicy (): base() { }
}

6
Assets/HuaweiService/cloud_db/Text.cs


public void set(string arg0) {
Call("set", arg0);
}
public int hashCode() {
return Call<int>("hashCode");
}
public bool equals(Text arg0) {
return Call<bool>("equals", arg0);
}
}
}

13
Assets/HuaweiService/fundation/HmsUtil.cs


private static Dictionary<Type, Dictionary<string, IHmsBase>> _enums = new Dictionary<Type, Dictionary<string, IHmsBase>>();
internal static T GetStaticValue<T>(string value) where T : IHmsBase, new()
internal static T GetStaticValue<T>(string value, string className="") where T : IHmsBase, new()
{
var type = typeof(T);
if (!_enums.ContainsKey(type))

if (!_enums[type].ContainsKey(value))
{
var result = new T();
result.obj = result.obj.GetStatic<AndroidJavaObject>(value);
if(className.Length > 0) {
var cls = new AndroidJavaClass(className);
result.obj = cls.GetStatic<AndroidJavaObject>(value);
} else {
result.obj = result.obj.GetStatic<AndroidJavaObject>(value);
}
}
}
return (T)_enums[type][value];
}
}
正在加载...
取消
保存