void SetContent(SerializableContent content, ContentWindowParameters options) { m_Content = content; m_Content.InspectionContext.ApplyInspectorStyling = options.ApplyInspectorStyling; m_Options = options; if (options.AddScrollView) { m_Content.Root = m_ScrollView; rootVisualElement.contentContainer.Add(m_ScrollView); } else { m_Content.Root = rootVisualElement; } if (options.ApplyInspectorStyling) { m_Content.Root.contentContainer.style.paddingLeft = 15; } m_Content.Initialize(); m_Content.Load(); m_Content.Update(); titleContent.text = m_Content.Name ?? nameof(ContentWindow); minSize = m_Options.MinSize; }
// Invoked by the Unity update loop void Update() { m_ScrollPosition = m_ScrollView.scrollOffset; titleContent.text = !string.IsNullOrEmpty(m_Content.Name) ? m_Content.Name : TypeUtility.GetTypeDisplayName(m_Content.GetType()); m_Content.Update(); if (!m_Content.IsValid) { Close(); } // We are saving here because we want to store the data inside the editor window so that it survives both // domain reloads and closing/re-opening Unity. m_Content.Save(); }