/// <summary> /// 切换方案 /// 由于自动打包会调用这里,所以将切换宏定义的代码也放在此处,注意! /// </summary> /// <param name="SchemeName"></param> public static void ChangeScheme(string SchemeName) { SchemeData data = SDKManager.LoadGameSchemeConfig(); string oldSchemeName = "None"; if (!IsExitsSchemeName(SchemeName)) { Debug.Log("->" + SchemeName + "<- 方案不存在! "); return; } if (data != null) { oldSchemeName = data.SchemeName; } //方案相同不切换 if (SchemeName == oldSchemeName) { return; } //重新生成游戏内使用的配置 SaveGameSchemeConfig(GetSchemeData(SchemeName)); if (IsExitsSchemeName(SchemeName)) { Debug.Log("Index: " + GetSchemeIndex(SchemeName)); //替换文件夹 if (oldSchemeName != "None") { UnloadPluginFile(oldSchemeName); UnloadSchemeFile(oldSchemeName); } LoadPluginFile(SchemeName); LoadSchemeFile(SchemeName); //调整宏定义 EditorExpand.ChangeDefine(new string[] { SchemeName }, new string[] { oldSchemeName }); } else { //这部分代码实际上不会执行 Debug.Log("不存在的方案名! " + SchemeName); if (oldSchemeName != "None") { //把当前方案收起来 UnloadPluginFile(oldSchemeName); UnloadSchemeFile(oldSchemeName); //移除宏定义 EditorExpand.ChangeDefine(new string[] {}, new string[] { oldSchemeName }); } } AssetDatabase.Refresh(); }
void DelectScheme() { SchemeDataService.DelectScheme(m_currentSchemeData); //移除宏定义 EditorExpand.ChangeDefine(new string[] { }, new string[] { m_currentSchemeData.SchemeName }); m_currentSchemeData = null; m_currentSelectIndex = GetCurrentSelectIndex(); }
void CreateScheme(string SchemeName) { SchemeData data = SchemeDataService.AddScheme(SchemeName); //如果当前没有方案,则把新建的方案设为当前方案 if (m_currentSchemeData == null) { m_currentSchemeData = data; m_currentSelectIndex = GetCurrentSelectIndex(); LoadSchemeData(m_currentSchemeData); SaveScheme(); //设置宏定义 EditorExpand.ChangeDefine(new string[] { SchemeName }, new string[] { }); } }