-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into DocsTeam-CCK-Rewrite
- Loading branch information
Showing
18 changed files
with
274 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# Player Profile Picture | ||
|
||
This is an example how we can request and use the player's profile and avatar's picture. | ||
|
||
All you need to do, is create 2 planes. One for the player's picture and the other for the player avatar's picture, and | ||
add their MeshRenderers as bound object. | ||
|
||
Note: You need to add the components directly, if you add the gameObjects you need to call the GetComponent on the | ||
gameObject to get the mesh renderer reference. Notice on the image, it shows the icon of a MeshRenderer component and | ||
not the gameObject. | ||
|
||
![player-profile-cck.png](images/player-profile-cck.png) | ||
|
||
```lua | ||
UnityEngine = require "UnityEngine" | ||
|
||
function Start() | ||
|
||
-- Get the references to the mesh rendereres | ||
local playerMeshRenderer = BoundObjects.playerMeshRenderer | ||
local avatarMeshRenderer = BoundObjects.avatarMeshRenderer | ||
|
||
-- We're going to use the local player | ||
local player = PlayerAPI.LocalPlayer | ||
|
||
-- Request the profile picture image for the player | ||
print("Requesting the player's profile image for player " .. player.UserID) | ||
player.RequestProfileImage(function(texture) | ||
-- Call the GetProfileImage while wrapping the function in a local create function | ||
-- so we can send some additional context (the player's reference, and the mesh renderer) | ||
OnPlayerProfileImage(texture, player, playerMeshRenderer) | ||
end, true) | ||
|
||
-- If the player has the avatar loaded, request the current avatar image for the player | ||
if player.Avatar.IsLoaded then | ||
print("Requesting the avatar's profile image for avatar " .. player.Avatar.AvatarID) | ||
-- Call the GetProfileImage while wrapping the function in a local create function | ||
-- so we can send some additional context (the player's avatar reference, and the mesh renderer) | ||
player.Avatar.RequestImage(function(texture) | ||
OnAvatarImage(texture, player.Avatar, avatarMeshRenderer) | ||
end, true) | ||
end | ||
end | ||
|
||
function OnPlayerProfileImage(texture, player, playerMeshRenderer) | ||
print("Received the Player Profile Image for user " .. player.UserID .. "! " .. tostring(texture)) | ||
if texture == nil then | ||
print("Unfortunately it was nil :(") | ||
return | ||
end | ||
-- Get the current material on the meshrenderer and set the texture | ||
-- The material SetTexture requires a Texture instance, and not Texture2D | ||
-- which is why we called GetProfileImage with the second arg true, so the | ||
-- texture is returned as a Texture instead of Texture2D | ||
local materialInstance = playerMeshRenderer.material | ||
materialInstance.SetTexture("_MainTex", texture) | ||
end | ||
|
||
function OnAvatarImage(texture, avatar, avatarMeshRenderer) | ||
print("Received the Avatar Profile Image for avatar " .. avatar.AvatarID .. "! " .. tostring(texture)) | ||
if texture == nil then | ||
print("Unfortunately it was nil :(") | ||
return | ||
end | ||
-- Get the current material on the meshrenderer and set the texture | ||
-- The material SetTexture requires a Texture instance, and not Texture2D | ||
-- which is why we called GetProfileImage with the second arg true, so the | ||
-- texture is returned as a Texture instead of Texture2D | ||
local materialInstance = avatarMeshRenderer.material | ||
materialInstance.SetTexture("_MainTex", texture) | ||
end | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.