Skip to content

Commit

Permalink
Merge branch 'master' into DocsTeam-CCK-Rewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
loliwut committed Sep 5, 2024
2 parents f334fab + 2ce4eb9 commit a5937f9
Show file tree
Hide file tree
Showing 18 changed files with 274 additions and 37 deletions.
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,17 @@ Internal copy of our public docs.
1. `cd path/to/docs`
1. `poetry install --no-root`
1. `poetry shell`
1. `mkdocs serve`
1. `mkdocs serve`

## Contributing
- master is our production branch, means anything in master goes into the production site
- develop is our main development branch, merge your changes to here

For any changes, make a feature branch.
This means a branch named like `feature/add-cvravatar-feature-docs` with a reaonable short name of the changes you are doing there.
When you are done with your changes, merge them into develop.

### Releases
Making a release should be done by either a Development Head or DevOps Engineer.

For deploying to production merge develop into master, and grab the latest build artifact from teamcity after it has been built.
4 changes: 2 additions & 2 deletions _variables/cck.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"cck": {
"version": "v3.9 RELEASE",
"downloadUrl": "https://files.abidata.io/static_web/ChilloutVR%20CCK%20v3.9%20RELEASE.unitypackage"
"version": "v3.10 RELEASE",
"downloadUrl": "https://files.abidata.io/static_web/ChilloutVR%20CCK%20v3.10%20RELEASE.unitypackage"
},
"unity": {
"install": {
Expand Down
29 changes: 25 additions & 4 deletions docs/cck/lua/api/avatar-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ Accessible via the `AvatarAPI` [Global](globals.md). This API provides access to

## Static Functions

| Name | Description |
|--------------------------------------------------------|-----------------------------------------------------|
| `LocalAvatar : Avatar` <br>(Returns [Avatar](#avatar)) | Access the Local Player's Avatar instance reference |
| Name | Description |
|----------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------|
| `LocalAvatar : Avatar` <br>(Returns [Avatar](#avatar)) | Access the Local Player's Avatar instance reference |
| `CurrentAvatar : Avatar` <br>(Returns [Avatar](#avatar)) | Access the Script's Avatar instance reference (the avatar the script is running on). *This is only available on avatar scripts* |

## Avatar

Expand Down Expand Up @@ -47,4 +48,24 @@ The `Avatar` instances can be accessed via:
| `GetParameterAsBool(string parameterName) : bool` | Retrieves a boolean parameter from the animator. Returns nil if the parameter does not exist. |
| `GetParameterAsInt(string parameterName) : int` | Retrieves an integer parameter from the animator. Returns nil if the parameter does not exist. |
| `GetParameterAsFloat(string parameterName) : float` | Retrieves a float parameter from the animator. Returns nil if the parameter does not exist. |
| `SetParameter(string parameterName, bool/float/int parameterValue) : void` | Sets an animator parameter to a set value.<br/>Internally will cast to the type actually used by the Animator. |
| `SetParameter(string parameterName, bool/float/int parameterValue) : void` | Sets an animator parameter to a set value.<br/>Internally will cast to the type actually used by the Animator. |

### Avatar Picture

Requesting the picture is a bit more complicated as it needs to be acquired in the first place. So it's not a function
that will give the results right away. Instead, it uses a callback lua function, which is basically a normal lua
function that gets called whenever the request is finished.

For a complete example, check: [Player Profile and Avatar Picture Example](../examples/player-profile-picture.md)

#### Methods

| Name | Description |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------|
| `RequestImage(callback OnAvatarImage, bool castToTexture) : void`<br>&nbsp;&nbsp;- `#arg1` lua function for the [callback](#callbacks)<br>&nbsp;&nbsp;- `#arg2` *[Optional]* Whether to cast the Texture2D to Texture or not. | Sends a request to fetch the Player Avatar's picture as a Texture2D or as a Texture. |

#### Callbacks

| Name | Description |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------|
| `OnAvatarImage(Texture2D/Texture texture, string avatarID) : void`<br>&nbsp;&nbsp;- `#arg1` The Texture/Texture2D reference for the avatar's image<br>&nbsp;&nbsp;- `#arg2` *[Optional]* The Avatar's ID the image belongs to | Gets called when `RequestImage` finished and is sending the results |
22 changes: 11 additions & 11 deletions docs/cck/lua/api/lua-behaviour.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ This entity inherits from MonoBehaviour, as such inherits some of its members.
### Properties

| Name | Description |
| ---------------------------- | -------------------------------------------------- |
|------------------------------|----------------------------------------------------|
| `Hash` : string | SHA512 hash of script text as Base64 string |
| `TypeLabel` : string | Returns the script type label |
| `ScriptName` : string | Name of the script asset |
| `IsScriptInitialized` : bool | Whether this script instance is initialized or not |

### Methods

| Method | Description |
| --------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
| `Crash(string)` : void | Crashes the script preventing stopping it's execution (the behaviour still exists) |
| `Destroy(string)` : void | Destroys the script, while actually getting rid of the behavior |
| `CallReceiverFunction(string name, anything[] args) : void`<br> | Call a function on the LuaBehaviour with the name `RECEIVER_<name>` with the given list table as an argument. |
| `GetGlobalBoolean(string name) : boolean\|nil` | Get the given global boolean variable, or nil if it doesn't exist. |
| `GetGlobalNumber(string name) : number\|nil` | Get the given global number variable, or nil if it doesn't exist. |
| `GetGlobalString(string name) : string\|nil` | Get the given global string variable, or nil if it doesn't exist. |
| `GetGlobalTable(string name) : Table\|nil` | Get the given global table variable, or nil if it doesn't exist. |
| `GetGlobals() : Table` | Get a table of all the globals in the script. |
| Method | Description |
|---------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `Crash(string)` : void | Crashes the script preventing stopping it's execution (the behaviour still exists) |
| `Destroy(string)` : void | Destroys the script, while actually getting rid of the behavior |
| `CallGlobalFunction(string name, arg1, arg2, ...) : value\|nil`<br> | Call a global function on the LuaBehaviour with the name provided. You can send as many arguments as you want (or even none).<br>This can used to call global functions on other scripts<br>Note: If you don't want other scripts from calling your script's functions, make them Local |
| `GetGlobalBoolean(string name) : boolean\|nil` | Get the given global boolean variable, or nil if it doesn't exist. |
| `GetGlobalNumber(string name) : number\|nil` | Get the given global number variable, or nil if it doesn't exist. |
| `GetGlobalString(string name) : string\|nil` | Get the given global string variable, or nil if it doesn't exist. |
| `GetGlobalTable(string name) : Table\|nil` | Get the given global table variable, or nil if it doesn't exist. |
| `GetGlobals() : Table` | Get a table of all the globals in the script. |
33 changes: 29 additions & 4 deletions docs/cck/lua/api/player-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,41 @@ The viseme index values are mapped as follows:
| `GetGravity() : Vector3` | Current gravity vector affecting the player. |
| `GetGravityDirection() : Vector3` | Direction of the gravity affecting the player. |

### Profile Picture

Requesting the picture is a bit more complicated as it needs to be acquired in the first place. So it's not a function
that will give the results right away. Instead, it uses a callback lua function, which is basically a normal lua
function that gets called whenever the request is finished.

For a complete example, check: [Player Profile and Avatar Picture Example](../examples/player-profile-picture.md)

#### Methods

| Name | Description |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------|
| `RequestProfileImage(callback OnProfileImage, bool castToTexture) : void`<br>&nbsp;&nbsp;- `#arg1` lua function for the [callback](#callbacks)<br>&nbsp;&nbsp;- `#arg2` *[Optional]* Whether to cast the Texture2D to Texture or not. | Sends a request to fetch the Player's profile picture as a Texture2D or as a Texture. |

#### Callbacks

| Name | Description |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------|
| `OnProfileImage(Texture2D/Texture texture, string userID) : void`<br>&nbsp;&nbsp;- `#arg1` The Texture/Texture2D reference for the player image<br>&nbsp;&nbsp;- `#arg2` *[Optional]* The Player's UserID the image belongs to | Gets called when `RequestProfileImage` finished and is sending the results |

## Remote Player

Functions and properties specific to remote players.

### Properties

| Name | Description |
|-------------------------------|---------------------------------------------------------|
| `NameplatePosition : Vector3` | Position of the remote player's nameplate in the world. |
| `IsNameplateActive : bool` | Indicates whether the nameplate is active or not. |
| Name | Description |
|------------------------------------|---------------------------------------------------------|
| `IsNameplateActive : bool` | Indicates whether the nameplate is active or not. |

### Methods

| Name | Description |
|------------------------------------|-----------------------------------------------------------------|
| `GetNameplatePosition() : Vector3` | Get the Position of the remote player's nameplate in the world. |

## Local Player

Expand Down
5 changes: 5 additions & 0 deletions docs/cck/lua/changelog/r176ex4-r176ex5.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,8 @@

### [PlayerAPI](../api/player-api.md)
- Added `IsUsingVR` to [Local Player Properties](../api/player-api.md#properties_2)
- Added `RequestProfileImage` to [Player Profile Picture](../api/player-api.md#profile-picture)

### [AvatarAPI](../api/avatar-api.md)
- Added `CurrentAvatar` to [Avatar API Static Functions](../api/avatar-api.md#static-functions)
- Added `RequestImage` to [Avatar Picture](../api/avatar-api.md#avatar-picture)
1 change: 1 addition & 0 deletions docs/cck/lua/examples/.pages
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ nav:
- index.md
- funny-cube.md
- instances-disable-go-in-home.md
- player-profile-picture.md
- player-thumbs-up-launch.md
- player-teleport-away-from-water.md
- viewpoint-raycast.md
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/cck/lua/examples/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ Here are some example scripts that can be used as an example to learn about Lua.
* [Teleport from Water](player-teleport-away-from-water.md) - Teleport when fully immersed in water.
* [Thumbs Up Player Launcher](player-thumbs-up-launch.md) - Launch upward when doing 2x thumbs up gesture.
* [Viewpoint Raycast](viewpoint-raycast.md) - Perform a raycast from the player's viewpoint.
* [Player Profile / Avatar Picture](player-profile-picture.md) - Get Player Profile and Avatar pictures.
72 changes: 72 additions & 0 deletions docs/cck/lua/examples/player-profile-picture.md
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
```
3 changes: 2 additions & 1 deletion docs/cck/lua/recipes/.pages
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ title: Recipes
nav:
- index.md
- getting-users.md
- listen-game-events.md
- listen-game-events.md
- getting-components.md
Loading

0 comments on commit a5937f9

Please sign in to comment.