How do i get the image or tile image / texture that is in my tile map?

Im trying to get the image that is used in my TileMap. At first i thought maybe something like Set Texture from Brush, though that doesnt exist. Only Set Brush from Texture is possible.

Im trying to get individual tile textures out of it to be used in different meshes. Or if i can get the image that is being used as a whole in the tilemap that will also work.
Maybe get some sort of reference from OldSmallHousing_TileMap

Edit:

There is a Get Brush as Texture2D but returns None :frowning:

The material inside of a tile map isn’t actually cut up into separate parts. It’s just one big image that is offset internally. You would have to do some extra c++ gymnastics to extract the needed tile and output it to a usable brush (probably involving drawing into a render target instance temporarily)

1 Like
UCLASS(BlueprintType)
class PAPER2D_API UPaperTileSet : public UObject
{
	GENERATED_UCLASS_BODY()

private:
	// The width and height of a single tile (in pixels)
	UPROPERTY(Category=TileSet, BlueprintReadOnly, EditAnywhere, meta=(UIMin=1, ClampMin=1, AllowPrivateAccess="true"))
	FIntPoint TileSize;

	// The tile sheet texture associated with this tile set
	UPROPERTY(Category=TileSet, BlueprintReadOnly, EditAnywhere, meta=(DisplayName="Tile Sheet Texture", AllowPrivateAccess="true"))
	UTexture2D* TileSheet;

	// Additional source textures for other slots
	UPROPERTY(Category = TileSet, EditAnywhere, AssetRegistrySearchable, meta = (DisplayName = "Additional Textures"))
	TArray<UTexture*> AdditionalSourceTextures;

These are the functions i think i need, they are in UPaperTileSet, in PaperStyleSet.h.
But I cant include PaperStyleSet in my BlueprintFunctionLibrary.. Really wanted to try to call these functions. Though they are also private. Any tips?

UPaperTileSet has a function called GetTileSheetTexture() to return the utexture2d.
Only problem is that by default the internal TileSet returned from the FPaperTileInfo via GetCel(X,Y) is null. Correction the layers where just swapped. I was able to extract the utexture on layer 1 :slight_smile:


UTexture2D* UMyBlueprintFunctionLibrary::GetBrushTile(UObject* WorldContextObject, int32 X, int32 Y, int32 layerIndex, UPaperTileMap* TileMap)
{
	UTexture2D* TileSheet = nullptr;		
	FPaperTileInfo info = TileMap->TileLayers[layerIndex]->GetCell(X, Y);
	if (info.TileSet != nullptr) 
	{
		UTexture2D* tex = info.TileSet->GetTileSheetTexture();
		return tex;
	}		
	return TileSheet;
}

Though it returns the full texture and not just the grid segment.

1 Like

awesome.
Though im not being able to include:
include “PaperTileMap.h”
include “PaperTileLayer.h”
include “PaperTileSet.h”

I included Paper2D in the modules.

Im getting these errors:

2>C:\Program Files\Epic Games\UE_4.27\Engine\Plugins\2D\Paper2D\Source\Paper2D\Classes\PaperTileSet.h(19): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
2>C:\Program Files\Epic Games\UE_4.27\Engine\Plugins\2D\Paper2D\Source\Paper2D\Classes\PaperTileSet.h(62): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
2>C:\Program Files\Epic Games\UE_4.27\Engine\Plugins\2D\Paper2D\Source\Paper2D\Classes\PaperTileSet.h(77): error C2143: syntax error: missing ';' before '<class-head>'

Did you have to include anything?

Just the paper 2d module

and then the header includes

include “PaperTileMap.h”
include “PaperTileLayer.h”
include “PaperTileSet.h”

Make sure your .generated is the last in the header file of your class otherwise you can get random nonsensical errors.

1 Like

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "PaperTileSet.h"
#include "Kismet/BlueprintFunctionLibrary.h"
//#include "C:/Program Files/Epic Games/UE_4.27/Engine/Plugins/2D/Paper2D/Source/Paper2D/Classes/PaperTileSet.h"
#include "GlobalLibraries.generated.h"

/**
 * 
 */

//class UPaperTileSet;

UCLASS()
class UKP_API UGlobalLibraries : public UBlueprintFunctionLibrary
{
	GENERATED_BODY()

    UFUNCTION(BlueprintCallable, meta = (DisplayName = "Move Camera", Keywords = "Move Camera"), Category = "Editor Camera")
        static void MoveCamera(FVector newLocation, FRotator newRotation, float newFoV/*, ELevelViewportType ViewPortType*/);

	//UFUNCTION(BlueprintCallable, meta = (DisplayName = "Move Camera", Keywords = "Move Camera"), Category = "Editor Camera")
	//	static UTexture2D* GetBrushTile(UObject* WorldContextObject, int32 X, int32 Y, int32 layerIndex, UPaperTileMap* TileMap);
	
};

error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

I cant even include just the include “PaperTileSet.h”
It gives me those weird errors. Tried googling around. They say to rebuild. Tried that, and Generate Visual studio. Perhaps its the version 4.27 is freaking out with the PaperTileSet.

This would point towards a needed rebuild. Only other thing that stands out is the use of the word Global in the name of the blueprint library. Maybe it triggers a macro in the pre-compiler for some reason? (a bit of a shot in the dark). Maybe try temporarily renaming the library and see if anything changes.

1 Like

Its so strange, its only the file PaperTileSet.h
Tried rebuilding.

Thats where the problem is.
What else can i try? Any work around ?

Try validating your engine install. PaperTileSet has been changed (it has an enter between include “IntMargin.h” and generated in the source files). Maybe you accidentally had it open and modified it with a keystroke causing a cascade of errors?

I try to keep all engine files locked so that vs cannot change them if I’m maybe slightly tired and type where I’m not supposed to.

Here is what I have in 4.27
PaperTileSet.h (9.2 KB)

Also close all engine files when compiling otherwise the compiler may throw errors.

1 Like

That actually fixed it !! the enter space fixed it? How is this possible?
Wow…
Its working now.

Now I can use the TileMap to design buildings with Y sorting, and then converting it to Planes.
This is great.

Thanks again @3dRaven :folded_hands::folded_hands:

1 Like