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

Added a way to initialize a texture with a pre-existing PixelData
Added size specific icons to entries in Library window

BearishSun 10 лет назад
Родитель
Сommit
970146ef27

+ 21 - 1
BansheeCore/Include/BsTexture.h

@@ -165,9 +165,15 @@ namespace BansheeEngine
 	{
 	public:
 		TextureCore(TextureType textureType, UINT32 width, UINT32 height, UINT32 depth, UINT32 numMipmaps,
-			PixelFormat format, int usage, bool hwGamma, UINT32 multisampleCount);
+			PixelFormat format, int usage, bool hwGamma, UINT32 multisampleCount, const PixelDataPtr& initData);
 		virtual ~TextureCore() {}
 
+
+		/**
+		 * @copydoc	CoreObjectCore::initialize
+		 */
+		virtual void initialize() override;
+
 		/**
 		 * @brief	Updates a part of the texture with the provided data.
 		 *
@@ -321,6 +327,7 @@ namespace BansheeEngine
 
 		UnorderedMap<TEXTURE_VIEW_DESC, TextureViewReference*, TextureView::HashFunction, TextureView::EqualFunction> mTextureViews;
 		TextureProperties mProperties;
+		PixelDataPtr mInitData;
 	};
 
 	/**
@@ -432,6 +439,16 @@ namespace BansheeEngine
 			PixelFormat format, int usage = TU_DEFAULT,
 			bool hwGammaCorrection = false, UINT32 multisampleCount = 0);
 
+		/**
+		 * @brief	Creates a new 2D or 3D texture initialized using the provided pixel data. Texture will not have any mipmaps.
+		 *
+		 * @param	pixelData			Data to initialize the texture width.
+		 * @param	usage				Describes planned texture use.
+		 * @param	hwGammaCorrection	If true the texture data is assumed to have been gamma corrected and will be
+		 *								converted back to linear space when sampled on GPU.
+		 */
+		static HTexture create(const PixelDataPtr& pixelData, int usage = TU_DEFAULT, bool hwGammaCorrection = false);
+
 		/**
 		 * @copydoc	create(TextureType, UINT32, UINT32, UINT32, int, PixelFormat, int, bool, UINT32)
 		 *
@@ -455,6 +472,8 @@ namespace BansheeEngine
 		Texture(TextureType textureType, UINT32 width, UINT32 height, UINT32 depth, UINT32 numMipmaps,
 			PixelFormat format, int usage, bool hwGamma, UINT32 multisampleCount);
 
+		Texture(const PixelDataPtr& pixelData, int usage, bool hwGamma);
+
 		/**
 		 * @copydoc	Resource::initialize
 		 */
@@ -485,6 +504,7 @@ namespace BansheeEngine
 	protected:
 		Vector<PixelDataPtr> mCPUSubresourceData;
 		TextureProperties mProperties;
+		mutable PixelDataPtr mInitData;
 
 		/************************************************************************/
 		/* 								SERIALIZATION                      		*/

+ 6 - 1
BansheeCore/Include/BsTextureManager.h

@@ -37,6 +37,11 @@ namespace BansheeEngine
 				numMips, format, usage, hwGammaCorrection, multisampleCount);
 		}
 
+		/**
+		 * @copydoc	Texture::create(const PixelDataPtr&, int, bool)
+		 */
+		TexturePtr createTexture(const PixelDataPtr& pixelData, int usage = TU_DEFAULT, bool hwGammaCorrection = false);
+
 		/**
 		 * @brief	Creates a completely empty and uninitialized Texture.
 		 *
@@ -137,7 +142,7 @@ namespace BansheeEngine
 		 */
 		virtual SPtr<TextureCore> createTextureInternal(TextureType texType, UINT32 width, UINT32 height, UINT32 depth,
 			int numMips, PixelFormat format, int usage = TU_DEFAULT, bool hwGammaCorrection = false,
-			UINT32 multisampleCount = 0) = 0;
+			UINT32 multisampleCount = 0, const PixelDataPtr& initialData = nullptr) = 0;
 
 		/**
 		 * @copydoc	TextureManager::createRenderTextureImpl

+ 0 - 1
BansheeCore/Include/BsTextureRTTI.h

@@ -139,7 +139,6 @@ namespace BansheeEngine
 				{
 					PixelDataPtr origData = pixelData->at(i);
 					PixelDataPtr newData = PixelData::create(origData->getWidth(), origData->getHeight(), origData->getDepth(), validFormat);
-					newData->allocateInternalBuffer();
 
 					PixelUtil::bulkPixelConversion(*origData, *newData);
 					(*pixelData)[i] = newData;

+ 8 - 2
BansheeCore/Source/BsPixelData.cpp

@@ -176,12 +176,18 @@ namespace BansheeEngine
 
 	PixelDataPtr PixelData::create(const PixelVolume &extents, PixelFormat pixelFormat)
 	{
-		return bs_shared_ptr_new<PixelData>(extents, pixelFormat);
+		PixelDataPtr pixelData = bs_shared_ptr_new<PixelData>(extents, pixelFormat);
+		pixelData->allocateInternalBuffer();
+
+		return pixelData;
 	}
 
 	PixelDataPtr PixelData::create(UINT32 width, UINT32 height, UINT32 depth, PixelFormat pixelFormat)
 	{
-		return bs_shared_ptr_new<PixelData>(width, height, depth, pixelFormat);
+		PixelDataPtr pixelData = bs_shared_ptr_new<PixelData>(width, height, depth, pixelFormat);
+		pixelData->allocateInternalBuffer();
+
+		return pixelData;
 	}
 
 	UINT32 PixelData::getInternalBufferSize() const

+ 51 - 18
BansheeCore/Source/BsTexture.cpp

@@ -81,10 +81,21 @@ namespace BansheeEngine
 	}
 
 	TextureCore::TextureCore(TextureType textureType, UINT32 width, UINT32 height, UINT32 depth, UINT32 numMipmaps,
-		PixelFormat format, int usage, bool hwGamma, UINT32 multisampleCount)
-		:mProperties(textureType, width, height, depth, numMipmaps, format, usage, hwGamma, multisampleCount)
+		PixelFormat format, int usage, bool hwGamma, UINT32 multisampleCount, const PixelDataPtr& initData)
+		:mProperties(textureType, width, height, depth, numMipmaps, format, usage, hwGamma, multisampleCount), 
+		mInitData(initData)
 	{ }
 
+	void TextureCore::initialize()
+	{
+		if (mInitData != nullptr)
+		{
+			writeSubresource(0, *mInitData, true);
+			mInitData->_unlock();
+			mInitData = nullptr;
+		}
+	}
+
 	void TextureCore::writeSubresource(UINT32 subresourceIdx, const PixelData& pixelData, bool discardEntireBuffer)
 	{
 		THROW_IF_NOT_CORE_THREAD;
@@ -93,7 +104,7 @@ namespace BansheeEngine
 		{
 			if(mProperties.getUsage() != TU_DYNAMIC)
 			{
-				LOGWRN("Buffer discard is enabled but buffer was not created as dynamic. Disabling discard.");
+				// Buffer discard is enabled but buffer was not created as dynamic. Disabling discard.
 				discardEntireBuffer = false;
 			}
 		}
@@ -282,14 +293,27 @@ namespace BansheeEngine
         
     }
 
+	Texture::Texture(const PixelDataPtr& pixelData, int usage, bool hwGamma)
+		: mProperties(pixelData->getDepth() > 1 ? TEX_TYPE_3D : TEX_TYPE_2D, pixelData->getWidth(), pixelData->getHeight(),
+		pixelData->getDepth(), 0, pixelData->getFormat(), usage, hwGamma, 0), mInitData(pixelData)
+	{
+		if (mInitData != nullptr)
+			mInitData->_lock();
+	}
+
 	void Texture::initialize()
 	{
 		mSize = calculateSize();
 
 		// Allocate CPU buffers if needed
 		if ((mProperties.getUsage() & TU_CPUCACHED) != 0)
+		{
 			createCPUBuffers();
 
+			if (mInitData != nullptr)
+				updateCPUBuffers(0, *mInitData);
+		}
+
 		Resource::initialize();
 	}
 
@@ -297,8 +321,13 @@ namespace BansheeEngine
 	{
 		const TextureProperties& props = getProperties();
 
-		return TextureCoreManager::instance().createTextureInternal(props.getTextureType(), props.getWidth(), props.getHeight(),
-			props.getDepth(), props.getNumMipmaps(), props.getFormat(), props.getUsage(), props.isHardwareGammaEnabled(), props.getMultisampleCount());
+		SPtr<CoreObjectCore> coreObj = TextureCoreManager::instance().createTextureInternal(props.getTextureType(), props.getWidth(), props.getHeight(),
+			props.getDepth(), props.getNumMipmaps(), props.getFormat(), props.getUsage(), props.isHardwareGammaEnabled(), props.getMultisampleCount(), mInitData);
+
+		if ((mProperties.getUsage() & TU_CPUCACHED) == 0)
+			mInitData = nullptr;
+
+		return coreObj;
 	}
 
 	AsyncOp Texture::writeSubresource(CoreAccessor& accessor, UINT32 subresourceIdx, const PixelDataPtr& data, bool discardEntireBuffer)
@@ -469,19 +498,26 @@ namespace BansheeEngine
 	/* 								STATICS	                      			*/
 	/************************************************************************/
 	HTexture Texture::create(TextureType texType, UINT32 width, UINT32 height, UINT32 depth, 
-		int num_mips, PixelFormat format, int usage, bool hwGammaCorrection, UINT32 multisampleCount)
+		int numMips, PixelFormat format, int usage, bool hwGammaCorrection, UINT32 multisampleCount)
 	{
 		TexturePtr texturePtr = _createPtr(texType, 
-			width, height, depth, num_mips, format, usage, hwGammaCorrection, multisampleCount);
+			width, height, depth, numMips, format, usage, hwGammaCorrection, multisampleCount);
 
 		return static_resource_cast<Texture>(gResources()._createResourceHandle(texturePtr));
 	}
 	
 	HTexture Texture::create(TextureType texType, UINT32 width, UINT32 height, 
-		int num_mips, PixelFormat format, int usage, bool hwGammaCorrection, UINT32 multisampleCount)
+		int numMips, PixelFormat format, int usage, bool hwGammaCorrection, UINT32 multisampleCount)
 	{
 		TexturePtr texturePtr = _createPtr(texType, 
-			width, height, num_mips, format, usage, hwGammaCorrection, multisampleCount);
+			width, height, numMips, format, usage, hwGammaCorrection, multisampleCount);
+
+		return static_resource_cast<Texture>(gResources()._createResourceHandle(texturePtr));
+	}
+
+	HTexture Texture::create(const PixelDataPtr& pixelData, int usage, bool hwGammaCorrection)
+	{
+		TexturePtr texturePtr = TextureManager::instance().createTexture(pixelData, usage, hwGammaCorrection);
 
 		return static_resource_cast<Texture>(gResources()._createResourceHandle(texturePtr));
 	}
@@ -505,17 +541,14 @@ namespace BansheeEngine
 		static HTexture dummyTexture;
 		if (!dummyTexture)
 		{
-			dummyTexture = create(TEX_TYPE_2D, 2, 2, 0, PF_R8G8B8A8);
-
-			UINT32 subresourceIdx = dummyTexture->getProperties().mapToSubresourceIdx(0, 0);
-			PixelDataPtr data = dummyTexture->getProperties().allocateSubresourceBuffer(subresourceIdx);
+			PixelDataPtr pixelData = PixelData::create(2, 2, 1, PF_R8G8B8A8);
 
-			data->setColorAt(Color::Red, 0, 0);
-			data->setColorAt(Color::Red, 0, 1);
-			data->setColorAt(Color::Red, 1, 0);
-			data->setColorAt(Color::Red, 1, 1);
+			pixelData->setColorAt(Color::Red, 0, 0);
+			pixelData->setColorAt(Color::Red, 0, 1);
+			pixelData->setColorAt(Color::Red, 1, 0);
+			pixelData->setColorAt(Color::Red, 1, 1);
 
-			dummyTexture->writeSubresource(gCoreAccessor(), subresourceIdx, data, false);
+			dummyTexture = create(pixelData);
 		}
 
 		return dummyTexture;

+ 11 - 0
BansheeCore/Source/BsTextureManager.cpp

@@ -18,6 +18,17 @@ namespace BansheeEngine
 		return ret;
     }
 
+	TexturePtr TextureManager::createTexture(const PixelDataPtr& pixelData, int usage , bool hwGammaCorrection)
+    {
+		Texture* tex = new (bs_alloc<Texture>()) Texture(pixelData, usage, hwGammaCorrection);
+		TexturePtr ret = bs_core_ptr<Texture>(tex);
+
+		ret->_setThisPtr(ret);
+		ret->initialize();
+
+		return ret;
+    }
+
 	TexturePtr TextureManager::_createEmpty()
 	{
 		Texture* tex = new (bs_alloc<Texture>()) Texture();

+ 1 - 1
BansheeD3D11RenderAPI/Include/BsD3D11Texture.h

@@ -32,7 +32,7 @@ namespace BansheeEngine
 		friend class D3D11TextureCoreManager;
 
 		D3D11TextureCore(TextureType textureType, UINT32 width, UINT32 height, UINT32 depth, UINT32 numMipmaps,
-			PixelFormat format, int usage, bool hwGamma, UINT32 multisampleCount);
+			PixelFormat format, int usage, bool hwGamma, UINT32 multisampleCount, const PixelDataPtr& initialData);
 
 		/**
 		* @copydoc	CoreObjectCore::initialize()

+ 1 - 1
BansheeD3D11RenderAPI/Include/BsD3D11TextureManager.h

@@ -39,7 +39,7 @@ namespace BansheeEngine
 		 */
 		SPtr<TextureCore> createTextureInternal(TextureType texType, UINT32 width, UINT32 height, UINT32 depth,
 			int numMips, PixelFormat format, int usage = TU_DEFAULT, bool hwGammaCorrection = false,
-			UINT32 multisampleCount = 0) override;
+			UINT32 multisampleCount = 0, const PixelDataPtr& initialData = nullptr) override;
 
 		/**
 		 * @copydoc	TextureCoreManager::createRenderTextureInternal

+ 2 - 2
BansheeD3D11RenderAPI/Source/BsD3D11Texture.cpp

@@ -12,8 +12,8 @@
 namespace BansheeEngine
 {
 	D3D11TextureCore::D3D11TextureCore(TextureType textureType, UINT32 width, UINT32 height, UINT32 depth, UINT32 numMipmaps,
-		PixelFormat format, int usage, bool hwGamma, UINT32 multisampleCount)
-		: TextureCore(textureType, width, height, depth, numMipmaps, format, usage, hwGamma, multisampleCount),
+		PixelFormat format, int usage, bool hwGamma, UINT32 multisampleCount, const PixelDataPtr& initialData)
+		: TextureCore(textureType, width, height, depth, numMipmaps, format, usage, hwGamma, multisampleCount, initialData),
 		m1DTex(nullptr), m2DTex(nullptr), m3DTex(nullptr), 
 		mTex(nullptr), mShaderResourceView(nullptr), mStagingBuffer(nullptr), 
 		mLockedSubresourceIdx(-1), mLockedForReading(false), mStaticBuffer(nullptr)

+ 2 - 2
BansheeD3D11RenderAPI/Source/BsD3D11TextureManager.cpp

@@ -30,10 +30,10 @@ namespace BansheeEngine
 	}
 
 	SPtr<TextureCore> D3D11TextureCoreManager::createTextureInternal(TextureType texType, UINT32 width, UINT32 height, UINT32 depth,
-		int numMips, PixelFormat format, int usage, bool hwGammaCorrection, UINT32 multisampleCount)
+		int numMips, PixelFormat format, int usage, bool hwGammaCorrection, UINT32 multisampleCount, const PixelDataPtr& initialData)
 	{
 		D3D11TextureCore* tex = new (bs_alloc<D3D11TextureCore>()) D3D11TextureCore(texType, 
-			width, height, depth, numMips, format, usage, hwGammaCorrection, multisampleCount);
+			width, height, depth, numMips, format, usage, hwGammaCorrection, multisampleCount, initialData);
 
 		SPtr<D3D11TextureCore> texPtr = bs_shared_ptr<D3D11TextureCore>(tex);
 		texPtr->_setThisPtr(texPtr);

+ 12 - 12
BansheeD3D9RenderAPI/Include/BsD3D9Texture.h

@@ -34,7 +34,7 @@ namespace BansheeEngine
 		/**
 		 * @copydoc Texture::isBindableAsShaderResource
 		 */
-		bool isBindableAsShaderResource() const { return mIsBindableAsShaderResource; }
+		bool isBindableAsShaderResource() const override { return mIsBindableAsShaderResource; }
 
 		/**
 		 * @brief	Returns internal DirectX 9 texture object.
@@ -70,59 +70,59 @@ namespace BansheeEngine
 		/**
 		 * @copydoc	D3D9Resource::notifyOnDeviceCreate
 		 */
-		virtual void notifyOnDeviceCreate(IDirect3DDevice9* d3d9Device);
+		virtual void notifyOnDeviceCreate(IDirect3DDevice9* d3d9Device) override;
 
 		/**
 		 * @copydoc	D3D9Resource::notifyOnDeviceDestroy
 		 */
-		virtual void notifyOnDeviceDestroy(IDirect3DDevice9* d3d9Device);
+		virtual void notifyOnDeviceDestroy(IDirect3DDevice9* d3d9Device) override;
 
 		/**
 		 * @copydoc	D3D9Resource::notifyOnDeviceLost
 		 */
-		virtual void notifyOnDeviceLost(IDirect3DDevice9* d3d9Device);
+		virtual void notifyOnDeviceLost(IDirect3DDevice9* d3d9Device) override;
 
 		/**
 		 * @copydoc	D3D9Resource::notifyOnDeviceReset
 		 */
-		virtual void notifyOnDeviceReset(IDirect3DDevice9* d3d9Device);
+		virtual void notifyOnDeviceReset(IDirect3DDevice9* d3d9Device) override;
 
 	protected:	
 		friend class D3D9TextureCoreManager;
 		friend class D3D9PixelBuffer;
 
 		D3D9TextureCore(TextureType textureType, UINT32 width, UINT32 height, UINT32 depth, UINT32 numMipmaps,
-			PixelFormat format, int usage, bool hwGamma, UINT32 multisampleCount);
+			PixelFormat format, int usage, bool hwGamma, UINT32 multisampleCount, const PixelDataPtr& initialData);
 
 		/**
 		 * @copydoc TextureCore::initialize
 		 */
-		void initialize();
+		void initialize() override;
 		
 		/**
 		 * @copydoc TextureCore::lock
 		 */
-		PixelData lockImpl(GpuLockOptions options, UINT32 mipLevel = 0, UINT32 face = 0);
+		PixelData lockImpl(GpuLockOptions options, UINT32 mipLevel = 0, UINT32 face = 0) override;
 
 		/**
 		 * @copydoc TextureCore::unlock
 		 */
-		void unlockImpl();
+		void unlockImpl() override;
 
 		/**
 		 * @copydoc TextureCore::copy
 		 */
-		void copyImpl(UINT32 srcFace, UINT32 srcMipLevel, UINT32 destFace, UINT32 destMipLevel, const SPtr<TextureCore>& target);
+		void copyImpl(UINT32 srcFace, UINT32 srcMipLevel, UINT32 destFace, UINT32 destMipLevel, const SPtr<TextureCore>& target) override;
 
 		/**
 		 * @copydoc TextureCore::readData
 		 */
-		void readData(PixelData& dest, UINT32 mipLevel = 0, UINT32 face = 0);
+		void readData(PixelData& dest, UINT32 mipLevel = 0, UINT32 face = 0) override;
 
 		/**
 		 * @copydoc TextureCore::writeData
 		 */
-		void writeData(const PixelData& src, UINT32 mipLevel = 0, UINT32 face = 0, bool discardWholeBuffer = false);
+		void writeData(const PixelData& src, UINT32 mipLevel = 0, UINT32 face = 0, bool discardWholeBuffer = false) override;
 
 		/**
 		 * @brief	Returns true if the texture should be allocated in the default pool.

+ 1 - 1
BansheeD3D9RenderAPI/Include/BsD3D9TextureManager.h

@@ -43,7 +43,7 @@ namespace BansheeEngine
 		 */
 		SPtr<TextureCore> createTextureInternal(TextureType texType, UINT32 width, UINT32 height, UINT32 depth,
 			int numMips, PixelFormat format, int usage = TU_DEFAULT, bool hwGammaCorrection = false,
-			UINT32 multisampleCount = 0) override;
+			UINT32 multisampleCount = 0, const PixelDataPtr& initialData = nullptr) override;
 
 		/**
 		 * @copydoc	TextureCoreManager::createRenderTextureInternal

+ 6 - 3
BansheeD3D9RenderAPI/Source/BsD3D9Texture.cpp

@@ -10,15 +10,18 @@
 #include "BsD3D9DeviceManager.h"
 #include "BsD3D9ResourceManager.h"
 #include "BsRenderStats.h"
+#include "BsPixelData.h"
 
 namespace BansheeEngine 
 {
 	D3D9TextureCore::D3D9TextureCore(TextureType textureType, UINT32 width, UINT32 height, UINT32 depth, UINT32 numMipmaps,
-		PixelFormat format, int usage, bool hwGamma, UINT32 multisampleCount)
-		:TextureCore(textureType, width, height, depth, numMipmaps, format, usage, hwGamma, multisampleCount),
+		PixelFormat format, int usage, bool hwGamma, UINT32 multisampleCount, const PixelDataPtr& initialData)
+		:TextureCore(textureType, width, height, depth, numMipmaps, format, usage, hwGamma, multisampleCount, initialData),
 		mD3DPool(D3DPOOL_MANAGED), mDynamicTextures(false), mHwGammaReadSupported(false), mHwGammaWriteSupported(false), 
 		mMultisampleType(D3DMULTISAMPLE_NONE), mMultisampleQuality(0), mIsBindableAsShaderResource(true)
-	{ }
+	{
+
+	}
 	
 	D3D9TextureCore::~D3D9TextureCore()
 	{	

+ 2 - 2
BansheeD3D9RenderAPI/Source/BsD3D9TextureManager.cpp

@@ -47,10 +47,10 @@ namespace BansheeEngine
 	}
 
 	SPtr<TextureCore> D3D9TextureCoreManager::createTextureInternal(TextureType texType, UINT32 width, UINT32 height, UINT32 depth,
-		int numMips, PixelFormat format, int usage, bool hwGammaCorrection, UINT32 multisampleCount)
+		int numMips, PixelFormat format, int usage, bool hwGammaCorrection, UINT32 multisampleCount, const PixelDataPtr& initialData)
 	{
 		D3D9TextureCore* tex = new (bs_alloc<D3D9TextureCore>()) D3D9TextureCore(texType,
-			width, height, depth, numMips, format, usage, hwGammaCorrection, multisampleCount);
+			width, height, depth, numMips, format, usage, hwGammaCorrection, multisampleCount, initialData);
 
 		SPtr<D3D9TextureCore> texPtr = bs_shared_ptr<D3D9TextureCore>(tex);
 		texPtr->_setThisPtr(texPtr);

+ 7 - 1
BansheeEditor/Include/BsBuiltinEditorResources.h

@@ -143,7 +143,7 @@ namespace BansheeEngine
 		 * @brief	Retrieves an icon that represents a specific resource type
 		 *			that may be displayed when viewing the project library.
 		 */
-		HSpriteTexture getLibraryIcon(ProjectIcon icon) const;
+		HSpriteTexture getLibraryIcon(ProjectIcon icon, int size) const;
 
 		/**
 		 * @brief	Retrieves an icon that may be displayed on the main window's toolbar.
@@ -217,6 +217,12 @@ namespace BansheeEngine
 		 */
 		HGUISkin generateGUISkin();
 
+		/**
+		 * @brief	Generates different sizes of resource icons. Expects maximum sizes of the icons to already be present.
+		 * 			Resulting textures will be saved to the same directory the maximum size textures are in.
+		 */
+		void generateResourceIcons(const Path& inputFolder, const ResourceManifestPtr& resourceManifest);
+
 		/**
 		 * @brief	Loads a GUI skin texture with the specified filename.
 		 */

+ 104 - 14
BansheeEditor/Source/BsBuiltinEditorResources.cpp

@@ -28,6 +28,7 @@
 #include "BsGUIStatusBar.h"
 #include "BsGUIMenuBar.h"
 #include "BsGUIListBox.h"
+#include "BsCoreThread.h"
 
 #include "BsFont.h"
 #include "BsFontImportOptions.h"
@@ -364,6 +365,9 @@ namespace BansheeEngine
 		BuiltinResourcesHelper::importAssets(EditorRawShaderFolder, EditorShaderFolder, mResourceManifest);
 		BuiltinResourcesHelper::importAssets(EditorRawSkinFolder, EditorSkinFolder, mResourceManifest);
 
+		// Generate different sizes of resource icons
+		generateResourceIcons(EditorIconFolder, mResourceManifest);
+
 		// Import fonts
 		BuiltinResourcesHelper::importFont(BuiltinRawDataFolder + DefaultFontFilename, DefaultFontFilename, 
 			BuiltinDataFolder, { DefaultFontSize }, true, mResourceManifest);
@@ -385,6 +389,68 @@ namespace BansheeEngine
 		Resources::instance().unloadAllUnused();
 	}
 
+	void BuiltinEditorResources::generateResourceIcons(const Path& inputFolder, const ResourceManifestPtr& manifest)
+	{
+		if (!FileSystem::exists(inputFolder))
+			return;
+
+		WString iconsToProcess[] = { FolderIconTex, FontIconTex, MeshIconTex, TextureIconTex, PlainTextIconTex, 
+			ScriptCodeIconTex, ShaderIconTex, ShaderIncludeIconTex, MaterialIconTex, SpriteTextureIconTex, PrefabIconTex,
+			GUISkinIconTex };
+
+		PixelDataPtr srcData[sizeof(iconsToProcess)];
+
+		UINT32 idx = 0;
+		for (auto& iconName : iconsToProcess)
+		{
+			Path path = inputFolder + (iconName + L".asset");
+
+			HTexture source = gResources().load<Texture>(path);
+			if (source != nullptr)
+			{
+				srcData[idx] = source->getProperties().allocateSubresourceBuffer(0);
+				source->readSubresource(gCoreAccessor(), 0, srcData[idx]);
+			}
+
+			idx++;
+		}
+
+		gCoreAccessor().submitToCoreThread(true);
+
+		idx = 0;
+		for (auto& iconName : iconsToProcess)
+		{
+			PixelDataPtr src = srcData[idx];
+
+			PixelDataPtr scaled48 = PixelData::create(48, 48, 1, src->getFormat());
+			PixelUtil::scale(*src, *scaled48);
+
+			PixelDataPtr scaled32 = PixelData::create(32, 32, 1, src->getFormat());
+			PixelUtil::scale(*scaled48, *scaled32);
+
+			PixelDataPtr scaled16 = PixelData::create(16, 16, 1, src->getFormat());
+			PixelUtil::scale(*scaled32, *scaled16);
+
+			HTexture tex48 = Texture::create(scaled48);
+			HTexture tex32 = Texture::create(scaled32);
+			HTexture tex16 = Texture::create(scaled16);
+
+			Path outputPath48 = FileSystem::getWorkingDirectoryPath() + inputFolder + (iconName + L"48.asset");
+			Resources::instance().save(tex48, outputPath48, true);
+			manifest->registerResource(tex48.getUUID(), outputPath48);
+
+			Path outputPath32 = FileSystem::getWorkingDirectoryPath() + inputFolder + (iconName + L"32.asset");
+			Resources::instance().save(tex32, outputPath32, true);
+			manifest->registerResource(tex32.getUUID(), outputPath32);
+
+			Path outputPath16 = FileSystem::getWorkingDirectoryPath() + inputFolder + (iconName + L"16.asset");
+			Resources::instance().save(tex16, outputPath16, true);
+			manifest->registerResource(tex16.getUUID(), outputPath16);
+
+			idx++;
+		}
+	}
+
 	HGUISkin BuiltinEditorResources::generateGUISkin()
 	{
 		HGUISkin skin = GUISkin::create();
@@ -1873,37 +1939,61 @@ namespace BansheeEngine
 		return Material::create(mShaderSelection);
 	}
 
-	HSpriteTexture BuiltinEditorResources::getLibraryIcon(ProjectIcon icon) const
+	HSpriteTexture BuiltinEditorResources::getLibraryIcon(ProjectIcon icon, int size) const
 	{
+		WString iconName;
+
 		switch (icon)
 		{
 		case ProjectIcon::Folder:
-			return getGUIIcon(FolderIconTex);
+			iconName = FolderIconTex;
+			break;
 		case ProjectIcon::Font:
-			return getGUIIcon(FontIconTex);
+			iconName = FontIconTex;
+			break;
 		case ProjectIcon::Mesh:
-			return getGUIIcon(MeshIconTex);
+			iconName = MeshIconTex;
+			break;
 		case ProjectIcon::Texture:
-			return getGUIIcon(TextureIconTex);
+			iconName = TextureIconTex;
+			break;
 		case ProjectIcon::PlainText:
-			return getGUIIcon(PlainTextIconTex);
+			iconName = PlainTextIconTex;
+			break;
 		case ProjectIcon::ScriptCode:
-			return getGUIIcon(ScriptCodeIconTex);
+			iconName = ScriptCodeIconTex;
+			break;
 		case ProjectIcon::Shader:
-			return getGUIIcon(ShaderIconTex);
+			iconName = ShaderIconTex;
+			break;
 		case ProjectIcon::ShaderInclude:
-			return getGUIIcon(ShaderIncludeIconTex);
+			iconName = ShaderIncludeIconTex;
+			break;
 		case ProjectIcon::Material:
-			return getGUIIcon(MaterialIconTex);
+			iconName = MaterialIconTex;
+			break;
 		case ProjectIcon::SpriteTexture:
-			return getGUIIcon(SpriteTextureIconTex);
+			iconName = SpriteTextureIconTex;
+			break;
 		case ProjectIcon::Prefab:
-			return getGUIIcon(PrefabIconTex);
+			iconName = PrefabIconTex;
+			break;
 		case ProjectIcon::GUISkin:
-			return getGUIIcon(GUISkinIconTex);
+			iconName = GUISkinIconTex;
+			break;
 		}
 
-		return HSpriteTexture();
+		if (iconName.empty())
+			return HSpriteTexture();
+
+		if (size <= 16)
+			iconName += L"16";
+		else if (size <= 32)
+			iconName += L"32";
+		else if (size <= 48)
+			iconName += L"48";
+
+		return getGUIIcon(iconName);
 	}
 
 	HSpriteTexture BuiltinEditorResources::getToolbarIcon(ToolbarIcon icon) const

+ 1 - 1
BansheeGLRenderAPI/Include/BsGLTexture.h

@@ -46,7 +46,7 @@ namespace BansheeEngine
 		friend class GLTextureCoreManager;
 
 		GLTextureCore(GLSupport& support, TextureType textureType, UINT32 width, UINT32 height, UINT32 depth, UINT32 numMipmaps,
-			PixelFormat format, int usage, bool hwGamma, UINT32 multisampleCount);
+			PixelFormat format, int usage, bool hwGamma, UINT32 multisampleCount, const PixelDataPtr& initialData);
 
 		/**
 		 * @copydoc TextureCore::initialize

+ 1 - 1
BansheeGLRenderAPI/Include/BsGLTextureManager.h

@@ -50,7 +50,7 @@ namespace BansheeEngine
 		 */
 		SPtr<TextureCore> createTextureInternal(TextureType texType, UINT32 width, UINT32 height, UINT32 depth,
 			int numMips, PixelFormat format, int usage = TU_DEFAULT, bool hwGammaCorrection = false,
-			UINT32 multisampleCount = 0) override;
+			UINT32 multisampleCount = 0, const PixelDataPtr& initialData = nullptr) override;
 
 		/**
 		 * @copydoc	TextureCoreManager::createRenderTextureInternal

+ 3 - 3
BansheeGLRenderAPI/Source/BsGLTexture.cpp

@@ -11,9 +11,9 @@
 
 namespace BansheeEngine 
 {
-	GLTextureCore::GLTextureCore(GLSupport& support, TextureType textureType, UINT32 width, UINT32 height, 
-		UINT32 depth, UINT32 numMipmaps, PixelFormat format, int usage, bool hwGamma, UINT32 multisampleCount)
-		: TextureCore(textureType, width, height, depth, numMipmaps, format, usage, hwGamma, multisampleCount),
+	GLTextureCore::GLTextureCore(GLSupport& support, TextureType textureType, UINT32 width, UINT32 height, UINT32 depth, 
+		UINT32 numMipmaps, PixelFormat format, int usage, bool hwGamma, UINT32 multisampleCount, const PixelDataPtr& initialData)
+		: TextureCore(textureType, width, height, depth, numMipmaps, format, usage, hwGamma, multisampleCount, initialData),
 		mTextureID(0), mGLSupport(support), mGLFormat(0)
     { }
 

+ 2 - 2
BansheeGLRenderAPI/Source/BsGLTextureManager.cpp

@@ -65,10 +65,10 @@ namespace BansheeEngine
 	{ }
 
 	SPtr<TextureCore> GLTextureCoreManager::createTextureInternal(TextureType texType, UINT32 width, UINT32 height, UINT32 depth,
-		int numMips, PixelFormat format, int usage, bool hwGammaCorrection, UINT32 multisampleCount)
+		int numMips, PixelFormat format, int usage, bool hwGammaCorrection, UINT32 multisampleCount, const PixelDataPtr& initialData)
 	{
 		GLTextureCore* tex = new (bs_alloc<GLTextureCore>()) GLTextureCore(mGLSupport, texType,
-			width, height, depth, numMips, format, usage, hwGammaCorrection, multisampleCount);
+			width, height, depth, numMips, format, usage, hwGammaCorrection, multisampleCount, initialData);
 
 		SPtr<GLTextureCore> texPtr = bs_shared_ptr<GLTextureCore>(tex);
 		texPtr->_setThisPtr(texPtr);

+ 23 - 72
MBansheeEditor/EditorBuiltin.cs

@@ -37,47 +37,20 @@ namespace BansheeEditor
 		Create, Clone, Clear, Resize, Delete, MoveUp, MoveDown, Edit, Apply, Add, Cancel
 	};
 
+    /// <summary>
+    /// Types of icons that may be displayed for resources in the library window.
+    /// </summary>
+    public enum LibraryItemIcon // Note: Must match C++ enum ProjectIcon
+	{
+		Folder, Mesh, Font, Texture, PlainText, ScriptCode, SpriteTexture, Shader, ShaderInclude, Material, Prefab, GUISkin
+	};
+
     /// <summary>
     /// Contains various editor-specific resources that are always available.
     /// </summary>
     public static class EditorBuiltin
     {
-        /// <summary>Icon used for displaying folders in the library window.</summary>
-        public static SpriteTexture FolderIcon { get { return Internal_GetFolderIcon(); } }
-
-        /// <summary>Icon used for displaying mesh resources in the library window.</summary>
-        public static SpriteTexture MeshIcon { get { return Internal_GetMeshIcon(); } }
-
-        /// <summary>Icon used for displaying font resources in the library window.</summary>
-        public static SpriteTexture FontIcon { get { return Internal_GetFontIcon(); } }
-
-        /// <summary>Icon used for displaying texture resources in the library window.</summary>
-        public static SpriteTexture TextureIcon { get { return Internal_GetTextureIcon(); } }
-
-        /// <summary>Icon used for displaying plain text resources in the library window.</summary>
-        public static SpriteTexture PlainTextIcon { get { return Internal_GetPlainTextIcon(); } }
-
-        /// <summary>Icon used for displaying script code resources in the library window.</summary>
-        public static SpriteTexture ScriptCodeIcon { get { return Internal_GetScriptCodeIcon(); } }
-
-        /// <summary>Icon used for displaying shader resources in the library window.</summary>
-        public static SpriteTexture ShaderIcon { get { return Internal_GetShaderIcon(); } }
-
-        /// <summary>Icon used for displaying shader include resources in the library window.</summary>
-        public static SpriteTexture ShaderIncludeIcon { get { return Internal_GetShaderIncludeIcon(); } }
-
-        /// <summary>Icon used for displaying material resources in the library window.</summary>
-        public static SpriteTexture MaterialIcon { get { return Internal_GetMaterialIcon(); } }
-
-        /// <summary>Icon used for displaying sprite texture resources in the library window.</summary>
-        public static SpriteTexture SpriteTextureIcon { get { return Internal_GetSpriteTextureIcon(); } }
-
-        /// <summary>Icon used for displaying prefab resources in the library window.</summary>
-        public static SpriteTexture PrefabIcon { get { return Internal_GetPrefabIcon(); } }
-
-        /// <summary>Icon used for displaying GUI skin resources in the library window.</summary>
-        public static SpriteTexture GUISkinIcon { get { return Internal_GetGUISkinIcon(); } }
-
+        /// <summary>Returns a texture displaying an X button.</summary>
         public static SpriteTexture XBtnIcon { get { return Internal_GetXBtnIcon(); } }
 
         /// <summary>Returns text contained in the default "empty" shader.</summary>
@@ -86,6 +59,18 @@ namespace BansheeEditor
         /// <summary>Returns text contained in the default "empty" C# script.</summary>
         public static string EmptyCSScriptCode { get { return Internal_GetEmptyCSScriptCode(); } }
 
+        /// <summary>
+        /// Retrieves an icon used for displaying an entry in the library window.
+        /// </summary>
+        /// <param name="icon">Type of the icon to retrieve.</param>
+        /// <param name="size">Size of the icon to retrieve in pixels. This will be rounded
+        ///                    to nearest available size.</param>
+        /// <returns>Sprite texture of the icon.</returns>
+        public static SpriteTexture GetLibraryItemIcon(LibraryItemIcon icon, int size)
+        {
+            return Internal_GetLibraryItemIcon(icon, size);
+        }
+
         /// <summary>
         /// Retrieves an icon that may be displayed on the main window's toolbar.
         /// </summary>
@@ -116,7 +101,6 @@ namespace BansheeEditor
             return Internal_GetInspectorWindowIcon(icon);
         }
 
-
         /// <summary>
         /// Retrieves an icon that may be displayed on the scene window.
         /// </summary>
@@ -128,41 +112,8 @@ namespace BansheeEditor
         }
 
         [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern SpriteTexture Internal_GetFolderIcon();
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern SpriteTexture Internal_GetMeshIcon();
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern SpriteTexture Internal_GetFontIcon();
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern SpriteTexture Internal_GetTextureIcon();
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern SpriteTexture Internal_GetPlainTextIcon();
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern SpriteTexture Internal_GetScriptCodeIcon();
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern SpriteTexture Internal_GetShaderIcon();
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern SpriteTexture Internal_GetShaderIncludeIcon();
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern SpriteTexture Internal_GetMaterialIcon();
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern SpriteTexture Internal_GetSpriteTextureIcon();
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern SpriteTexture Internal_GetPrefabIcon();
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern SpriteTexture Internal_GetGUISkinIcon();
-
+        private static extern SpriteTexture Internal_GetLibraryItemIcon(LibraryItemIcon icon, int size);
+        
         [MethodImpl(MethodImplOptions.InternalCall)]
         private static extern SpriteTexture Internal_GetXBtnIcon();
 

+ 14 - 13
MBansheeEditor/Library/LibraryGUIEntry.cs

@@ -57,7 +57,7 @@ namespace BansheeEditor
             else
                 entryLayout = parent.AddLayoutX();
 
-            SpriteTexture iconTexture = GetIcon(entry);
+            SpriteTexture iconTexture = GetIcon(entry, owner.TileSize);
 
             icon = new GUITexture(iconTexture, GUIImageScaleMode.ScaleToFit,
                 true, GUIOption.FixedHeight(owner.TileSize), GUIOption.FixedWidth(owner.TileSize));
@@ -299,12 +299,13 @@ namespace BansheeEditor
         /// Returns an icon that can be used for displaying a resource of the specified type.
         /// </summary>
         /// <param name="entry">Project library entry of the resource to retrieve icon for.</param>
+        /// <param name="size">Size of the icon to retrieve, in pixels.</param>
         /// <returns>Icon to display for the specified entry.</returns>
-        private static SpriteTexture GetIcon(LibraryEntry entry)
+        private static SpriteTexture GetIcon(LibraryEntry entry, int size)
         {
             if (entry.Type == LibraryEntryType.Directory)
             {
-                return EditorBuiltin.FolderIcon;
+                return EditorBuiltin.GetLibraryItemIcon(LibraryItemIcon.Folder, size);
             }
             else
             {
@@ -312,25 +313,25 @@ namespace BansheeEditor
                 switch (fileEntry.ResType)
                 {
                     case ResourceType.Font:
-                        return EditorBuiltin.FontIcon;
+                        return EditorBuiltin.GetLibraryItemIcon(LibraryItemIcon.Font, size);
                     case ResourceType.Mesh:
-                        return EditorBuiltin.MeshIcon;
+                        return EditorBuiltin.GetLibraryItemIcon(LibraryItemIcon.Mesh, size);
                     case ResourceType.Texture:
-                        return EditorBuiltin.TextureIcon;
+                        return EditorBuiltin.GetLibraryItemIcon(LibraryItemIcon.Texture, size);
                     case ResourceType.PlainText:
-                        return EditorBuiltin.PlainTextIcon;
+                        return EditorBuiltin.GetLibraryItemIcon(LibraryItemIcon.PlainText, size);
                     case ResourceType.ScriptCode:
-                        return EditorBuiltin.ScriptCodeIcon;
+                        return EditorBuiltin.GetLibraryItemIcon(LibraryItemIcon.ScriptCode, size);
                     case ResourceType.SpriteTexture:
-                        return EditorBuiltin.SpriteTextureIcon;
+                        return EditorBuiltin.GetLibraryItemIcon(LibraryItemIcon.SpriteTexture, size);
                     case ResourceType.Shader:
-                        return EditorBuiltin.ShaderIcon;
+                        return EditorBuiltin.GetLibraryItemIcon(LibraryItemIcon.Shader, size);
                     case ResourceType.Material:
-                        return EditorBuiltin.MaterialIcon;
+                        return EditorBuiltin.GetLibraryItemIcon(LibraryItemIcon.Material, size);
                     case ResourceType.Prefab:
-                        return EditorBuiltin.PrefabIcon;
+                        return EditorBuiltin.GetLibraryItemIcon(LibraryItemIcon.Prefab, size);
                     case ResourceType.GUISkin:
-                        return EditorBuiltin.GUISkinIcon;
+                        return EditorBuiltin.GetLibraryItemIcon(LibraryItemIcon.GUISkin, size);
                 }
             }
 

+ 12 - 12
MBansheeEditor/Scene/SceneWindow.cs

@@ -119,24 +119,24 @@ namespace BansheeEditor
             GUIContent rotateSnapIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.RotateSnap));
 
             GUIToggleGroup handlesTG = new GUIToggleGroup();
-            viewButton = new GUIToggle(viewIcon, handlesTG, EditorStyles.Button);
-            moveButton = new GUIToggle(moveIcon, handlesTG, EditorStyles.Button);
-            rotateButton = new GUIToggle(rotateIcon, handlesTG, EditorStyles.Button);
-            scaleButton = new GUIToggle(scaleIcon, handlesTG, EditorStyles.Button);
+            viewButton = new GUIToggle(viewIcon, handlesTG, EditorStyles.Button, GUIOption.FlexibleWidth(35));
+            moveButton = new GUIToggle(moveIcon, handlesTG, EditorStyles.Button, GUIOption.FlexibleWidth(35));
+            rotateButton = new GUIToggle(rotateIcon, handlesTG, EditorStyles.Button, GUIOption.FlexibleWidth(35));
+            scaleButton = new GUIToggle(scaleIcon, handlesTG, EditorStyles.Button, GUIOption.FlexibleWidth(35));
 
             GUIToggleGroup coordModeTG = new GUIToggleGroup();
-            localCoordButton = new GUIToggle(localIcon, coordModeTG, EditorStyles.Button);
-            worldCoordButton = new GUIToggle(worldIcon, coordModeTG, EditorStyles.Button);
+            localCoordButton = new GUIToggle(localIcon, coordModeTG, EditorStyles.Button, GUIOption.FlexibleWidth(75));
+            worldCoordButton = new GUIToggle(worldIcon, coordModeTG, EditorStyles.Button, GUIOption.FlexibleWidth(75));
 
             GUIToggleGroup pivotModeTG = new GUIToggleGroup();
-            pivotButton = new GUIToggle(pivotIcon, pivotModeTG, EditorStyles.Button);
-            centerButton = new GUIToggle(centerIcon, pivotModeTG, EditorStyles.Button);
+            pivotButton = new GUIToggle(pivotIcon, pivotModeTG, EditorStyles.Button, GUIOption.FlexibleWidth(35));
+            centerButton = new GUIToggle(centerIcon, pivotModeTG, EditorStyles.Button, GUIOption.FlexibleWidth(35));
 
-            moveSnapButton = new GUIToggle(moveSnapIcon, EditorStyles.Button);
-            moveSnapInput = new GUIFloatField();
+            moveSnapButton = new GUIToggle(moveSnapIcon, EditorStyles.Button, GUIOption.FlexibleWidth(35));
+            moveSnapInput = new GUIFloatField("", GUIOption.FlexibleWidth(35));
 
-            rotateSnapButton = new GUIToggle(rotateSnapIcon, EditorStyles.Button);
-            rotateSnapInput = new GUIFloatField();
+            rotateSnapButton = new GUIToggle(rotateSnapIcon, EditorStyles.Button, GUIOption.FlexibleWidth(35));
+            rotateSnapInput = new GUIFloatField("", GUIOption.FlexibleWidth(35));
 
             viewButton.OnClick += () => OnSceneToolButtonClicked(SceneViewTool.View);
             moveButton.OnClick += () => OnSceneToolButtonClicked(SceneViewTool.Move);

+ 1 - 12
SBansheeEditor/Include/BsScriptEditorBuiltin.h

@@ -20,18 +20,7 @@ namespace BansheeEngine
 		/************************************************************************/
 		/* 								CLR HOOKS						   		*/
 		/************************************************************************/
-		static MonoObject* internal_getFolderIcon();
-		static MonoObject* internal_getMeshIcon();
-		static MonoObject* internal_getFontIcon();
-		static MonoObject* internal_getTextureIcon();
-		static MonoObject* internal_getPlainTextIcon();
-		static MonoObject* internal_getScriptCodeIcon();
-		static MonoObject* internal_getShaderIcon();
-		static MonoObject* internal_getShaderIncludeIcon();
-		static MonoObject* internal_getMaterialIcon();
-		static MonoObject* internal_getSpriteTextureIcon();
-		static MonoObject* internal_getGUISkinIcon();
-		static MonoObject* internal_getPrefabIcon();
+		static MonoObject* internal_getLibraryItemIcon(ProjectIcon icon, int size);
 		static MonoObject* internal_getXBtnIcon();
 
 		static MonoString* internal_GetEmptyShaderCode();

+ 3 - 91
SBansheeEditor/Source/BsScriptEditorBuiltin.cpp

@@ -14,18 +14,7 @@ namespace BansheeEngine
 
 	void ScriptEditorBuiltin::initRuntimeData()
 	{
-		metaData.scriptClass->addInternalCall("Internal_GetFolderIcon", &ScriptEditorBuiltin::internal_getFolderIcon);
-		metaData.scriptClass->addInternalCall("Internal_GetMeshIcon", &ScriptEditorBuiltin::internal_getMeshIcon);
-		metaData.scriptClass->addInternalCall("Internal_GetFontIcon", &ScriptEditorBuiltin::internal_getFontIcon);
-		metaData.scriptClass->addInternalCall("Internal_GetTextureIcon", &ScriptEditorBuiltin::internal_getTextureIcon);
-		metaData.scriptClass->addInternalCall("Internal_GetPlainTextIcon", &ScriptEditorBuiltin::internal_getPlainTextIcon);
-		metaData.scriptClass->addInternalCall("Internal_GetScriptCodeIcon", &ScriptEditorBuiltin::internal_getScriptCodeIcon);
-		metaData.scriptClass->addInternalCall("Internal_GetShaderIcon", &ScriptEditorBuiltin::internal_getShaderIcon);
-		metaData.scriptClass->addInternalCall("Internal_GetShaderIncludeIcon", &ScriptEditorBuiltin::internal_getShaderIncludeIcon);
-		metaData.scriptClass->addInternalCall("Internal_GetMaterialIcon", &ScriptEditorBuiltin::internal_getMaterialIcon);
-		metaData.scriptClass->addInternalCall("Internal_GetSpriteTextureIcon", &ScriptEditorBuiltin::internal_getSpriteTextureIcon);
-		metaData.scriptClass->addInternalCall("Internal_GetGUISkinIcon", &ScriptEditorBuiltin::internal_getGUISkinIcon);
-		metaData.scriptClass->addInternalCall("Internal_GetPrefabIcon", &ScriptEditorBuiltin::internal_getPrefabIcon);
+		metaData.scriptClass->addInternalCall("Internal_GetLibraryItemIcon", &ScriptEditorBuiltin::internal_getLibraryItemIcon);
 		metaData.scriptClass->addInternalCall("Internal_GetXBtnIcon", &ScriptEditorBuiltin::internal_getXBtnIcon);
 		metaData.scriptClass->addInternalCall("Internal_GetEmptyShaderCode", &ScriptEditorBuiltin::internal_GetEmptyShaderCode);
 		metaData.scriptClass->addInternalCall("Internal_GetEmptyCSScriptCode", &ScriptEditorBuiltin::internal_GetEmptyCSScriptCode);
@@ -35,86 +24,9 @@ namespace BansheeEngine
 		metaData.scriptClass->addInternalCall("Internal_GetSceneWindowIcon", &ScriptEditorBuiltin::internal_GetSceneWindowIcon);
 	}
 
-	MonoObject* ScriptEditorBuiltin::internal_getFolderIcon()
+	MonoObject* ScriptEditorBuiltin::internal_getLibraryItemIcon(ProjectIcon icon, int size)
 	{
-		HSpriteTexture tex = BuiltinEditorResources::instance().getLibraryIcon(ProjectIcon::Folder);
-
-		return ScriptSpriteTexture::toManaged(tex);
-	}
-
-	MonoObject* ScriptEditorBuiltin::internal_getMeshIcon()
-	{
-		HSpriteTexture tex = BuiltinEditorResources::instance().getLibraryIcon(ProjectIcon::Mesh);
-
-		return ScriptSpriteTexture::toManaged(tex);
-	}
-
-	MonoObject* ScriptEditorBuiltin::internal_getFontIcon()
-	{
-		HSpriteTexture tex = BuiltinEditorResources::instance().getLibraryIcon(ProjectIcon::Font);
-
-		return ScriptSpriteTexture::toManaged(tex);
-	}
-
-	MonoObject* ScriptEditorBuiltin::internal_getTextureIcon()
-	{
-		HSpriteTexture tex = BuiltinEditorResources::instance().getLibraryIcon(ProjectIcon::Texture);
-
-		return ScriptSpriteTexture::toManaged(tex);
-	}
-
-	MonoObject* ScriptEditorBuiltin::internal_getPlainTextIcon()
-	{
-		HSpriteTexture tex = BuiltinEditorResources::instance().getLibraryIcon(ProjectIcon::PlainText);
-
-		return ScriptSpriteTexture::toManaged(tex);
-	}
-
-	MonoObject* ScriptEditorBuiltin::internal_getScriptCodeIcon()
-	{
-		HSpriteTexture tex = BuiltinEditorResources::instance().getLibraryIcon(ProjectIcon::ScriptCode);
-
-		return ScriptSpriteTexture::toManaged(tex);
-	}
-
-	MonoObject* ScriptEditorBuiltin::internal_getShaderIcon()
-	{
-		HSpriteTexture tex = BuiltinEditorResources::instance().getLibraryIcon(ProjectIcon::Shader);
-
-		return ScriptSpriteTexture::toManaged(tex);
-	}
-
-	MonoObject* ScriptEditorBuiltin::internal_getShaderIncludeIcon()
-	{
-		HSpriteTexture tex = BuiltinEditorResources::instance().getLibraryIcon(ProjectIcon::ShaderInclude);
-
-		return ScriptSpriteTexture::toManaged(tex);
-	}
-
-	MonoObject* ScriptEditorBuiltin::internal_getMaterialIcon()
-	{
-		HSpriteTexture tex = BuiltinEditorResources::instance().getLibraryIcon(ProjectIcon::Material);
-
-		return ScriptSpriteTexture::toManaged(tex);
-	}
-
-	MonoObject* ScriptEditorBuiltin::internal_getSpriteTextureIcon()
-	{
-		HSpriteTexture tex = BuiltinEditorResources::instance().getLibraryIcon(ProjectIcon::SpriteTexture);
-
-		return ScriptSpriteTexture::toManaged(tex);
-	}
-
-	MonoObject* ScriptEditorBuiltin::internal_getGUISkinIcon()
-	{
-		HSpriteTexture tex = BuiltinEditorResources::instance().getLibraryIcon(ProjectIcon::GUISkin);
-
-		return ScriptSpriteTexture::toManaged(tex);
-	}
-
-	MonoObject* ScriptEditorBuiltin::internal_getPrefabIcon()
-	{
-		HSpriteTexture tex = BuiltinEditorResources::instance().getLibraryIcon(ProjectIcon::Prefab);
+		HSpriteTexture tex = BuiltinEditorResources::instance().getLibraryIcon(icon, size);
 
 		return ScriptSpriteTexture::toManaged(tex);
 	}