protected override void OnBeginDrawEditors()
        {
            base.OnBeginDrawEditors();
            if (OdinMenuTree == null)
            {
                return;
            }
            var select        = MenuTree.Selection.FirstOrDefault();
            var toolBarHeight = MenuTree.Config.SearchToolbarHeight;

            SirenixEditorGUI.BeginHorizontalToolbar(toolBarHeight);
            {
                if (select != null)
                {
                    GUILayout.Label(select.Name);
                }
                DrawLanguageSwitch();
            }
            SirenixEditorGUI.EndHorizontalToolbar();

            void DrawLanguageSwitch()
            {
                var languageType          = UnityEditorEntrance.GetCurrentLanguageType();
                var switchLanguageContent = $"Langeage:{languageType}";

                if (SirenixEditorGUI.ToolbarButton(
                        new GUIContent(switchLanguageContent)))
                {
                    MakeSwitchLanguageMenu();
                }
            }

            void MakeSwitchLanguageMenu()
            {
                var genericMenu   = new GenericMenu();
                var languageTypes =
                    CommonExtend.GetAllEnumValues <LanguageType>();

                foreach (var item in languageTypes)
                {
                    genericMenu.AddItem(new GUIContent(
                                            item.ToString()), false, SwitchLanguage, item.ToString());
                }
                genericMenu.ShowAsContext();
            }

            void SwitchLanguage(object data)
            {
                var languageType = ((string)data).AsEnum <LanguageType>();

                MultiLanguageString.SetLanguageType(languageType);
                UnityEditorEntrance.UpdateLanguageType(languageType);
                ForceMenuTreeRebuild();
                OpenLastMenu();

                var switchTip = MultiLanguageString.Create($"Yojoy已切换" +
                                                           $"为{languageType}!", $"Yojoy has been switched to " +
                                                           $"{languageType}!");

                Debug.Log(switchTip.Text);
            }
        }
Exemplo n.º 2
0
        private void ApplyModification()
        {
            var buildTargetInstructionMap = new Dictionary <BuildTargetGroup, string>();

            ParsePrecompileNodes();
            CleanAllPrecompileSettings();
            UpdatePrecompileSettings();

            void ParsePrecompileNodes()
            {
                foreach (var configNode in precompileConfigNodes)
                {
                    if (configNode.BuildPlatformType.ToString() == "0")
                    {
                        continue;
                    }

                    var platformTypeStrings = configNode.BuildPlatformType
                                              .ToString().Split(',');

                    foreach (var platformTypeString in platformTypeStrings)
                    {
                        var buildTargetGroup = platformTypeString
                                               .AsEnum <BuildTargetGroup>();
                        if (!buildTargetInstructionMap.ContainsKey(buildTargetGroup))
                        {
                            buildTargetInstructionMap.Add(buildTargetGroup,
                                                          configNode.Instruction);
                        }
                        else
                        {
                            var existInstruction = buildTargetInstructionMap
                                                   [buildTargetGroup];
                            var newInstruction = existInstruction
                                                 + ";" + configNode.Instruction;
                            buildTargetInstructionMap[buildTargetGroup] = newInstruction;
                        }
                    }
                }
            }

            void CleanAllPrecompileSettings()
            {
                var platformTypes = CommonExtend.GetAllEnumValues <
                    BuildPlatformType>();

                foreach (var platformType in platformTypes)
                {
                    var buildTargetGroup = platformType.ToString()
                                           .AsEnum <BuildTargetGroup>();
                }
            }

            void UpdatePrecompileSettings()
            {
                foreach (var pair in buildTargetInstructionMap)
                {
                    PlayerSettings.SetScriptingDefineSymbolsForGroup(
                        pair.Key, pair.Value);
                }
            }
        }