Exemple #1
0
        private void OnEnable()
        {
            activeSettings = ActiveLocalizationSettings.Load();

            activeSettingsEditor = Editor.CreateEditor(activeSettings) as ActiveLocalizationSettingsEditor;
            activeSettingsEditor !.OnActiveSettingsChanged += ActiveSettingsChanged;
            Undo.undoRedoPerformed += UndoRedoPerformed;
            UpdateFilter();
            UpdateTableFilter();
        }
        public override VisualElement CreateInspectorGUI()
        {
            currentSettings = target as ActiveLocalizationSettings;

            rootElement = new VisualElement {
                name = "ActiveSettings"
            };
            activeSettingsField = new ObjectField("Active Settings")
            {
                objectType = typeof(LocalizationSettings)
            };
            activeSettingsField.BindProperty(new SerializedObject(currentSettings).FindProperty("activeSettings"));
            activeSettingsField.RegisterValueChangedCallback(evt => {
                if (evt.previousValue == null && evt.newValue != null)
                {
                    createAssetContainer.AddToClassList("hidden");
                }
                else if (evt.previousValue != null && evt.newValue == null)
                {
                    createAssetContainer.RemoveFromClassList("hidden");
                }
                OnActiveSettingsChanged?.Invoke(evt.newValue as LocalizationSettings);
                if (evt.newValue == null)
                {
                    EditorPrefs.DeleteKey(Constants.ACTIVE_SETTINGS_PREFS_KEY);
                }
                else
                {
                    var assetPath = AssetDatabase.GetAssetPath(evt.newValue);
                    EditorPrefs.SetString(Constants.ACTIVE_SETTINGS_PREFS_KEY, assetPath);
                }
            });
            createAssetContainer = new VisualElement();
            createAssetContainer.Add(new HelpBox("There is no active Localization Settings selected. Would you like to create one?", HelpBoxMessageType.Info));
            var createAssetButton = new Button(TriggerCreateAsset)
            {
                text = "Create"
            };

            createAssetContainer.Add(createAssetButton);
            if (currentSettings.ActiveSettings != null)
            {
                createAssetContainer.AddToClassList("hidden");
            }
            activeSettingsField.value = currentSettings.ActiveSettings;

            rootElement.Add(activeSettingsField);
            rootElement.Add(createAssetContainer);
            return(rootElement);
        }
        private void OnEnable()
        {
            AcquireProperties();
            localizedString            = target as LocalizedString;
            localizedString !.Settings = ActiveLocalizationSettings.Load().ActiveSettings;

            // Update Setter mode to Editor & Runtime
            var count = localizedString == null ? 0 : localizedString.Setter.GetPersistentEventCount();

            for (var i = 0; i < count; i++)
            {
                localizedString.Setter.SetPersistentListenerState(i, UnityEventCallState.EditorAndRuntime);
            }

            if (rootElement != null)
            {
                UpdateWarningVisibility();
            }
        }