1. Unity环境配置
复制unity安装目录下的System.Configuration ddl文件到项目文件夹下。
项目目录
2.编写脚本
- 引用命名空间using System.Configuration;
-
void Start() { ExeConfigurationFileMap file = new ExeConfigurationFileMap(); file.ExeConfigFilename = Application.streamingAssetsPath + "/Configs/Python.config"; Configuration config = ConfigurationManager.OpenMappedExeConfiguration(file, ConfigurationUserLevel.None); string pythonPath = config.AppSettings.Settings["pythonPath"].Value; Debug.Log(pythonPath); }