1
\$\begingroup\$

I'm trying to follow the modular character tutorial for Unreal from this link Specifically the mesh merge portion. How ever the code that is provided seems to not be working.

For example when I add this piece of code :

USTRUCT(BlueprintType)
struct VR_API FSkelMeshMergeSectionMapping_BP
{
    GENERATED_BODY()
        UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Mesh Merge Params")
        TArray<type> SectionIDs;
};

I get the following error : Unrecognized type 'type' - type must be a UCLASS, USTRUCT or UENUM

I;m guessing I should provide a certain type in the <> but I have no idea what it should be. I've been using unreal only for 2 days now so if anyone can help me figure this tutorial out and get it working I would be thankful.

\$\endgroup\$
1
\$\begingroup\$

TArray is a template type in Unreal, which means you need to give it template parameters (within the angle brackets) when declaring one. In the case of TArray, you need at a minimum to indicate the type of data stored in the array. What you've written in your example is "a TArray of instances of type" and the error is telling you that there is no type named type.

"Section IDs" sound like they'd be integers, so you should probably write TArray<int> to create an array of ints. Or whichever other integer type is appropriate.

(Other than TArray itself, which is an Unreal type, this is a general C++ problem regarding templates, so if you are looking for more background you don't need to look for Unreal-specific information... although the specific error you are seeing is an Unreal-specific one arising from how it parses your code and applies extra validation to UPROPERTY members, in this case putting additional constraints on the type parameter. TArray is roughly analogous in intent to the C++ standard library type std::vector.)


Reading through that tutorial link in more detail, much of the code samples seem to suffer from errors like this, including several declarations of TArray with no template parameters at all (which won't compile) as well as some stray characters at the end of some of the snippets.

\$\endgroup\$
3
\$\begingroup\$

Not sure if you got this, but I worked it out pretty sure...

The goal is they're trying to make the existing ones in SkeletalMeshMerge.h editable on the blueprint side, so basically going into that file I could see what the arrays were.

So you want the FSkelMeshMergeSectionMapping_BP to contain int32's:

USTRUCT(BlueprintType)
struct MULTIPLAYERARENA_API FSkelMeshMergeSectionMapping_BP
{
    GENERATED_BODY()
        /** Indices to final section entries of the merged skeletal mesh */
        UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Mesh Merge Params")
        TArray<int32> SectionIDs;
};

and the FSkelMeshMergeSectionMapping_BP to contain FTransform's:

USTRUCT(BlueprintType)
struct MULTIPLAYERARENA_API FSkelMeshMergeUVTransform
{
    GENERATED_BODY()
        /** A list of how UVs should be transformed on a given mesh, where index represents a specific UV channel. */
        UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Mesh Merge Params")
        TArray<FTransform> UVTransforms;
};

and the FSkelMeshMergeUVTransformMapping to contain FSkelMeshMergeUVTransform's:

USTRUCT(BlueprintType)
struct MULTIPLAYERARENA_API FSkelMeshMergeUVTransformMapping
{
    GENERATED_BODY()
        /** For each UV channel on each mesh, how the UVS should be transformed. */
        UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Mesh Merge Params")
        TArray<FSkelMeshMergeUVTransform> UVTransformsPerMesh;
};

finally in the struct params themselves, like so:

USTRUCT(BlueprintType)
struct MULTIPLAYERARENA_API FSkeletalMeshMergeParams
{
    GENERATED_BODY()
        FSkeletalMeshMergeParams()
    {
        MeshSectionMappings = TArray<FSkelMeshMergeSectionMapping_BP>();
        UVTransformsPerMesh = TArray<FSkelMeshMergeUVTransformMapping>();
        StripTopLODS = 0;
        bNeedsCpuAccess = false;
        bSkeletonBefore = false;
        Skeleton = nullptr;
    }
    // An optional array to map sections from the source meshes to merged section entries
    UPROPERTY(EditAnywhere, BlueprintReadWrite)
        TArray<FSkelMeshMergeSectionMapping_BP> MeshSectionMappings;
    // An optional array to transform the UVs in each mesh
    UPROPERTY(EditAnywhere, BlueprintReadWrite)
        TArray<FSkelMeshMergeUVTransformMapping> UVTransformsPerMesh;
    // The list of skeletal meshes to merge.
    UPROPERTY(EditAnywhere, BlueprintReadWrite)
        TArray<class USkeletalMesh*> MeshesToMerge;
    // The number of high LODs to remove from input meshes
    UPROPERTY(EditAnywhere, BlueprintReadWrite)
        int32 StripTopLODS;
    // Whether or not the resulting mesh needs to be accessed by the CPU for any reason (e.g. for spawning particle effects).
    UPROPERTY(EditAnywhere, BlueprintReadWrite)
        uint32 bNeedsCpuAccess : 1;
    // Update skeleton before merge. Otherwise, update after.
    // Skeleton must also be provided.
    UPROPERTY(EditAnywhere, BlueprintReadWrite)
        uint32 bSkeletonBefore : 1;
    // Skeleton that will be used for the merged mesh.
    // Leave empty if the generated skeleton is OK.
    UPROPERTY(EditAnywhere, BlueprintReadOnly)
        class USkeleton* Skeleton;
};

It compiles and it works with meshes, but I haven't used these optional parameters so don't know if they actually work

\$\endgroup\$
1
\$\begingroup\$

To add to Alex Coultas's solution, the final UProperty in the FSkeletalMeshMergeParams struct has to be BlueprintReadWrite like the others, otherwise you get yellow warnings in the output box.

// Skeleton that will be used for the merged mesh.
// Leave empty if the generated skeleton is OK.
UPROPERTY(EditAnywhere, BlueprintReadWrite)
    class USkeleton* Skeleton;
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.