public void JsonEditModeTestSimplePasses() { // Use the Assert class to test conditions. TetsJson t = new TetsJson(); Debug.Log(JsonUtils.ClassOrStructToJson(t)); }
/// <summary> /// 将一个场景物体转换为信息(string) /// </summary> /// <param name="root"></param> /// <returns></returns> public string GetSceneInfo() { MapWorld mapWorld = new MapWorld(); List <MapObject> mapobjs = new List <MapObject>(); int childCount = mapNameRoot.childCount; for (int i = 0; i < childCount; i++) { Transform item = mapNameRoot.GetChild(i); MapObject mop = new MapObject(); mop.name = item.name; mop.isStatic = item.gameObject.isStatic; mop.transformInfo.position = item.localPosition; mop.transformInfo.rotation = item.localRotation.eulerAngles; mop.transformInfo.scale = item.localScale; MonoBehaviour[] mos = item.GetComponents <MonoBehaviour>(); foreach (MonoBehaviour m in mos) { ClassValue cv = new ClassValue(m); mop.behavirComponets.Add(cv); } mapobjs.Add(mop); } mapWorld.mapObjects = mapobjs; mapWorld.lightPrefab = mapLightRoot.name; return(JsonUtils.ClassOrStructToJson(mapWorld)); }
private void OnGUI() { if (worldSettingData == null) { return; } toolbarOption = GUILayout.Toolbar(toolbarOption, toolbarTexts, GUILayout.Width(Screen.width)); switch (toolbarOption) { case 0: WorldSettingGUI(); break; case 1: WorldSystemSettingGUI(); break; } GUILayout.FlexibleSpace(); if (GUILayout.Button("保存")) { string path = PathDic + SettingFileName + ".txt"; string data = JsonUtils.ClassOrStructToJson(worldSettingData); FileUtils.CreateTextFile(path, data); AssetDatabase.Refresh(); } }
public void SaveData(string name, LogicObject lo) { MessageString ms = new MessageString(name, JsonUtils.ClassOrStructToJson(lo)); msData.mesList.Add(ms); EditorUtility.SetDirty(msData); }
/// <summary> /// 创建bundle信息 /// </summary> /// <param name="settingData"></param> public static void CreateBundleVersionFile(string assetPath, AssetBundleInfo assetBundleInfo) { if (assetPath[assetPath.Length - 1] != '/') { assetPath += "/"; } string data = JsonUtils.ClassOrStructToJson(assetBundleInfo); FileUtils.CreateTextFile(assetPath + UpdateAssetsConst.AssetBundleInfoFileName, data); }
public void SetValue(string vName, object vValue) { if (vValue == null) { return; } cacheObje = vValue; this.name = vName; Type type = vValue.GetType(); typeName = type.FullName; if (type.IsPrimitive || type == typeof(string)) { value = vValue.ToString(); valueType = ValueType.CsharpBaseValue; } else if (type.IsArray) { typeName = type.GetElementType().FullName; value = JsonUtils.ArrayToJson(vValue); valueType = ValueType.Array; } else if (type.IsGenericType) { if (typeof(List <>).Name == type.Name) { Type t = type.GetGenericArguments()[0]; typeName = t.FullName; value = JsonUtils.ListToJson(vValue); valueType = ValueType.List; } else if (typeof(Dictionary <,>).Name == type.Name) { Type[] tArr = type.GetGenericArguments(); typeName = tArr[0].FullName + "," + tArr[1].FullName; valueType = ValueType.Dictionary; value = JsonUtils.DictionaryToJson(vValue); } } else if (type.IsEnum) { value = ((int)vValue).ToString(); valueType = ValueType.Enum; } else { if (type.IsClass || type.IsValueType) { valueType = ValueType.ClassOrStruct; value = JsonUtils.ClassOrStructToJson(vValue); } } }
public static void SaveData(string dataName, string pathName, LogicObjectContainer data) { string path = LogicSystemEditorTools.GetPath(dataName, pathName); string content = JsonUtils.ClassOrStructToJson(data); FileUtils.CreateTextFile(path, content); if (!ResourcePathManager.ContainsFileName(dataName)) { ResourcePathManager.Clear(); } }
public string GetLightMapInfo() { LightMapObject lightmapObj = new LightMapObject(); int childCount = mapNameRoot.childCount; for (int i = 0; i < childCount; i++) { Transform item = mapNameRoot.GetChild(i); MapObjectRendererLightMapInfo renderInfo = new MapObjectRendererLightMapInfo(); if (item.gameObject.isStatic) { MeshRenderer[] renders = item.GetComponentsInChildren <MeshRenderer>(); foreach (var r in renders) { RendererLightMapInfo rInfo = new RendererLightMapInfo(); rInfo.lightmapIndex = r.lightmapIndex; rInfo.lightmapScaleOffset = r.lightmapScaleOffset; renderInfo.renderLightMapInfos.Add(rInfo); } } lightmapObj.mapObjectRendererLightMapInfo.Add(renderInfo); } lightmapObj.lightmapsMode = LightmapSettings.lightmapsMode; lightmapObj.fogInfo.fog = RenderSettings.fog; lightmapObj.fogInfo.fogMode = RenderSettings.fogMode; lightmapObj.fogInfo.fogColor = RenderSettings.fogColor; lightmapObj.fogInfo.fogStartDistance = RenderSettings.fogStartDistance; lightmapObj.fogInfo.fogEndDistance = RenderSettings.fogEndDistance; //Debug.Log("customReflection :" + AssetDatabase.GetAssetPath(RenderSettings.customReflection)); for (int i = 0; i < LightmapSettings.lightmaps.Length; i++) { LightmapData data = LightmapSettings.lightmaps[i]; if (data.lightmapDir != null) { lightmapObj.lightmapDir.Add(MapUseConstValues.LightmapDirNamePrefix + MapManager.MapInfosDic[currentLoadMap.id].mapFileName + "_" + i); } if (data.lightmapColor != null) { lightmapObj.lightmapColor.Add(MapUseConstValues.LightmapColorPrefix + MapManager.MapInfosDic[currentLoadMap.id].mapFileName + "_" + i); } } ReflectionProbe[] reflectionProbes = mapLightRoot.gameObject.GetComponentsInChildren <ReflectionProbe>(); foreach (var item in reflectionProbes) { ReflectionProbeInfo info = new ReflectionProbeInfo(); info.gameObjectName = item.gameObject.name; if (item.bakedTexture != null) { string sPath = AssetDatabase.GetAssetPath(item.bakedTexture); info.reflectionProbeFileName = Path.GetFileNameWithoutExtension(sPath); } else { info.reflectionProbeFileName = ""; } lightmapObj.reflectionProbeInfos.Add(info); } return(JsonUtils.ClassOrStructToJson(lightmapObj)); }
void BackUpAndUpdateGUI() { GUILayout.Space(7); GUILayout.Box("Game Version : " + PlayerSettings.bundleVersion); gameVersionInfo.latestVersion = EditorDrawGUIUtil.DrawBaseValue("最新版本:", gameVersionInfo.latestVersion).ToString(); gameVersionInfo.forceUpdateVersion = EditorDrawGUIUtil.DrawBaseValue("最小强制更新包版本:", gameVersionInfo.forceUpdateVersion).ToString(); versionControlInfo.assetBundleVersions.Sort(); GUILayout.Box("Assset Bundle Update Package :"); foreach (var item in versionControlInfo.assetBundleVersions) { GUILayout.BeginHorizontal("box"); GUILayout.Label(item.ToString()); if (GUILayout.Button("Delete", GUILayout.Width(60))) { if (EditorUtility.DisplayDialog("警告", "是否删除该更新版本?", "是", "取消")) { versionControlInfo.assetBundleVersions.Remove(item); return; } } GUILayout.EndHorizontal(); GUILayout.Space(4); } int num = GetMaxNumber(versionControlInfo.assetBundleVersions) + 1; GUILayout.Label("当前生成更新包版本 :" + num); GUILayout.FlexibleSpace(); if (GUILayout.Button("Create Package")) { if (num == 0) { versionControlInfo.assetBundleVersions.Add(num); } int res = 0; if (num != 0) { string md5Data = UpdatePackageController.GetPathMD5File(PlayerSettings.productName, PlayerSettings.bundleVersion, num - 1); string md5DataNew = FileUtils.LoadTextFileByPath(Application.streamingAssetsPath + "/" + UpdateAssetsConst.PathMD5FileName); res = CreateUpdatePack(md5Data, md5DataNew); Debug.Log("更新包包含更新文件个数 :" + res); } if (num == 0 || res > 0) { //GameVersionInfo FileUtils.CreateTextFile(UpdatePackageController.localDirPath + "/" + UpdateAssetsConst.GameVersionInfoFileName, JsonUtils.ClassOrStructToJson(gameVersionInfo)); UpdatePackageController.UpLoadFile(UpdatePackageController.localDirPath + "/" + UpdateAssetsConst.GameVersionInfoFileName, assetBundleInfo.gameName); //VersionControlInfo FileUtils.CreateTextFile(UpdatePackageController.localDirPath + "/" + UpdateAssetsConst.VersionControlInfoFileName, JsonUtils.ClassOrStructToJson(versionControlInfo)); string tempPath = assetBundleInfo.gameName + "/" + assetBundleInfo.gameVersion; UpdatePackageController.UpLoadFile(UpdatePackageController.localDirPath + "/" + UpdateAssetsConst.VersionControlInfoFileName, tempPath); //PathMD5File tempPath = assetBundleInfo.gameName + "/" + assetBundleInfo.gameVersion + "/" + assetBundleInfo.assetBundleVersion; UpdatePackageController.UpLoadFile(Application.streamingAssetsPath + "/" + UpdateAssetsConst.PathMD5FileName, tempPath); if (res > 0) { //update.zip UpdatePackageController.UpLoadFile(UpdatePackageController.localDirPath + "/" + UpdateAssetsConst.UpdatePackageFileName, tempPath); } } } GUILayout.Space(10); }