Revision Difference
Creating_Workshop_Items#523920
<cat>code.workshop</cat>⤶
<title>Creating Workshop Items</title>⤶
⤶
# Creating An Item⤶
⤶
Creating an item is pretty straight forward.⤶
⤶
```⤶
var result = await Ugc.Editor.NewCommunityFile⤶
.WithTitle( "My New Item" )⤶
.WithDescription( itemDescription )⤶
.WithTag( "Map" )⤶
.SubmitAsync();⤶
```⤶
⤶
# Uploading An Item⤶
⤶
The previous example doesn't include any files with the item. To do that we use <page>Ugc.Editor.WithContent</page>.⤶
⤶
This will upload the contents of that folder as your entry.⤶
⤶
```⤶
var result = await Ugc.Editor.NewCommunityFile⤶
.WithTitle( "My New Item" )⤶
.WithDescription( itemDescription )⤶
.WithTag( "Map" )⤶
.WithContent( pathToFolder )⤶
.SubmitAsync();⤶
```⤶
⤶
# Showing Progress ⤶
⤶
⤶
The submit function <page>Ugc.Editor.SubmitAsync</page> takes an optional parameter of a IProgress<float>.⤶
⤶
You should be able to use this to show some progress.⤶
⤶
⤶
```⤶
⤶
class ProgressClass : IProgress<float>⤶
{⤶
float lastvalue = 0;⤶
⤶
public void Report( float value )⤶
{⤶
if ( lastvalue >= value ) return;⤶
⤶
lastvalue = value;⤶
⤶
Console.WriteLine( value );⤶
}⤶
}⤶
⤶
...⤶
⤶
var result = await Ugc.Editor.NewCommunityFile⤶
.WithTitle( "My New Item" )⤶
.WithDescription( itemDescription )⤶
.WithTag( "Map" )⤶
.WithContent( pathToFolder )⤶
.SubmitAsync( new ProgressClass() );⤶
```⤶
⤶