public void LoadSceneData() { #if UNITY_EDITOR var settingData = TGSettingData.GetInstance(); var scn = GameObject.FindObjectOfType <TGBaseScene> (); SceneData sceneData = new SceneData(); if (scn != null) { sceneData = settingData.GetSceneData(scn); } else { sceneData = settingData.sceneDatas[0]; } TGData.SetSceneData(sceneData); if (TGData.SceneName != scn.SceneName) { m_controller.ErrorQuit("当前的场景与game.txt中的设备名称不匹配"); } #else var sceneData = LMFileWriter.ReadJSON <SceneData>(TGPaths.SceneData); TGData.SetSceneData(sceneData); #endif }
public static KeyInputConfig GetInstance() { var retval = LMFileWriter.ReadJSON <KeyInputConfig>(TGPaths.KeyInputSetting); if (retval == null) { throw new Exception(TGPaths.KeyInputSetting + " 并不存在"); } return(retval); }
public static IEnumerator SaveTexture(Texture2D _tex, string _name) { float ratio = ( float )_tex.width / _tex.height; int width = 0, height = 0; // 如果比例大于阈值,则使用Fix width方案 // 反之使用Fix Height方案 if (ratio > FIX_HEIGHT_THRESHOLD) { width = FIX_WIDTH; height = Mathf.RoundToInt(width / ratio); } else { height = FIX_HEIGHT; width = Mathf.RoundToInt(height * ratio); // 如果使用Fix Height方案后,宽度还是超标 // 则再转位Fix Width方案 if (width > FIX_WIDTH) { width = FIX_WIDTH; height = Mathf.RoundToInt(width / ratio); } } Debug.Log("Saved Texture Sizes: " + width + ", " + height); _tex = TextureScaler.ResizeTexture(_tex, width, height); byte[] bytes = _tex.EncodeToPNG(); string path = TGPaths.FullScreenshotPath(_name); Debug.Log("截图路径: " + path); // 写入文件 LMFileWriter.Write(path, bytes); // 写到Dicionary里,好之后写入ret.txt TGData.SaveScreenshot(_name); yield return(null); }
private void LoadEvaluationSetting() { string eval = TGPaths.EvalSetting; // 读取3D传感器的配置 if (!string.IsNullOrEmpty(eval)) { var group = LMFileWriter.ReadJSON <EvalDataGroup>(eval); if (group != null) { string cnTitle = GetValue("体侧", string.Empty); TGData.evalData = GetConfigDataFromTitle(group, cnTitle); } } else { Debug.LogWarning(eval + "Has not found"); } }
private static void OutputConfigs(SceneData _sceneData, string _targetFolder) { CopyConfigToPath(FRAMEWORK_ROOT, _targetFolder, TGConfigs.MAIN_CONFIG_FILENAME); string srcConfigFolder = FRAMEWORK_ROOT + "Configs/"; string dstConfigFolder = _targetFolder + "Configs/"; Directory.CreateDirectory(dstConfigFolder); string[] outputConfigs = new string[] { TGConfigs.EVAL_SETTING_FILENAME, TGConfigs.KEY_INPUT_CONFIG_FILENAME }; foreach (var c in outputConfigs) { CopyConfigToPath(srcConfigFolder, dstConfigFolder, c); } // 制作Json为读取表 LMFileWriter.Write(dstConfigFolder + TGConfigs.SCENE_SETTING_FILENAME, JsonUtility.ToJson(_sceneData, true)); }