@@ -70,6 +70,100 @@ methods:
7070 security : None
7171 thread_safety : Unsafe
7272 capabilities : []
73+ - name : AvatarCreationService:GenerateAvatar2DPreviewAsync
74+ summary : |
75+ Creates a 2D avatar preview and returns a previewId.
76+ description : |
77+ Creates a 2D avatar image preview, taking as input the FileId from
78+ `Class.AvatarCreationService:PromptSelectAvatarGenerationImageAsync()|PromptSelectAvatarGenerationImageAsync()`
79+ and an optional text prompt. It returns a previewId which can be passed to
80+ `Class.AvatarCreationService:LoadAvatar2DPreviewAsync()|LoadAvatar2DPreviewAsync()`
81+ to retrieve the preview image on the client. This API can only be used on
82+ the game server.
83+
84+ ```lua
85+ local AvatarCreationService = game:GetService("AvatarCreationService")
86+
87+ function generateAvatar2DPreview(sessionId, fileId, textPrompt)
88+ local pcallSuccess, result = pcall(function()
89+ local args = {}
90+ args.SessionId = sessionId
91+ args.FileId = fileId
92+ args.TextPrompt = textPrompt
93+ return AvatarCreationService:GenerateAvatar2DPreview(args)
94+ end)
95+
96+ if not pcallSuccess then
97+ warn("Generating 2D preview failed: ", result)
98+ end
99+
100+ return result
101+ end
102+ ```
103+ code_samples : []
104+ parameters :
105+ - name : avatarGeneration2dPreviewParams
106+ type : Dictionary
107+ default :
108+ summary : |
109+ A table of arguments for 2D preview generation. Type:
110+ `avatarGeneration2dPreviewParams: {SessionId: string, FileId: string, TextPrompt: string?}`
111+ returns :
112+ - type : string
113+ summary : |
114+ A string previewId
115+ tags :
116+ - Yields
117+ deprecation_message : ' '
118+ security : None
119+ thread_safety : Unsafe
120+ capabilities : []
121+ - name : AvatarCreationService:GenerateAvatarAsync
122+ summary : |
123+ Generates an avatar and returns a generationId.
124+ description : |
125+ Generate an avatar from a preview and return the generationId. The
126+ `Class.AvatarCreationService:LoadGeneratedAvatarAsync()|LoadGeneratedAvatarAsync()`
127+ method is then called to retrieve the generated
128+ `Class.HumanoidDescription` avatar. This API can only be used on the game
129+ server.
130+
131+ ```lua
132+ local AvatarCreationService = game:GetService("AvatarCreationService")
133+
134+ function generateAvatar(sessionId, previewId)
135+ local pcallSuccess, result = pcall(function()
136+ local args = {}
137+ args.SessionId = sessionId
138+ args.PreviewId = previewId
139+ return AvatarCreationService:GenerateAvatarAsync(args)
140+ end)
141+
142+ if not pcallSuccess then
143+ warn("Generating avatar failed: ", result)
144+ end
145+
146+ return result
147+ end
148+ ```
149+ code_samples : []
150+ parameters :
151+ - name : avatarGenerationParams
152+ type : Dictionary
153+ default :
154+ summary : |
155+ A table of arguments for generating an avatar. Type:
156+ `avatarGenerationParams: {SessionId: string, PreviewId: string}`
157+ returns :
158+ - type : string
159+ summary : |
160+ A string generationId.
161+ tags :
162+ - Yields
163+ deprecation_message : ' '
164+ security : None
165+ thread_safety : Unsafe
166+ capabilities : []
73167 - name : AvatarCreationService:GetBatchTokenDetailsAsync
74168 summary : |
75169 Gets the avatar creation token details for a list of avatar creation
@@ -265,12 +359,54 @@ methods:
265359 security : None
266360 thread_safety : Unsafe
267361 capabilities : []
362+ - name : AvatarCreationService:LoadAvatar2DPreviewAsync
363+ summary : |
364+ Load an AvatarGeneration 2D preview on the client from a previewId.
365+ description : |
366+ Load an AvatarGeneration 2D preview as an `Class.EditableImage` on the
367+ client for the given previewId. This API can only be used on the client.
368+
369+ ```lua
370+ local AvatarCreationService = game:GetService("AvatarCreationService")
371+
372+ function loadAvatar2DPreview(previewId)
373+ local pcallSuccess, result = pcall(function()
374+ return AvatarCreationService:LoadAvatar2DPreviewAsync(previewId)
375+ end)
376+
377+ if not pcallSuccess then
378+ warn("Failed to load preview: ", result)
379+ end
380+
381+ return result
382+ end
383+ ```
384+ code_samples : []
385+ parameters :
386+ - name : previewId
387+ type : string
388+ default :
389+ summary : |
390+ Load the preview generated from
391+ `Class.AvatarCreationService:GenerateAvatar2DPreviewAsync()|GenerateAvatar2DPreviewAsync()`.
392+ returns :
393+ - type : EditableImage
394+ summary : |
395+ An `Class.EditableImage` containing the preview image.
396+ tags :
397+ - Yields
398+ deprecation_message : ' '
399+ security : None
400+ thread_safety : Unsafe
401+ capabilities : []
268402 - name : AvatarCreationService:LoadGeneratedAvatarAsync
269403 summary : |
270404 Loads a generated avatar using an avatar generation ID.
271405 description : |
272406 Loads a generated avatar using an avatar generation ID, as returned by
273- `Class.AvatarCreationService:AutoSetupAvatarAsync()|AutoSetupAvatarAsync()`.
407+ `Class.AvatarCreationService:AutoSetupAvatarAsync()|AutoSetupAvatarAsync()`
408+ or
409+ `Class.AvatarCreationService:GenerateAvatarAsync()|GenerateAvatarAsync()`.
274410 The generated avatar will be returned as a `Class.HumanoidDescription`
275411 with all the generated instances and properties. Mesh and texture assets
276412 will be provided as `Class.EditableMesh` and `Class.EditableImage`
@@ -436,6 +572,117 @@ methods:
436572 security : None
437573 thread_safety : Unsafe
438574 capabilities : []
575+ - name : AvatarCreationService:PromptSelectAvatarGenerationImageAsync
576+ summary : |
577+ Prompt the `Class.Player` to take a selfie and return the FileId.
578+ description : |
579+ Prompt the `Class.Player` to take a selfie and return the FileId of the
580+ selfie. This FileId is then passed as an argument to
581+ `Class.AvatarCreationService:GenerateAvatar2DPreviewAsync()|GenerateAvatar2DPreviewAsync()`.
582+ This API can only be used on the game server.
583+
584+ ```lua
585+ local AvatarCreationService = game:GetService("AvatarCreationService")
586+
587+ function promptSelectAvatarGenerationImage(player)
588+ local pcallSuccess, result = pcall(function()
589+ return AvatarCreationService:PromptSelectAvatarGenerationImageAsync(player)
590+ end)
591+
592+ if not pcallSuccess then
593+ warn("Failed to prompt for image: ", result)
594+ end
595+
596+ return result
597+ end
598+ ```
599+ code_samples : []
600+ parameters :
601+ - name : player
602+ type : Player
603+ default :
604+ summary : |
605+ The `Class.Player` to prompt for taking a selfie.
606+ returns :
607+ - type : string
608+ summary : |
609+ A string FileId of the selfie.
610+ tags :
611+ - Yields
612+ deprecation_message : ' '
613+ security : None
614+ thread_safety : Unsafe
615+ capabilities : []
616+ - name : AvatarCreationService:RequestAvatarGenerationSessionAsync
617+ summary : |
618+ Request an AvatarGeneration session for a `Class.Player`.
619+ description : |
620+ Request an AvatarGeneration session for a `Class.Player`. Information
621+ about the session is returned via the callback, including the SessionId
622+ which is passed to the
623+ `Class.AvatarCreationService:GenerateAvatar2DPreviewAsync()|GenerateAvatar2DPreviewAsync()`
624+ and
625+ `Class.AvatarCreationService:GenerateAvatarAsync()|GenerateAvatarAsync()`
626+ methods. Additional session information includes allowed 2d preview
627+ generations, allowed 3d avatar generations, and the session time. The
628+ method returns a `Tuple` with an `Datatype.RBXScriptConnection` and
629+ estimated `waitTime`. The `Datatype.RBXScriptConnection` allows canceling
630+ a session request. The estimated `waitTime` is used to provide the player
631+ an estimated time in seconds until the session will be ready. This API can
632+ only be used on the game server.
633+
634+ ```lua
635+ local AvatarCreationService = game:GetService("AvatarCreationService")
636+ local playerSessions = {}
637+ local playerSessionRequests = {}
638+
639+ function requestAvatarGenerationSession(player)
640+ local pcallSuccess, conn, waitTime = pcall(function()
641+ return AvatarCreationService:RequestAvatarGenerationSessionAsync(player, function(sessionInfo)
642+ playerSessions[player.UserID] = sessionInfo
643+ playerSessionRequests[player.UserID] = nil
644+ end)
645+ end)
646+
647+ if not pcallSuccess then
648+ warn("Failed to request Avatar generation session: ", conn)
649+ end
650+
651+ playerSessionRequests[player.UserID] = conn
652+ print("Wait time for session: ", tostring(waitTime))
653+ end
654+
655+ function cancelAvatarGenerationSessionRequest(player)
656+ if playerSessionRequests[player.UserID] ~= nil then
657+ playerSessionRequests[player.UserID]:Disconnect()
658+ end
659+ end
660+ ```
661+ code_samples : []
662+ parameters :
663+ - name : player
664+ type : Player
665+ default :
666+ summary : |
667+ The `Class.Player` to request an AvatarGeneration session for.
668+ - name : callback
669+ type : Function
670+ default :
671+ summary : |
672+ Callback function that is invoked with a SessionInfo table, with
673+ information about the session. Type:
674+ `(SessionInfo: { SessionId: string, Allowed2DGenerations: number, Allowed3DGenerations: number, SessionTime: number }) -> ()`
675+ returns :
676+ - type : Tuple
677+ summary : |
678+ A tuple containing a `Datatype.RBXScriptConnection` that can be used
679+ to cancel the session request and the estimated wait time in seconds.
680+ tags :
681+ - Yields
682+ deprecation_message : ' '
683+ security : None
684+ thread_safety : Unsafe
685+ capabilities : []
439686 - name : AvatarCreationService:ValidateUGCAccessoryAsync
440687 summary : |
441688 Studio only. Runs UGC validation for an `Enum.AccessoryType`.
0 commit comments