trophy 0
May 2025 20 posts
Editor.BaseDropObject : api/Editor.BaseDropObject
trophy 2958
Sep 2022 39 posts
[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.