TextureUtility is a static helper class that helps you get Textures in the editor from two sources, Resources folder and DLLs.
GetBuiltInTexture provides a solution to get a unity editor build in texture.
In the Unity Editor, the texture has to be in a Resources folder in a Editor folder.
If the texture is not found in a Resources folder in the project, the utility will try to load it from the Embedded Resources in a DLL. If it does not find it, it will just put up a blank texture.
Load the texture (...)/Editor/Resources/MyProject_TextureName.png
var tex = TextureUtility.GetEmbeddedIcon("MyProject_TextureName");
Textures name require an unique name (with your project name for example) because
TextureUtility find textures by name, not with the complete path in assembly
Wonderland can automatically adds your Resources in your libraries. Set
Common.ResourcesCompilationPipelineto true in the Wonderland configuration window.
Create an assembly definition in your dll directory.
Configure it with references and platforms (tick Editor only for editor dlls)
Unity will build automatically the dll and create a csproj file.
TextureUtility adds a compilation step and automatically appends (...)/Editor/Resources/ files in the project if DLL name contains "Editor". Resources are not append in the unity dlls (Library/ScriptAssemblies/).
Generate projects in VS
Open all referenced projects
Configure your build (release for standard dll, debug for editor dll)
Select your build and generate it. DLLs are located in obj folders.
Bug since Unity 2019.3
Since Unity 2019.3, project files not works to build DLL. There are 2 problems.
PropertyGroup Release has been removed To resolve, append this
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>pdbonly</DebugType> <Optimize>true</Optimize> <OutputPath>Temp\bin\Release\</OutputPath> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <NoWarn>0169</NoWarn> <AllowUnsafeBlocks>False</AllowUnsafeBlocks> </PropertyGroup>
<PropertyGroup> <NoConfig>true</NoConfig> <NoStdLib>true</NoStdLib> ...
In ProjectReference blocks, this line
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>Remove it or set it to true. Issue tracker (Fixed in 2019.3.13f1)