private void AddCallbackToReordableList(ReorderableList reorderableList)
        {
            reorderableList.drawHeaderCallback = (rect) =>
            {
                EditorGUI.LabelField(rect, $"{Strings.Dictionary} ({reorderableList.count})");
            };

            reorderableList.elementHeightCallback = (index) =>
            {
                if (IndiceIsInShowingRange(index))
                {
                    return(EditorGUI.GetPropertyHeight(reorderableList.serializedProperty.GetArrayElementAtIndex(index)));
                }
                return(0);
            };

            reorderableList.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) =>
            {
                if (IndiceIsInShowingRange(index))
                {
                    currentKey = reorderableList.serializedProperty.GetArrayElementAtIndex(index);
                    error      = CodeGenerationUtils.CheckIdentifier(currentKey.stringValue);
                    EditorGUI.PropertyField(rect, currentKey, GUIContent.none);
                    var show = !string.IsNullOrEmpty(error) && error != CodeGenerationUtils.EMPTY_FIELD_NAME_ERROR;
                    EditorUtils.ShowMessage(string.Format(Strings.InvalidKeyName, currentKey.stringValue), MessageType.Error, show);
                }
            };
        }
Exemple #2
0
        /// <summary>
        /// Called when the component is drawed
        /// </summary>
        public override void OnInspectorGUI()
        {
            serializedObject.Update();
            showHelp = EditorUtils.DrawHeader(showHelp, @"https://infinity-engine-f6f33.firebaseapp.com/index.html#ISI-Localization");
            EditorUtils.ShowMessage(ISILocalizationEditor.Strings.Help, MessageType.Info, showHelp);

            EditorGUILayout.PropertyField(nextScene);
            EditorGUILayout.PropertyField(loadSceneDelay);

            GUILayout.Space(10);
            var rect = EditorUtils.GetCenteredRect(120, 40);

            if (GUI.Button(rect, AssetReferences.EditIcon, GUI.skin.label))
            {
                ISILocalizationEditor.OpenWindow();
            }
            if (GUI.changed)
            {
                EditorUtility.SetDirty(target);
            }
            serializedObject.ApplyModifiedProperties();
        }