Skip to content

Commit

Permalink
Merge pull request #3 from namark/improved-package-structure
Browse files Browse the repository at this point in the history
General project structure improvements.
  • Loading branch information
digisomni authored May 3, 2022
2 parents 31a6673 + d92b5da commit beabcb9
Show file tree
Hide file tree
Showing 45 changed files with 1,593 additions and 66 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ ExportedObj/

# Unity3D generated file on crash reports
sysinfo.txt
*.blob

# Builds
*.apk
Expand Down Expand Up @@ -79,3 +80,9 @@ unity-test-result.xml
# Documetation
/docs/html
/docs/latex

# Generated Package Samples
Packages/com.vircadia.unitysdk/Samples~

# Generated Package Archive
com.vircadia.unitysdk.tgz
8 changes: 8 additions & 0 deletions Assets/Samples.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Assets/Samples/DomainServerConnection.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Assets/Samples/DomainServerConnection/Assets.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -132,26 +132,14 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 109466086}
- component: {fileID: 109466085}
- component: {fileID: 109466087}
m_Layer: 0
m_Name: TestObject
m_Name: DomainServerConnection
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &109466085
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 109466084}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 02c931a2692ea65dfbe451306c62a2c0, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!4 &109466086
Transform:
m_ObjectHideFlags: 0
Expand All @@ -167,6 +155,21 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &109466087
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 109466084}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6836185efaef599018378d9d33bdc8f6, type: 3}
m_Name:
m_EditorClassIdentifier:
location: localhost
applicationInfo:
domain:
--- !u!1 &778838313
GameObject:
m_ObjectHideFlags: 0
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
//
// DomainServerConnectionScript.cs
// Samples/DomainServerConnection
//
// Created by Nshan G. on 03 Mar 2022.
// Copyright 2022 Vircadia contributors.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[System.Serializable]
public class ApplicationInfo
{

private string _name;
public string name
{
get { return _name ?? Application.productName; }
set { _name = value; }
}

private string _organization;
public string organization
{
get { return _organization ?? Application.companyName; }
set { _organization = value; }
}

public string domain;

private string _version;
public string version
{
get { return _version ?? Application.version; }
set { _version = value; }
}
}

[System.Serializable]
public struct MessageData
{
public string displayName;
public string message;
public string type;
public string channel;
}

public class DomainServerConnectionScript : MonoBehaviour
{
private Vircadia.DomainServer _domainServer;
private bool _connected = false;
private int _nodesSeen = 0;
private bool _testMessageSent = false;
private bool _messagesMixerActive = false;

public string location = "localhost";
public ApplicationInfo applicationInfo;

void Start()
{
Debug.Log("Vircadia SDK native API version: " + Vircadia.Info.NativeVersion().full);

_domainServer = new Vircadia.DomainServer(
appName: applicationInfo.name,
appOrganization: applicationInfo.organization,
appDomain: applicationInfo.domain,
appVersion: applicationInfo.version);

if (!string.IsNullOrEmpty(location))
{
_domainServer.Connect(location);
_domainServer.Messages.Enable(Vircadia.MessageType.Text);
_domainServer.Messages.Subscribe("Chat");
}
}

void FixedUpdate()
{
if (!_connected)
{
Debug.Log("[vircadia-unity-example] Connecting");
if (_domainServer.Status == Vircadia.DomainServerStatus.Connected)
{
Debug.Log("[vircadia-unity-example] Successfully connected to " + location);
_connected = true;
}
}
else
{
var nodes = _domainServer.Nodes;
if (nodes.Length != _nodesSeen)
{
Debug.Log("[vircadia-unity-example] Updated node list:");
foreach (var node in nodes)
{
Debug.Log("[vircadia-unity-example] UUID: " + node.uuid.ToString());
Debug.Log("[vircadia-unity-example] Type: " + node.type.ToString());
Debug.Log("[vircadia-unity-example] Active: " + node.active.ToString());
Debug.Log("[vircadia-unity-example]");
}
_nodesSeen = nodes.Length;
}

if (!_messagesMixerActive)
{
foreach (var node in nodes)
{
if (node.type == Vircadia.NodeType.MessagesMixer)
{
_messagesMixerActive = node.active;
}
}
}


if (!_testMessageSent && _messagesMixerActive)
{
_domainServer.Messages.SendTextMessage("Chat", JsonUtility.ToJson(new MessageData{
displayName = "Unity SDK Example",
message = "This is Vircadia Unity SDK example speaking.",
channel = "Domain",
type = "TransmitChatMessage"
}));
_testMessageSent = true;
}

_domainServer.Messages.Update();

foreach (var message in _domainServer.Messages.TextMessages)
{
var data = JsonUtility.FromJson<MessageData>(message.Text);
Debug.Log("[vircadia-unity-example] Received a chat message: \n" +
" Sender UUID: " + message.Sender.ToString() + "\n" +
" Display Name: " + data.displayName + "\n" +
" Channel: " + data.channel + "\n" +
" Type: " + data.type + "\n" +
" Text: " + data.message + "\n");
}

}
}

void OnDestroy()
{
_domainServer.Destroy();
}

}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 0 additions & 24 deletions Assets/TestScript.cs

This file was deleted.

10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## Version 2022.0.1

### Features
* Domain Server connection and node enumeration.
* Sending and receiving messages using the message mixer.
* A simple example script.

### Developer Features
* Project setup as an embedded UPM package.
* A Makefile to support automation and UPM package creation.
18 changes: 15 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
TEST_RESULT = unity-test-result.xml
PACKAGE = com.vircadia.unitysdk.tar.gz
PACKAGE = com.vircadia.unitysdk.tgz
BUILDDIR = ./build

UNITY3D = $(UNITY3D_PATH)/Editor/Unity

build:
$(UNITY3D) -batchmode -nographics -quit -buildLinux64Player "$(BUILDDIR)/app" -logfile -

run:
cd $(BUILDDIR); ./app -screen-fullscreen 0 -screen-height 600 -screen-width 800 -logfile -

debug:
$(UNITY3D) -runTests -batchmode -nographics -testPlatform playmode -testResults $(TEST_RESULT) -logfile -

Expand All @@ -14,7 +21,9 @@ test:
@echo Complete.

package: test
tar --xform s:'./':: -czvf $(PACKAGE) -C ./Packages/com.vircadia.unitysdk ./
-rm -r Packages/com.vircadia.unitysdk/Samples~
cp Assets/Samples Packages/com.vircadia.unitysdk/Samples~ -r
tar --transform="s/Packages\/com.vircadia.unitysdk/package/" -czvf ${PACKAGE} Packages/com.vircadia.unitysdk

docs:
doxygen ./docs/Doxyfile
Expand All @@ -25,5 +34,8 @@ clean-tests:
clean-package:
-rm $(PACKAGE)

clean-build:
-rm -rf $(BUILDDIR)


.PHONY: test clean-tests
.PHONY: build run debug test package docs clean-tests clean-package clean-build
Loading

0 comments on commit beabcb9

Please sign in to comment.