Просмотр исходного кода

Editor: Fix `ListboxItem` text content. (#33648)

Michael Herzog 1 месяц назад
Родитель
Сommit
14e6e6c145
2 измененных файлов с 31 добавлено и 3 удалено
  1. 22 1
      editor/js/Sidebar.Project.Resources.js
  2. 9 2
      editor/js/libs/ui.js

+ 22 - 1
editor/js/Sidebar.Project.Resources.js

@@ -128,6 +128,7 @@ function SidebarProjectResources( editor ) {
 	function refreshTexturesUI() {
 
 		const textures = [];
+		const types = [];
 		const texturesUsed = new Set();
 
 		const materials = Object.values( editor.materials );
@@ -143,6 +144,7 @@ function SidebarProjectResources( editor ) {
 					if ( texturesUsed.has( value.uuid ) === false ) {
 
 						textures.push( value );
+						types.push( getTextureType( value ) );
 						texturesUsed.add( value.uuid );
 
 					}
@@ -153,11 +155,30 @@ function SidebarProjectResources( editor ) {
 
 		}
 
-		texturesListbox.setItems( textures );
+		texturesListbox.setItems( textures, types );
 		texturesInfo.setValue( textures.length + ' ' + strings.getKey( 'sidebar/project/textures' ).toLowerCase() );
 
 	}
 
+	function getTextureType( texture ) {
+
+		if ( texture.isCanvasTexture ) return 'CanvasTexture';
+		if ( texture.isVideoTexture ) return 'VideoTexture';
+		if ( texture.isCubeDepthTexture ) return 'CubeDepthTexture';
+		if ( texture.isDepthTexture ) return 'DepthTexture';
+		if ( texture.isCompressedArrayTexture ) return 'CompressedArrayTexture';
+		if ( texture.isCompressedCubeTexture ) return 'CompressedCubeTexture';
+		if ( texture.isCompressedTexture ) return 'CompressedTexture';
+		if ( texture.isCubeTexture ) return 'CubeTexture';
+		if ( texture.isData3DTexture ) return 'Data3DTexture';
+		if ( texture.isDataArrayTexture ) return 'DataArrayTexture';
+		if ( texture.isDataTexture ) return 'DataTexture';
+		if ( texture.isFramebufferTexture ) return 'FramebufferTexture';
+
+		return 'Texture';
+
+	}
+
 	function refreshUI() {
 
 		refreshGeometriesUI();

+ 9 - 2
editor/js/libs/ui.js

@@ -1169,13 +1169,14 @@ class UIListbox extends UIDiv {
 		this.dom.tabIndex = 0;
 
 		this.items = [];
+		this.types = [];
 		this.listitems = [];
 		this.selectedIndex = 0;
 		this.selectedValue = null;
 
 	}
 
-	setItems( items ) {
+	setItems( items, types = [] ) {
 
 		if ( Array.isArray( items ) ) {
 
@@ -1183,6 +1184,12 @@ class UIListbox extends UIDiv {
 
 		}
 
+		if ( Array.isArray( types ) ) {
+
+			this.types = types;
+
+		}
+
 		this.render();
 
 	}
@@ -1205,7 +1212,7 @@ class UIListbox extends UIDiv {
 
 			const listitem = new ListboxItem( this );
 			listitem.setId( item.id || `Listbox-${i}` );
-			listitem.setTextContent( item.name || item.type );
+			listitem.setTextContent( item.name || this.types[ i ] || item.type );
 			this.add( listitem );
 
 		}

粤ICP备19079148号