View on GitHub

TextureAtlasImporter

plugin folder: master/Engine/Plugins/TextureAtlasImporter

Manual

  1. Create texture atlas (sprite sheet) with Free Texture Packer (http://free-tex-packer.com/), TexturePacker (http://www.codeandweb.com/texturepacker), etc. in JSON Array or UnrealEngine(paper2dsprites) data format.
  2. Change json/paper2dsprites file extension to “atlas”, “json_atlas” or “paper2dsprites_atlas”.
  3. Import it to Unreal Editor and get Material Parameter Collection with MPC_ prefix and texture in /Textures subfolder.
  4. For extracting use GetImageFromAtlas material function.
  5. For the numbering of tiles instead of the names of the pictures, use the option in the Project Settings/Editor/TextureAtlasImporter.

Examples

For C++

int32 num = MPC->GetScalarParameterByName(TEXT("Num"))->DefaultValue;
for (int32 i = 0; i < num; ++i)
{
	UMaterialInstanceDynamic* MID = UMaterialInstanceDynamic::Create(DefaultMaterial,nullptr);
	Materials.Emplace(MID);
	MID->SetVectorParameterValue(TEXT("Param_1"), MPC->GetVectorParameterByName(*("Tile_"+FString::FromInt(i)+"_PosXY_SizeXY"))->DefaultValue);
	MID->SetVectorParameterValue(TEXT("Param_2"), MPC->GetVectorParameterByName(*("Tile_"+FString::FromInt(i)+"_InSourcePosXY_SourceSize"))->DefaultValue);
	MID->SetVectorParameterValue(TEXT("Param_3"), MPC->GetVectorParameterByName(*("Tile_"+FString::FromInt(i)+"_bTrimmed_bRotated_AtlasSize"))->DefaultValue);
}