Compare commits

..

No commits in common. "4ef4a96f74ac278ce42aec5d68c9a9e3758e2895" and "d3f466d3c4a92844d1e3ec31c1ad8b401c37822e" have entirely different histories.

17 changed files with 23 additions and 358 deletions

View File

@ -1,47 +0,0 @@
env:
SUBFOLDER: docs_website
name: Publish Docs to docs.velconnect.ugavel.com (Cloudflare Pages)
on:
push:
paths:
- docs_website/**
jobs:
publish-docs:
defaults:
run:
working-directory: ${{env.SUBFOLDER}}
runs-on: ubuntu-latest
permissions:
contents: read
deployments: write
name: Publish to Cloudflare Pages
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.x
- run: echo "CACHE_ID=$(date --utc '+%V')" >> $GITHUB_ENV
- uses: actions/cache@v3
with:
key: mkdocs-material-${{ env.CACHE_ID }}
path: .cache
restore-keys: |
mkdocs-material-
- run: pip install -r requirements.txt
- name: Build
run: mkdocs build --site-dir public
- name: Upload
env:
PROJECT_NAME: velconnect-docs
CLOUDFLARE_ACCOUNT_ID: 8077b5b1f8e2ade41874cbaa3f883069
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
run: npx wrangler@3.1.1 pages deploy public --project-name="${{env.PROJECT_NAME}}" --branch="${{env.GITHUB_REF_NAME}}"

View File

@ -1,4 +0,0 @@
env/
public/
site/
.venv/

View File

@ -1,10 +0,0 @@
{
"configurations": [
{
"name": "Serve Docs",
"type": "node-terminal",
"request": "launch",
"command": "mkdocs serve"
}
]
}

View File

@ -1,3 +0,0 @@
{
"python.terminal.activateEnvironment": true,
}

View File

@ -1,17 +0,0 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Autogenerate docs from code",
"detail": "Runs generate_docs.py",
"command": "python generate_docs.py",
"type": "shell",
"args": [],
"problemMatcher": [],
"presentation": {
"reveal": "always"
},
"group": "build"
}
]
}

View File

@ -1,19 +0,0 @@
# VEL-Connect Docs
## Setup
1. Create or activate a pip environment
- Create:
- `python -m venv env`
- Activate:
- PowerShell: `.\env\Scripts\Activate.ps1`
- CMD: `.\env\Scripts\Activate.bat`
2. Install requirements:
- `pip install -r requirements.txt`
3. Run:
- `mkdocs serve`
- or use `F5` in VSCode
4. Build and Deploy
- Building and deploying happens automatically using a GitHub Action on push. If you want to build manually, use this command:
- `mkdocs build`
- For more information, visit these docs pages: https://squidfunk.github.io/mkdocs-material/getting-started/

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 659 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 108 KiB

View File

@ -1,8 +0,0 @@
# VEL-Connect
VEL-Connect is a persistent shared storage mechanism for Unity projects. It can be used as a key-value store as a networked replacement for PlayerPrefs, to share a profile of user data across multiple devices, or to easily switch between different user profiles on a single device.
Important pages:
- [Installation](/installation)
- [Quick Start](/quick-start)

View File

@ -1,40 +0,0 @@
Install the UPM package in Unity:
=== "**Option 1:** Add the VEL package registry"
![Scoped registry example](assets/screenshots/scoped_registry.png){ align=right }
Using the scoped registry allows you to easily install a specific version of the package by using the Version History tab.
- In Unity, go to `Edit->Project Settings...->Package Manager`
- Under "Scoped Registries" click the + icon
- Add the following details, then click Apply
- Name: `VEL` (or anything you want)
- URL: `https://npm.ugavel.com`
- Scope(s): `edu.uga.engr.vel`
- Install the package:
- In the package manager, select `My Registries` from the dropdown
- Install the `VEL-Connect` package.
=== "**Option 2:** Add the package by git url"
1. Open the Package Manager in Unity with `Window->Package Manager`
- Add the local package:
- `+`->`Add package from git URL...`
- Set the path to `https://github.com/velaboratory/VEL-Connect`
To update the package, click the `Update` button in the Package Manager, or delete the `packages-lock.json` file.
=== "**Option 3:** Add the package locally"
1. Clone the repository on your computer:
`git clone git@github.com:velaboratory/VEL-Connect.git`
- Open the Package Manager in Unity with `Window->Package Manager`
- Add the local package:
- `+`->`Add package from disk...`
- Set the path to `VEL-Connect/package.json` on your hard drive.
To update the package, use `git pull` in the VEL-Connect folder.
Then check out the [quick start guide](quick-start.md).

View File

@ -1,107 +0,0 @@
---
title: Quick Start
---
## Setup
1. [Install the package](/)
2. Add the VelConnectManager script to an object in your scene. If you transition between scenes in your application, mark the object as `DontDestroyOnLoad`
3. Set the `Vel Connect Url` field on the component to a valid velconnect server. `https://velconnect-v4.ugavel.com` is useful for VEL projects.
## Usage
### Setting data
To set user data in VEL-Connect use the static function `SetUserData`.
You can add a single key and value:
```cs
VELConnectManager.SetUserData("key1", "val1");
```
Or set multiple keys with the dictionary syntax:
```cs
VELConnectManager.SetUserData(new Dictionary<string, string>
{
{ "key2", "val2" },
{ "key3", "val3" }
});
```
Data will be set instantly locally, then pushed to the server. You don't have to wait for VEL-Connect to initialize at the beginning of your game to set data.
### Getting data
Fetching data from a remote server can be more tricky because it won't be available immediately when the game starts. Data can also be set from other applications (such as a dashboard or other users in the case of room data), so change listeners are useful.
To fetch a single value from a key:
```cs
string value1 = VELConnectManager.GetUserData("key1");
```
The latest local value will be returned. This will always return null in `Start()` because no data has been fetched yet, so you could wrap this call in the `OnInitialState` callback:
```cs
VELConnectManager.OnInitialState += state =>
{
VELConnectManager.GetUserData("key1");
};
```
If the data was already on the server before the start of your application, the correct value will be returned.
#### Change listeners
If you want to subscribe to changes in a key you can set up change listeners:
```cs
VELConnectManager.AddUserDataListener("key1", this, value =>
{
Debug.Log($"key1: {value}");
}, true);
```
Passing in `this` binds the lifetime of the listener to the lifetime of the current script. It is often tedious to make sure to unsubscribe to all of your listeners OnDisable or OnDestroy to prevent the event emitter from sending events to objects that no longer exist, but VEL-Connect will remove listeners when their `keepAliveObject` parameter becomes null. The last parameter in this function (`true` in the example) tells VEL-Connect to activate the callback immediately or when the first value is received. You can add the listener on `Start()` and the first invokation of the callback will have the previous value of the server.
---
Full example:
```cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using VELConnect;
public class VELConnectTesting : MonoBehaviour
{
private IEnumerator Start()
{
VELConnectManager.OnInitialState += state =>
{
Debug.Log($"[OnInitialState] key1: {VELConnectManager.GetUserData("key1")}");
};
VELConnectManager.AddUserDataListener("key1", this, value =>
{
Debug.Log($"[Listener] key1: {value}");
}, true);
VELConnectManager.AddUserDataListener("key2", this, value =>
{
Debug.Log($"[Listener] key2: {value}");
}, false);
yield return new WaitForSeconds(1f);
VELConnectManager.SetUserData("key1", "val1");
VELConnectManager.SetUserData(new Dictionary<string, string>
{
{ "key1", "val1" },
{ "key2", "val2" },
});
yield return new WaitForSeconds(1f);
VELConnectManager.SetUserData("key1", "val1_later");
}
}
```

View File

@ -1,17 +0,0 @@
:root {
--md-primary-fg-color: #7a2020;
--md-primary-fg-color--light: #ffffff;
--md-primary-fg-color--dark: #e4002b;
--md-primary-bg-color: hsla(0, 0%, 100%, 1);
--md-primary-bg-color--light: hsla(0, 0%, 100%, 0.7);
/* --md-accent-fg-color: #ffffff;
--md-accent-fg-color--transparent: #ffffff11;
--md-accent-bg-color: hsla(0, 0%, 100%, 1);
--md-accent-bg-color--light: hsla(0, 0%, 100%, 0.7); */
}
[data-md-color-scheme="slate"] {
--md-hue: 34;
--md-default-bg-color: #191818;
--md-code-bg-color: #252525;
}

View File

@ -1,59 +0,0 @@
site_name: VEL-Connect Docs
site_url: https://docs.velconnect.ugavel.com
repo_url: https://github.com/velaboratory/VEL-Connect
repo_name: velaboratory/VEL-Connect
edit_uri: edit/main/docs_website/docs
theme:
name: material
features:
- content.action.edit
- navigation.instant
# - navigation.sections
- navigation.expand
- navigation.path
- navigation.indexes
- toc.follow
- toc.integrate
- content.code.copy
palette:
scheme: slate
primary: custom
accent: red
# background: custom
font: false
# text: Oswald
# text: Merriweather
# text: Merriweather Sans
logo: assets/vel_logo_3d.png
favicon: assets/vel_logo_3d_square.png
plugins:
- search:
# - social:
# cards_layout_options:
# font_family: Oswald
- git-revision-date-localized:
enable_creation_date: true
markdown_extensions:
- attr_list
- md_in_html
- pymdownx.emoji:
emoji_index: !!python/name:material.extensions.emoji.twemoji
emoji_generator: !!python/name:material.extensions.emoji.to_svg
- pymdownx.superfences
- pymdownx.tabbed:
alternate_style: true
- admonition
- pymdownx.details
- pymdownx.highlight:
anchor_linenums: true
line_spans: __span
pygments_lang_class: true
- pymdownx.inlinehilite
- pymdownx.snippets
extra_css:
- stylesheets/extra.css

View File

@ -1,2 +0,0 @@
mkdocs-material
mkdocs-git-revision-date-localized-plugin

View File

@ -171,7 +171,6 @@ namespace VELConnect
private void Awake() private void Awake()
{ {
velConnectUrl = velConnectUrl.TrimEnd('/');
if (instance != null) Debug.LogError("VELConnectManager instance already exists", this); if (instance != null) Debug.LogError("VELConnectManager instance already exists", this);
instance = this; instance = this;
deviceId = CreateDeviceId(); deviceId = CreateDeviceId();
@ -260,8 +259,27 @@ namespace VELConnect
{ {
state = JsonConvert.DeserializeObject<State>(json); state = JsonConvert.DeserializeObject<State>(json);
if (state == null) return; if (state == null) return;
if (state.room == null) return;
bool isInitialState = false;
// first load stuff
if (lastState == null)
{
try
{
OnInitialState?.Invoke(state);
}
catch (Exception e)
{
Debug.LogError(e);
}
isInitialState = true;
// lastState = state;
// return;
}
bool isInitialState = lastState == null;
// if (state.device.modified_by != DeviceId) // if (state.device.modified_by != DeviceId)
{ {
@ -387,7 +405,7 @@ namespace VELConnect
} }
// if (state.room.modified_by != DeviceId && state.room.data != null) // if (state.room.modified_by != DeviceId && state.room.data != null)
if (state.room?.data != null) if (state.room.data != null)
{ {
foreach (KeyValuePair<string, string> elem in state.room.data) foreach (KeyValuePair<string, string> elem in state.room.data)
{ {
@ -461,18 +479,6 @@ namespace VELConnect
{ {
Debug.LogError("Pairing code nulllll"); Debug.LogError("Pairing code nulllll");
} }
if (isInitialState)
{
try
{
OnInitialState?.Invoke(state);
}
catch (Exception e)
{
Debug.LogError(e);
}
}
}); });
} }
catch (Exception e) catch (Exception e)
@ -680,11 +686,6 @@ namespace VELConnect
); );
} }
public static void SetUserData(string key, string value)
{
SetUserData(new Dictionary<string, string> { { key, value } });
}
/// <summary> /// <summary>
/// Sets the 'data' object of the Device table /// Sets the 'data' object of the Device table
/// </summary> /// </summary>
@ -792,9 +793,6 @@ namespace VELConnect
); );
} }
/// <summary>
/// Unpairs this device from the current user.
/// </summary>
public static void Unpair() public static void Unpair()
{ {
if (instance.state?.device != null) if (instance.state?.device != null)

View File

@ -1,7 +1,7 @@
{ {
"name": "edu.uga.engr.vel.vel-connect", "name": "edu.uga.engr.vel.vel-connect",
"displayName": "VEL-Connect", "displayName": "VEL-Connect",
"version": "4.0.7", "version": "4.0.5",
"unity": "2019.1", "unity": "2019.1",
"description": "Web-based configuration for VR applications", "description": "Web-based configuration for VR applications",
"keywords": [], "keywords": [],
@ -13,6 +13,6 @@
"samples": [], "samples": [],
"dependencies": { "dependencies": {
"com.unity.nuget.newtonsoft-json": "3.0.0", "com.unity.nuget.newtonsoft-json": "3.0.0",
"edu.uga.engr.vel.velnet": "1.3.8" "edu.uga.engr.vel.velnet": "1.1.8"
} }
} }