Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ugc.Editor type #752

Open
ZhangHuan0407 opened this issue Jan 31, 2024 · 0 comments
Open

Ugc.Editor type #752

ZhangHuan0407 opened this issue Jan 31, 2024 · 0 comments
Assignees

Comments

@ZhangHuan0407
Copy link

ZhangHuan0407 commented Jan 31, 2024

Describe the bug
Ugc.Editor is struct, not class type.

The code in the example is executable, but it is not a C# best practice.

To Reproduce
use Calling Code

Calling Code
Steamworks.Ugc.Editor

// The code you're using to call into Steamworks

using UgcEditor = Steamworks.Ugc.Editor;
UgcEditor ugcEditor;
if (xxxFlag)
    ugcEditor = UgcEditor.NewCommunityFile;
ugcEditor.WithTitle(title)
         .WithDescription("This is a description")
         //.WithContent(modDirectory)
         .WithContent("C:\\Users\\xxxx\\AppData\\LocalLow\\Company\\AppName\\Mods\\test1");
ProgressView progress = xxx;
progress.BindView(xxx);
ugcEditor.SubmitAsync(progress, null);

Expected behavior

Desktop (please complete the following information):

  • OS: Windows11 64bit
  • Unity: Unity 2021.3

Additional context
Add any other context about the problem here.

  1. When I invoke Withxxx function, C# will copy this data with 13 fields, and changed one of them(for example title).We only need one instance instead of re-copying it every time
  2. This is Microsoft suggest https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/struct
    Because structure types have value semantics, we recommend you define immutable structure types.
  3. Generally speaking, chain calls is class not struct. For example, DoTween.Sequence, C# StringBuilder.

I try to provide two solutions:

  1. Please warm this in ReadMe "Publish your own file" block, because this chain calls is not common...orz
using UgcEditor = Steamworks.Ugc.Editor;

            var result = UgcEditor.NewCommunityFile
                  .WithTitle("My New FIle")
                  .WithDescription("This is a description")
                  .WithContent("C:\\Users\\xxxx\\AppData\\LocalLow\\Company\\AppName\\Mods\\test1")
                  .SubmitAsync(null, (PublishResult pr) =>
                  {
                      Debug.Log(pr.Result);
                  });

// UgcEditor is struct
var ugcEditor = UgcEditor.NewCommunityFile;
var ugcEditor2 = ugcEditor.WithContent("directory path here");
// ugcEditor is not equal ugcEditor2,
// call ugcEditor.SubmitAsync() is not equal ugcEditor2.SubmitAsync()
  1. Change type to class, not struct. Or rename Steamworks.Ugc.Editor with Steamworks.Ugc.EditorStruct

People who have been bothered by this issue for 24 hours leave a message here

Same question
#722

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants