public static void InitElements() { Type toolbarType = typeof(Editor).Assembly.GetType("UnityEditor.Toolbar"); #if UNITY_2019_1_OR_NEWER string fieldName = "k_ToolCount"; #else string fieldName = "s_ShownToolIcons"; #endif FieldInfo toolIcons = toolbarType.GetField(fieldName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); #if UNITY_2019_3_OR_NEWER m_toolCount = toolIcons != null ? ((int)toolIcons.GetValue(null)) : 8; #elif UNITY_2019_1_OR_NEWER m_toolCount = toolIcons != null ? ((int)toolIcons.GetValue(null)) : 7; #elif UNITY_2018_1_OR_NEWER m_toolCount = toolIcons != null ? ((Array)toolIcons.GetValue(null)).Length : 6; #else m_toolCount = toolIcons != null ? ((Array)toolIcons.GetValue(null)).Length : 5; #endif ToolbarCallback.OnToolbarGUI -= OnGUI; ToolbarCallback.OnToolbarGUI += OnGUI; setting = CustomToolbarSetting.GetOrCreateSetting(); foreach (var element in setting.elements) { element.Init(); } }
public static bool IsSettingAvailable() { CustomToolbarSetting.GetOrCreateSetting(); return(File.Exists(SETTING_PATH));; }