private void UpdateTemplateDescriptionUI(SceneTemplateInfo newSceneTemplateInfo) { // Text info var sceneTemplateTitleLabel = rootVisualElement.Q <Label>(k_SceneTemplateTitleLabelName); if (sceneTemplateTitleLabel != null && newSceneTemplateInfo != null) { sceneTemplateTitleLabel.text = newSceneTemplateInfo.name; } var sceneTemplatePathLabel = rootVisualElement.Q <Label>(k_SceneTemplatePathName); var sceneTemplatePathSection = rootVisualElement.Q(k_SceneTemplatePathSection); if (sceneTemplatePathLabel != null && newSceneTemplateInfo != null && sceneTemplatePathSection != null) { sceneTemplatePathLabel.text = newSceneTemplateInfo.assetPath; sceneTemplatePathSection.visible = !string.IsNullOrEmpty(newSceneTemplateInfo.assetPath); } var sceneTemplateDescriptionLabel = rootVisualElement.Q <Label>(k_SceneTemplateDescriptionName); var sceneTemplateDescriptionSection = rootVisualElement.Q(k_SceneTemplateDescriptionSection); if (sceneTemplateDescriptionLabel != null && newSceneTemplateInfo != null && sceneTemplateDescriptionSection != null) { sceneTemplateDescriptionLabel.text = newSceneTemplateInfo.description; sceneTemplateDescriptionSection.visible = !string.IsNullOrEmpty(newSceneTemplateInfo.description); } // Thumbnail m_PreviewArea?.UpdatePreview(newSceneTemplateInfo?.thumbnail, newSceneTemplateInfo?.badge); m_PreviewArea?.UpdatePreviewAreaSize(); }
private void CreateTemplateDescriptionUI(VisualElement rootContainer) { rootContainer.style.flexDirection = FlexDirection.Column; // Thumbnail container m_PreviewArea = new SceneTemplatePreviewArea(k_SceneTemplateThumbnailName, m_LastSelectedTemplate?.thumbnail, m_LastSelectedTemplate?.badge, L10n.Tr("No preview thumbnail available")); var thumbnailElement = m_PreviewArea.Element; rootContainer.Add(thumbnailElement); rootContainer.RegisterCallback <GeometryChangedEvent>(evt => m_PreviewArea?.UpdatePreviewAreaSize()); // Text container var sceneTitleLabel = new Label(); sceneTitleLabel.name = k_SceneTemplateTitleLabelName; sceneTitleLabel.AddToClassList(Styles.classWrappingText); rootContainer.Add(sceneTitleLabel); var assetPathSection = new VisualElement(); assetPathSection.name = k_SceneTemplatePathSection; { var scenePathLabel = new Label(); scenePathLabel.name = k_SceneTemplatePathName; scenePathLabel.AddToClassList(Styles.classWrappingText); assetPathSection.Add(scenePathLabel); var editLocateRow = new VisualElement(); editLocateRow.style.flexDirection = FlexDirection.Row; { var scenePathLocate = new Label(); scenePathLocate.text = L10n.Tr("Locate"); scenePathLocate.AddToClassList(Styles.classTextLink); scenePathLocate.RegisterCallback <MouseDownEvent>(e => { if (string.IsNullOrEmpty(scenePathLabel.text)) { return; } var asset = AssetDatabase.LoadAssetAtPath <SceneTemplateAsset>(scenePathLabel.text); if (!asset) { return; } EditorApplication.delayCall += () => { EditorWindow.FocusWindowIfItsOpen(typeof(ProjectBrowser)); EditorApplication.delayCall += () => EditorGUIUtility.PingObject(asset); }; }); editLocateRow.Add(scenePathLocate); editLocateRow.Add(new Label() { text = " | " }); var scenePathEdit = new Label(); scenePathEdit.name = k_SceneTemplateEditTemplateButtonName; scenePathEdit.text = L10n.Tr("Edit"); scenePathEdit.AddToClassList(Styles.classTextLink); scenePathEdit.RegisterCallback <MouseDownEvent>(e => { OnEditTemplate(m_LastSelectedTemplate); }); editLocateRow.Add(scenePathEdit); } assetPathSection.Add(editLocateRow); } rootContainer.Add(assetPathSection); var descriptionSection = new VisualElement(); descriptionSection.name = k_SceneTemplateDescriptionSection; { var descriptionLabel = new Label(); descriptionLabel.AddToClassList(Styles.classHeaderLabel); descriptionLabel.text = L10n.Tr("Description"); descriptionSection.Add(descriptionLabel); var sceneDescriptionLabel = new Label(); sceneDescriptionLabel.AddToClassList(Styles.classWrappingText); sceneDescriptionLabel.name = k_SceneTemplateDescriptionName; descriptionSection.Add(sceneDescriptionLabel); } rootContainer.Add(descriptionSection); }