using UnityEngine;
using System.Collections;
using UnityEditor;
using System.Collections.Generic;
public class SettingsWindow : EditorWindow
{
#region Settings 宏设置
[MenuItem("工具/宏设置(Settings)")]
public static void Settings()
{
SettingsWindow win = (SettingsWindow)EditorWindow.GetWindow(typeof(SettingsWindow));
win.titleContent = new GUIContent("宏设置");
win.Show();
}
#endregion
private List<MacorItem> m_List = new List<MacorItem>();
private Dictionary<string, bool> m_Dic = new Dictionary<string, bool>();
private string m_Macor = null;
void OnEnable()
{
m_Macor = PlayerSettings.GetScriptingDefineSymbolsForGroup(BuildTargetGroup.Android);
m_List.Clear();
m_List.Add(new MacorItem() { Name = "DEBUG_LOG_ERROR", DisplayName = "打印错误日志", IsDebug = true, IsRelease = false });
m_List.Add(new MacorItem() { Name = "DEBUG_LOG_NORMAL", DisplayName = "打印普通日志", IsDebug = true, IsRelease = false });
m_List.Add(new MacorItem() { Name = "DEBUG_LOG_PROCEDURE", DisplayName = "打印流程日志", IsDebug = true, IsRelease = false });
m_List.Add(new MacorItem() { Name = "DEBUG_LOG_RESOURCE", DisplayName = "打印资源日志", IsDebug = true, IsRelease = false });
m_List.Add(new MacorItem() { Name = "DEBUG_LOG_PROTO", DisplayName = "打印通讯日志", IsDebug = true, IsRelease = false });
m_List.Add(new MacorItem() { Name = "DISABLE_ASSETBUNDLE", DisplayName = "禁用AssetBundle", IsDebug = false, IsRelease = false });
m_List.Add(new MacorItem() { Name = "HOTFIX_ENABLE", DisplayName = "开启热补丁", IsDebug = false, IsRelease = true });
m_List.Add(new MacorItem() { Name = "SDKCHANNEL_APPLE_STORE", DisplayName = "渠道_苹果商店", IsDebug = false, IsRelease = false });
for (int i = 0; i < m_List.Count; i++)
{
if (!string.IsNullOrEmpty(m_Macor) && m_Macor.IndexOf(m_List[i].Name) != -1)
{
m_Dic[m_List[i].Name] = true;
}
else
{
m_Dic[m_List[i].Name] = false;
}
}
}
void OnGUI()
{
for (int i = 0; i < m_List.Count; i++)
{
EditorGUILayout.BeginHorizontal("box");
m_Dic[m_List[i].Name] = GUILayout.Toggle(m_Dic[m_List[i].Name], m_List[i].DisplayName);
EditorGUILayout.EndHorizontal();
}
//开启一行
EditorGUILayout.BeginHorizontal();
if (GUILayout.Button("保存", GUILayout.Width(100)))
{
SaveMacor();
}
if (GUILayout.Button("调试模式", GUILayout.Width(100)))
{
for (int i = 0; i < m_List.Count; i++)
{
m_Dic[m_List[i].Name] = m_List[i].IsDebug;
}
SaveMacor();
}
if (GUILayout.Button("发布模式", GUILayout.Width(100)))
{
for (int i = 0; i < m_List.Count; i++)
{
m_Dic[m_List[i].Name] = m_List[i].IsRelease;
}
SaveMacor();
}
EditorGUILayout.EndHorizontal();
}
private void SaveMacor()
{
m_Macor = string.Empty;
foreach (var item in m_Dic)
{
if (item.Value)
{
m_Macor += string.Format("{0};", item.Key);
}
if (item.Key.Equals("DISABLE_ASSETBUNDLE", System.StringComparison.CurrentCultureIgnoreCase))
{
EditorBuildSettingsScene[] arrScene = EditorBuildSettings.scenes;
for (int i = 0; i < arrScene.Length; i++)
{
if (arrScene[i].path.IndexOf("download", System.StringComparison.CurrentCultureIgnoreCase) > -1)
{
arrScene[i].enabled = item.Value;
}
}
EditorBuildSettings.scenes = arrScene;
}
}
PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.Android, m_Macor);
PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.iOS, m_Macor);
PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.Standalone, m_Macor);
}
/// <summary>
/// 宏项目
/// </summary>
public class MacorItem
{
/// <summary>
/// 名称
/// </summary>
public string Name;
/// <summary>
/// 显示的名称
/// </summary>
public string DisplayName;
/// <summary>
/// 是否调试项
/// </summary>
public bool IsDebug;
/// <summary>
/// 是否发布项
/// </summary>
public bool IsRelease;
}
}
Im grateful for the article. Much thanks again. Great. Sibel Darill Ebenezer
I am no longer certain where you are getting your information, however good topic. Godiva Lowell Stead
Very handful of websites that come about to be comprehensive beneath, from our point of view are undoubtedly properly worth checking out. Myrtice Emmery Rakia
Wohh exactly what I porn was searchI pornng for, apprecI pornate I pornt for postI pornng. Jobyna Cullin Sacttler
There is definately a great deal to know about this subject. I like all of the points you have made. Judi Moises Witt
I am not rattling superb with English but I line up this rattling easygoing to translate. Cecile Zack Glasgo
Regards for this wonderful post, I am glad I noticed this web site on yahoo. Emalee Fidel Gerti
I visit daily a few sites and websites to read articles, however this webpage offers quality based posts. Coraline Morten Bonnette
I enjoy the efforts you have put in this, thanks for all the great articles. Dee Dee Rand Trent
Useful info. Lucky me I found your website unintentionally, and I am shocked why this coincidence did not happened earlier! I bookmarked it. Tobe Ramon Clemens
Im obliged for the blog article. Really looking forward to read more. Want more. Berni Bord Werner
PSN code. Obviously, if you get accurately PS4 and Xbox vs. Noel Jozef Kaltman
Looking forward to reading more. Great blog post. Much thanks again. Really Great. Abbye Frannie Corydon
Hello. This post was really fascinating, particularly because I was looking for thoughts on this issue last Tuesday. Johnna Sebastien Sherri
There are some points in this article that I would never have thought of on my own. Thank you for your clear information. Electra Lyell Arette
Coaching is an amazing profession and you are great at it Thank you Sherri. Marcella Lionel Avitzur