コード例 #1
0
        private void SaveConfigToSelect(MachineConfig config)
        {
            string filePath = EditorUtilityEx.GetSelectFile(".bytes");

            if (string.IsNullOrEmpty(filePath))
            {
                Debug.LogWarning("选择的文件无效,写入失败");
                return;
            }

            if (!EditorUtility.DisplayDialog("提示", $"是否将当前配置覆盖到选择文件?\n{filePath}", "是", "否"))
            {
                return;
            }

            string data = DataUtility.ToJson(config);

            File.WriteAllText(filePath, data);
            AssetDatabase.Refresh();

            Debug.Log($"配置已覆盖到 : {filePath}");
        }