Adding World Actors to UDataAsset in Editor issue

Hi all,

I’ve create a UDataAsset, see below…



UCLASS()
class MM2_API UMultipleLightTriggerData : public UDataAsset
{
    GENERATED_BODY()

public:

    // Switch Positions
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Switch")
    int32 SwitchPosition;

    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Switch")
    int32 SwitchPositionPrevious;

    // Connected Lights 1
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Lights")
    TArray<AWallLamp*> ConnectLights1;

    // Connected Lights 2
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Lights")
    TArray<AWallLamp*> ConnectLights2;
};



In the editor I’ve created a DataAsset object in the Project, referenced it in my AActor class so that it shows in the Editor and assigned it’s reference (see image to see this as it’s easier to see than explain). You will see the drop downs for the two sets of Arrays. When i click the little down arrow in the arrays it lists all the lights in my scene correctly, but i can’t select them (always defaults to none).


Can you not reference world actors in DataAssets?

Best Regards,
Matt.

[UPDATE] - I’ve reverted to referencing the Connected Lights within the Switch Actor (i guess this makes sense to some degree). I just like to keep data and function separate, especially as it help me with saving and loading games.

The question still stands though… if thee is a way of referencing Actors that are in the scene within DataAssets i’d love to know.

Best regards always,
Matt.

You can’t reference scene Actors in Blueprints of any kind, as far as I am aware. The only place you can reference them is in instances of Blueprints (i.e. other scene Actors).

You cannot reference scene actors in any static assets, such as Blueprints and DataAssets.

Remember: scene actors only exist for as long as the scene is loaded. Once you switch scenes, the referenced actors are destroyed. If you opened the data asset while the scene was not loaded, your data asset would point to gibberish! That’s why the editor prohibits it.

You current solution is the way to go: using another actor in the scene to reference your scene actors.