Facepunch.Steamworks icon indicating copy to clipboard operation
Facepunch.Steamworks copied to clipboard

Unsure how to get a valid UGC type for AttachUgc.

Open DrBeza opened this issue 4 years ago • 16 comments

Hi there,

Thanks for the great library. I have been stumped on how to use AttachUgc with a leaderboard for a day or so now and I am unable to work out from the documentation/issues history available.

I am creating a new UGC file using:

var res = await Editor.NewCommunityFile
    .WithTitle("some title")
    .WithMetaData("metadata string")
    .SubmitAsync();

My metadata will most likely be some JSON string. I am able to retrieve this UGC based on the FileId result:

var item = await SteamUGC.QueryFileAsync(res.FileId);

I cannot see anything on item that would allow me to get a Steamworks.Data.Ugc type.

There was a similar issue closed without any resolution - https://github.com/Facepunch/Facepunch.Steamworks/issues/360

Is there any examples of AttachUgc or have I missed something simple/fundemental?

Thanks

DrBeza avatar May 01 '20 14:05 DrBeza

You're right - I need to add these binds. How urgently do you need it?

garrynewman avatar May 07 '20 10:05 garrynewman

Not urgently I've parked this work for the moment. Thanks Garry.

DrBeza avatar May 07 '20 16:05 DrBeza

Looking for it as well ! Any ETA ?

Mat-Loz avatar Jul 10 '20 14:07 Mat-Loz

#488 allows you to Attach Workshop UGC to the LeaderboardEntry, however, doesn't #436 need to be implemented to actually attach a file to the Entry so that replays will function correctly?

I have tested trying to attach a UGCItem to the leaderboard item, instead of a SteamCloud file, and I've experienced intermittently working results. Replays are the last big feature I am looking to add to my game, so any info would be greatly appreciated!

ambid17 avatar Dec 08 '20 06:12 ambid17

@ambid17 have you tried using it? Creating workshop items with FileShare is an older method, when I was trying it and attaching to leaderboard scores it was nothing but it was buggy - couldn't make it work.

kamyker avatar Dec 25 '20 00:12 kamyker

@kamyker I did end up getting it to work! You can see my code here: https://github.com/CaosCreations/JumpingJax/blob/develop/Assets/Scripts/Steam/StatsManager.cs

relevant methods: SaveLevelCompletion(), and CreateNewGhostRun()

ambid17 avatar Jan 06 '21 20:01 ambid17

@kamyker I did end up getting it to work!

Nice, yes I'm using something similar but I was asking about FileShare :)

kamyker avatar Jan 07 '21 01:01 kamyker

@kamyker I didn't end up using FileShare, it didn't seem like a viable option

ambid17 avatar Jan 08 '21 22:01 ambid17

@ambid17 Thanks for the example, it's been really helpful!

I'm running into a problem I'm wondering if you've seen. Initially it seems like I can submit my score and attach a UGC item, then others can download that UGC item from the leaderboard entry later.

But after a bit of time, the LeaderboardEntry no longer has a valid UGC attached (it returns 0xfffffffffful for the fileId). I have no idea why this is happening, and I'm not sure if there's something odd going on like the file timing out/expiring or what. Did you run into anything like this?

I recently switched from having the UGC item created via NewCommunityFile and into a NewGameManagedFile (to try to address the above), but now I get failures on the upload. Were there any specific settings/permissions required to make NewGameManagedFile work?

hankditton avatar Sep 15 '21 16:09 hankditton

@hankditton Did you ever solve that issue of attached UGC turning into invalid file id? I might be having the same issue.

Everything was working just fine at first but now that I added a bigger number of new leaderboard entries to different leaderboards (>30), attaching ghost recordings to them, the next day leaderboard queries are returning an invalid value for the attached UGC for those new entries.

I also created the UGC file with NewGameManagedFile. I can still find the files with Steamworks.Ugc.Query.GameManagedItems using search text but Leaderboards are not linked to them anymore. It also seems queries don't always require exact match for the search text which partially invalidates the idea of searching for the file by unique id as title instead of using attached UGC from leaderboards. I can reupload the ghost recordings and reattach them, which seemingly fixes the issue, but I have no idea for how long, and why they got invalidated last time - or if the files will get deleted at some point as they are not attached to leaderboards.

Does anyone have any idea on what could be causing this or what should be done?

andefoo avatar Feb 23 '22 12:02 andefoo

@andefoo no, I didn't solve this issue but I implemented a work around that's working well. There's some details in this reddit thread, https://www.reddit.com/r/gamedev/comments/pphbhu/steamworks_leaderboard_question_vanishing_ugc. The tldr is I upload the replay file, break the file id into two ints and then manually add those ints to the details array on the leaderboard entry when the score is submitted. Then i can download a replay by reconstructing the fileid and downloading by id.

It is working great, and has the added benefit of always having a replay when a score is uploaded (vs having to add a score first then add the file later).

hankditton avatar Feb 23 '22 16:02 hankditton

Thank you for the information! So I assume you are not using the AttachUGC anymore so you don't have any idea what is causing that file id to be detached or if it is still happening to all entries?

But the files that you upload that way stay in the cloud forever even if they are not attached to leaderboards? Is there any way for players to delete them? Do you have any system to prevent leaking uploaded files? (For example, what happens if for some reason when making a leaderboard update deleting the old entry fails?)

But I will consider your system, it could be a good solution! I have another alternative also, since the name of the uploaded file is unique and encodes player and leaderboard name, so it would be possible find it by querying, too. Unfortunately, as mentioned above, the query sometimes returns non-exact matches, too. And, first making a query and then downloading the entry is of course slower than getting the file id directly from leaderboards.

andefoo avatar Feb 23 '22 18:02 andefoo

One more question to @hankditton or anyone else that might know the answer...

Are you sure AttachUGC is supposed to work with GameManagedItems or could it be so that you must use normal Workshop items? That would not be very nice, though, since they would then be visible in the web, too, I guess...

But anyway, it feels odd that a feature like this is so broken (or at least badly documented). I would assume there are lots of other games trying to use it, too.

andefoo avatar Feb 23 '22 19:02 andefoo

@garrynewman is there any chance that AttachUGC will be working in the near future?

Bialy123 avatar Jul 24 '22 10:07 Bialy123

But the files that you upload that way stay in the cloud forever even if they are not attached to leaderboards? Is there any way for players to delete them? Do you have any system to prevent leaking uploaded files? (For example, what happens if for some reason when making a leaderboard update deleting the old entry fails?)

@andefoo You should be able to avoid the "leaking files" issue by updating the existing leaderboard file rather than deleting it and uploading a new one.

But then, if your leaderboard entry submission fails (after updating the leaderboard file), it could leave the leaderboard entry with an invalid file / outdated entry info, or vice-versa if you did it the other way around. This isn't as big an issue as "leaking files" though, and easily fixed by re-submitting the score (or re-updating the file).

Note: I've not tested any of this yet, just going through and preparing my Steam implementations. Probably going to follow the method mentioned by hankditton for leaderboard file attachment.

Matsyir avatar Oct 03 '22 20:10 Matsyir

Hey, is this still being worked on @garrynewman ? I've just run into this issue myself today - tried using #488 but apparently it's been deleted? Got my replay system and everything working, I just can't do anything with it. I would super appreciate it if this was added!

JanMalitschek avatar Oct 20 '22 18:10 JanMalitschek