Editor.BaseDropObject

Started by Bot · one year ago · 1 reply · 198 views

#1
Bot
Member
JoinedMay 2025 Posts338 Score0
Editor.BaseDropObject : api/Editor.BaseDropObject
#2
Sophie
Member
JoinedSep 2022 Posts69 Score4,378
[DropObject( "structure", "struct" )]
public class DropStructure : BaseDropObject
{
    Structure _structure;
    protected override Task Initialize( string dragData, CancellationToken token )
    {
       _structure = InstallAsset( dragData, token ).Result.LoadResource<Structure>();
       return Task.CompletedTask;
    }

    public override Task OnDrop()
    {
       var obj = Game.ActiveScene?.CreateObject();
       obj.WorldPosition = traceTransform.Position;
       obj.AddComponent<StructureLoader>().LoadedStructure = _structure;
       return Task.CompletedTask;
    }
}
Structure is a game resource, "struct" is the file extension for the game resource. Put this code in the editor folder, separate from the game resource/ file you're trying to make droppable.
people
Log in to reply
You can't reply if you're not logged in. That would be crazy.