OnPreviewSettings() public method

Override this method if you want to show custom controls in the preview header.

public OnPreviewSettings ( ) : void
return void
        public override void OnPreviewSettings()
        {
            Editor selectedMaterialInspector = this.GetSelectedMaterialInspector();

            if (selectedMaterialInspector != null)
            {
                selectedMaterialInspector.OnPreviewSettings();
            }
        }
        public override void OnPreviewSettings()
        {
            Editor materialInspector = this.GetSelectedMaterialInspector();

            if (!(bool)((UnityEngine.Object)materialInspector))
            {
                return;
            }
            materialInspector.OnPreviewSettings();
        }
Exemplo n.º 3
0
        public override void OnGUI(Rect rect)
        {
            if (m_Editor == null)
            {
                editorWindow.Close();
                return;
            }

            if (s_Styles == null)
            {
                s_Styles = new Styles();
            }

            // Toolbar
            Rect toolbarRect = EditorGUILayout.BeginHorizontal(GUIContent.none, s_Styles.toolbar, GUILayout.Height(kToolbarHeight));

            {
                GUILayout.FlexibleSpace();
                Rect contentRect = EditorGUILayout.BeginHorizontal();
                m_Editor.OnPreviewSettings();
                EditorGUILayout.EndHorizontal();

                const float kPadding  = 5f;
                Rect        labelRect = new Rect(toolbarRect.x + kPadding, toolbarRect.y, toolbarRect.width - contentRect.width - 2 * kPadding, toolbarRect.height);
                Vector2     labelSize = s_Styles.toolbarText.CalcSize(m_ObjectName);
                labelRect.width      = Mathf.Min(labelRect.width, labelSize.x);
                m_ObjectName.tooltip = m_ObjectName.text;
                GUI.Label(labelRect, m_ObjectName, s_Styles.toolbarText);
            }
            EditorGUILayout.EndHorizontal();

            // Object preview
            Rect previewRect = new Rect(rect.x, rect.y + kToolbarHeight, rect.width, rect.height - kToolbarHeight);

            m_Editor.OnPreviewGUI(previewRect, s_Styles.background);
        }
Exemplo n.º 4
0
 public void OnPreviewSettings()
 {
     editor.OnPreviewSettings();
 }
Exemplo n.º 5
0
        private void DrawPreviewGUI()
        {
            GUILayout.FlexibleSpace();

            if (_wavClipEditor == null)
            {
                _wavClipEditor = UnityEditor.Editor.CreateEditor(_wavClip);
            }

            if (_clipEditorBg == null)
            {
                _clipEditorBg = new GUIStyle();
                _clipEditorBg.normal.background = Texture2D.blackTexture;
            }

            int currentSample = GetSamplePosition();

            if (currentSample > 0)
            {
                // Playback position gets reset to zero after pausing. Save the last one to make
                // finding the desired loops easier.
                _lastPreviewSample = currentSample;
            }

            using (new EditorGUILayout.HorizontalScope())
            {
                GUILayout.Label("Preview");
                using (new EditorGUI.DisabledScope(_zoomLevel / 1.5f < 1.0f))
                {
                    if (GUILayout.Button("-"))
                    {
                        _zoomLevel /= 1.5f;
                    }
                }

                using (new EditorGUI.DisabledScope(_zoomLevel * 1.5f > 20.0f))
                {
                    if (GUILayout.Button("+"))
                    {
                        _zoomLevel *= 1.5f;
                    }
                }

                GUILayout.FlexibleSpace();
                _wavClipEditor.OnPreviewSettings();
            }

            using (var scrollView = new EditorGUILayout.ScrollViewScope(_previewScrollPos))
            {
                _previewScrollPos = scrollView.scrollPosition;
                _wavClipEditor.OnPreviewGUI(
                    GUILayoutUtility.GetRect(position.width * _zoomLevel, 100, GUILayout.ExpandWidth(false)),
                    _clipEditorBg);
            }

            using (new EditorGUILayout.HorizontalScope())
            {
                GUILayout.Label("Set Loop Point to Current Preview Position: ", GUILayout.ExpandWidth(false));
                GUILayout.Label(_useSeconds
                    ? SecondsToDurationString(SamplesToSeconds(_lastPreviewSample))
                    : _lastPreviewSample.ToString(),
                                GUILayout.Width(80));

                if (GUILayout.Button("Start", GUILayout.Width(80)))
                {
                    _wavData.GetOrAddFirstLoop().StartSample = _lastPreviewSample;
                }

                if (GUILayout.Button("End", GUILayout.Width(80)))
                {
                    _wavData.GetOrAddFirstLoop().EndSample = _lastPreviewSample;
                }
            }

            // Enable looping by default
            _wavClipEditor.GetType()
            .GetField("s_Loop", BindingFlags.Static | BindingFlags.NonPublic)?
            .SetValue(null, true);
        }