[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.