/// <summary>
        /// Displays a slider enabling the user to change the preview index.
        /// </summary>
        private void SectionPreviewIndexPanel()
        {
            // Start the index panel area.
            float startX = _indentValue;
            float startY = position.height - _previewIndexPanelHeight;
            float width  = position.width - 2 * _indentValue;
            float height = _previewIndexPanelHeight;

            _previewIndexPanel = new Rect(startX, startY, width, height);
            GUILayout.BeginArea(_previewIndexPanel);
            // Check which source camera is currently being used for preview, i.e. determine the preview index.
            int previewIndex = -1;
            int channel      = 0;

            while (channel < _registeredCallers.Count)
            {
                IPreviewCaller caller = _registeredCallers[channel];
                if (caller != null)
                {
                    previewIndex = caller.previewIndex;
                    break;
                }
                channel++;
            }
            // If the caller objects indicate that they use a preview index, display a slider to enable the user to modify it.
            if (previewIndex > -1)
            {
                // Display a slider to enable the user to change the preview index.
                string label           = "Preview camera index: ";
                string tooltip         = "Index of the source camera to be used for preview.";
                int    newPreviewIndex = EditorGUILayout.IntSlider(new GUIContent(label, tooltip), previewIndex, 0, _previewMaxIndex);
                // If the preview index was changed, notify the caller objects.
                if (newPreviewIndex != previewIndex)
                {
                    foreach (IPreviewCaller caller in _registeredCallers)
                    {
                        if (caller != null)
                        {
                            // Set the caller object with a new preview index.
                            caller.previewIndex = newPreviewIndex;
                            // Notify objects that the preview index has changed.
                            if (caller.onPreviewIndexChangeEvent != null)
                            {
                                caller.onPreviewIndexChangeEvent.Invoke();
                            }
                            // Mark the current scene as dirty.
                            if (!Application.isPlaying)
                            {
                                EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
                            }
                        }
                    }
                }
            }
            // End the index panel area.
            GUILayout.EndArea();
        }
        /// <summary>
        /// Adds a caller to the lists.
        /// </summary>
        /// <param name="caller"></param> The caller to be added.
        /// <param name="imageName"></param> The corresponding name, to be used later on as an identifier.
        private void WindowAddCaller(IPreviewCaller caller, string imageName)
        {
            // Initialize the lists if needed.
            WindowInitIfNeeded();
            // If the caller is already in the lists, do not register it again.
            int listIndex = _registeredCallerNames.IndexOf(imageName);

            if (listIndex > -1 && (caller == _registeredCallers[listIndex]))
            {
                return;
            }
            // Register a new caller in the lists.
            _registeredCallers.Add(caller);
            _registeredCallerNames.Add(imageName);
            _registeredTextures.Add(null);
            // Repaint the window.
            Repaint();
        }
 /// <summary>
 /// Adds a preview caller to the list, enabling this caller object to provide an image for preview.
 /// </summary>
 /// <param name="caller"></param> The caller object wishing to display an image for preview.
 /// <param name="imageName"></param> The name of the image that the caller wishes to register.
 public static void AddCaller(IPreviewCaller caller, string imageName)
 {
     _instance.WindowAddCaller(caller, imageName);
 }