idk even stuff
parent
ca96e555b2
commit
c3e3169982
|
|
@ -5,13 +5,13 @@ using UnityEngine;
|
||||||
using UnityEngine.Serialization;
|
using UnityEngine.Serialization;
|
||||||
|
|
||||||
|
|
||||||
namespace VelNetUnity
|
namespace VelNet
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Added to the same object as DissonanceComms component. Only one in the scene.
|
/// Added to the same object as DissonanceComms component. Only one in the scene.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[RequireComponent(typeof(DissonanceComms))]
|
[RequireComponent(typeof(DissonanceComms))]
|
||||||
[AddComponentMenu("VelNetUnity/Dissonance/VelNet Comms Network")]
|
[AddComponentMenu("VelNet/Dissonance/VelNet Comms Network")]
|
||||||
public class VelCommsNetwork : MonoBehaviour, ICommsNetwork
|
public class VelCommsNetwork : MonoBehaviour, ICommsNetwork
|
||||||
{
|
{
|
||||||
public ConnectionStatus Status => manager.connected ? ConnectionStatus.Connected : ConnectionStatus.Disconnected;
|
public ConnectionStatus Status => manager.connected ? ConnectionStatus.Connected : ConnectionStatus.Disconnected;
|
||||||
|
|
|
||||||
|
|
@ -5,12 +5,12 @@ using System.Linq;
|
||||||
using Dissonance;
|
using Dissonance;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace VelNetUnity
|
namespace VelNet
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This should be added to your player object
|
/// This should be added to your player object
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[AddComponentMenu("VelNetUnity/Dissonance/VelNet Dissonance Player")]
|
[AddComponentMenu("VelNet/Dissonance/VelNet Dissonance Player")]
|
||||||
public class VelNetDissonancePlayer : NetworkComponent, IDissonancePlayer
|
public class VelNetDissonancePlayer : NetworkComponent, IDissonancePlayer
|
||||||
{
|
{
|
||||||
private VelCommsNetwork comms;
|
private VelCommsNetwork comms;
|
||||||
|
|
@ -28,6 +28,10 @@ namespace VelNetUnity
|
||||||
public bool IsTracking => true;
|
public bool IsTracking => true;
|
||||||
|
|
||||||
private static readonly List<VelNetDissonancePlayer> allPlayers = new List<VelNetDissonancePlayer>();
|
private static readonly List<VelNetDissonancePlayer> allPlayers = new List<VelNetDissonancePlayer>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Only sends voice data to players in this list
|
||||||
|
/// </summary>
|
||||||
public List<int> closePlayers = new List<int>();
|
public List<int> closePlayers = new List<int>();
|
||||||
|
|
||||||
[Tooltip("Maximum distance to transmit voice data. 0 to always send voice to all players.")]
|
[Tooltip("Maximum distance to transmit voice data. 0 to always send voice to all players.")]
|
||||||
|
|
@ -50,12 +54,30 @@ namespace VelNetUnity
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnEnable()
|
||||||
|
{
|
||||||
// add ourselves to the global list of all players in the scene
|
// add ourselves to the global list of all players in the scene
|
||||||
if (!allPlayers.Contains(this))
|
if (!allPlayers.Contains(this))
|
||||||
{
|
{
|
||||||
allPlayers.Add(this);
|
allPlayers.Add(this);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.LogError("We're already in the player list 🐭", this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnDisable()
|
||||||
|
{
|
||||||
|
// remove ourselves from the global list of all players in the scene
|
||||||
|
allPlayers.Remove(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Start()
|
||||||
|
{
|
||||||
if (IsMine)
|
if (IsMine)
|
||||||
{
|
{
|
||||||
SetDissonanceID(comms.dissonanceId);
|
SetDissonanceID(comms.dissonanceId);
|
||||||
|
|
@ -71,7 +93,7 @@ namespace VelNetUnity
|
||||||
writer.Write(dissonanceID);
|
writer.Write(dissonanceID);
|
||||||
SendBytes(mem.ToArray());
|
SendBytes(mem.ToArray());
|
||||||
};
|
};
|
||||||
VelNetManager.instance.SetupMessageGroup("close", closePlayers.ToArray());
|
VelNetManager.instance.SetupMessageGroup("voice", closePlayers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -83,10 +105,12 @@ namespace VelNetUnity
|
||||||
using MemoryStream mem = new MemoryStream();
|
using MemoryStream mem = new MemoryStream();
|
||||||
using BinaryWriter writer = new BinaryWriter(mem);
|
using BinaryWriter writer = new BinaryWriter(mem);
|
||||||
writer.Write((byte)MessageType.AudioData);
|
writer.Write((byte)MessageType.AudioData);
|
||||||
writer.Write(BitConverter.GetBytes(lastAudioId++));
|
writer.Write(lastAudioId++);
|
||||||
writer.Write(data.ToArray());
|
writer.Write(data.ToArray());
|
||||||
// send voice data unreliably
|
// send voice data unreliably
|
||||||
SendBytesToGroup("close", mem.ToArray(), false);
|
SendBytes(mem.ToArray(), false);
|
||||||
|
// SendBytesToGroup("voice", mem.ToArray());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -147,12 +171,16 @@ namespace VelNetUnity
|
||||||
|
|
||||||
if (closePlayerListChanged)
|
if (closePlayerListChanged)
|
||||||
{
|
{
|
||||||
VelNetManager.instance.SetupMessageGroup("close", closePlayers);
|
VelNetManager.instance.SetupMessageGroup("voice", closePlayers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
closePlayers = allPlayers.Select(p => p.Owner.userid).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//handle dissonance comms
|
// handle dissonance comms
|
||||||
|
|
||||||
//if we're not speaking, and the comms say we are, send a speaking event, which will be received on other network players and sent to their comms accordingly
|
//if we're not speaking, and the comms say we are, send a speaking event, which will be received on other network players and sent to their comms accordingly
|
||||||
if (comms.dissonanceComms.FindPlayer(dissonanceID)?.IsSpeaking != isSpeaking) //unfortunately, there does not seem to be an event for this
|
if (comms.dissonanceComms.FindPlayer(dissonanceID)?.IsSpeaking != isSpeaking) //unfortunately, there does not seem to be an event for this
|
||||||
|
|
@ -194,6 +222,7 @@ namespace VelNetUnity
|
||||||
if (dissonanceID == "") // I don't have this yet
|
if (dissonanceID == "") // I don't have this yet
|
||||||
{
|
{
|
||||||
dissonanceID = reader.ReadString();
|
dissonanceID = reader.ReadString();
|
||||||
|
|
||||||
// tell the comms network that this player joined the channel
|
// tell the comms network that this player joined the channel
|
||||||
comms.SetPlayerJoined(dissonanceID); // tell dissonance
|
comms.SetPlayerJoined(dissonanceID); // tell dissonance
|
||||||
comms.dissonanceComms.TrackPlayerPosition(this); // tell dissonance to track the remote player
|
comms.dissonanceComms.TrackPlayerPosition(this); // tell dissonance to track the remote player
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ using UnityEngine;
|
||||||
using UnityEngine.Serialization;
|
using UnityEngine.Serialization;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
namespace VelNetUnity
|
namespace VelNet
|
||||||
{
|
{
|
||||||
public class NetworkGUI : MonoBehaviour
|
public class NetworkGUI : MonoBehaviour
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,9 @@ using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace VelNetUnity
|
namespace VelNet
|
||||||
{
|
{
|
||||||
public class PlayerController : NetworkSerializedObject
|
public class PlayerController : NetworkComponent
|
||||||
{
|
{
|
||||||
public Vector3 targetPosition;
|
public Vector3 targetPosition;
|
||||||
public Quaternion targetRotation;
|
public Quaternion targetRotation;
|
||||||
|
|
@ -13,12 +13,13 @@ namespace VelNetUnity
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
private void Update()
|
private void Update()
|
||||||
{
|
{
|
||||||
if (!IsMine)
|
// if (!IsMine)
|
||||||
{
|
// {
|
||||||
transform.position = Vector3.Lerp(transform.position, targetPosition, .1f);
|
// transform.position = Vector3.Lerp(transform.position, targetPosition, .1f);
|
||||||
transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, .1f);
|
// transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, .1f);
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
|
if (IsMine)
|
||||||
{
|
{
|
||||||
Vector3 movement = new Vector3();
|
Vector3 movement = new Vector3();
|
||||||
movement.x += Input.GetAxis("Horizontal");
|
movement.x += Input.GetAxis("Horizontal");
|
||||||
|
|
@ -53,25 +54,29 @@ namespace VelNetUnity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
protected override byte[] SendState()
|
// protected override byte[] SendState()
|
||||||
|
// {
|
||||||
|
// using MemoryStream mem = new MemoryStream();
|
||||||
|
// using BinaryWriter writer = new BinaryWriter(mem);
|
||||||
|
//
|
||||||
|
// writer.Write(transform.position);
|
||||||
|
// writer.Write(transform.rotation);
|
||||||
|
//
|
||||||
|
// return mem.ToArray();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// protected override void ReceiveState(byte[] message)
|
||||||
|
// {
|
||||||
|
// using MemoryStream mem = new MemoryStream(message);
|
||||||
|
// using BinaryReader reader = new BinaryReader(mem);
|
||||||
|
//
|
||||||
|
// targetPosition = reader.ReadVector3();
|
||||||
|
// targetRotation = reader.ReadQuaternion();
|
||||||
|
// }
|
||||||
|
public override void ReceiveBytes(byte[] message)
|
||||||
{
|
{
|
||||||
using MemoryStream mem = new MemoryStream();
|
throw new System.NotImplementedException();
|
||||||
using BinaryWriter writer = new BinaryWriter(mem);
|
|
||||||
|
|
||||||
writer.Write(transform.position);
|
|
||||||
writer.Write(transform.rotation);
|
|
||||||
|
|
||||||
return mem.ToArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void ReceiveState(byte[] message)
|
|
||||||
{
|
|
||||||
using MemoryStream mem = new MemoryStream(message);
|
|
||||||
using BinaryReader reader = new BinaryReader(mem);
|
|
||||||
|
|
||||||
targetPosition = reader.ReadVector3();
|
|
||||||
targetRotation = reader.ReadQuaternion();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -31,7 +31,7 @@ Transform:
|
||||||
m_GameObject: {fileID: 6139051692386484099}
|
m_GameObject: {fileID: 6139051692386484099}
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 0.1, y: 0.1, z: 0.1}
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_RootOrder: 0
|
m_RootOrder: 0
|
||||||
|
|
@ -130,7 +130,6 @@ MonoBehaviour:
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
networkObject: {fileID: 9102273340480352682}
|
networkObject: {fileID: 9102273340480352682}
|
||||||
serializationRateHz: 30
|
|
||||||
targetPosition: {x: 0, y: 0, z: 0}
|
targetPosition: {x: 0, y: 0, z: 0}
|
||||||
targetRotation: {x: 0, y: 0, z: 0, w: 0}
|
targetRotation: {x: 0, y: 0, z: 0, w: 0}
|
||||||
--- !u!114 &1181612843795795320
|
--- !u!114 &1181612843795795320
|
||||||
|
|
@ -147,7 +146,5 @@ MonoBehaviour:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
networkObject: {fileID: 9102273340480352682}
|
networkObject: {fileID: 9102273340480352682}
|
||||||
dissonanceID:
|
dissonanceID:
|
||||||
targetPosition: {x: 0, y: 0, z: 0}
|
|
||||||
targetRotation: {x: 0, y: 0, z: 0, w: 0}
|
|
||||||
closePlayers:
|
closePlayers:
|
||||||
maxDistance: 0
|
maxDistance: 0
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ MonoBehaviour:
|
||||||
m_PrefabInstance: {fileID: 0}
|
m_PrefabInstance: {fileID: 0}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 8565720275311462453}
|
m_GameObject: {fileID: 8565720275311462453}
|
||||||
m_Enabled: 1
|
m_Enabled: 0
|
||||||
m_EditorHideFlags: 0
|
m_EditorHideFlags: 0
|
||||||
m_Script: {fileID: 11500000, guid: 3f1f9b0bbd93a484a987c51f1107ebe5, type: 3}
|
m_Script: {fileID: 11500000, guid: 3f1f9b0bbd93a484a987c51f1107ebe5, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using VelNetUnity;
|
using VelNet;
|
||||||
|
|
||||||
public class VelNetMan : MonoBehaviour
|
public class VelNetMan : MonoBehaviour
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1834,7 +1834,7 @@ MonoBehaviour:
|
||||||
m_Script: {fileID: 11500000, guid: 03a4d4e1a7fd74c7ab2eccca4ce168db, type: 3}
|
m_Script: {fileID: 11500000, guid: 03a4d4e1a7fd74c7ab2eccca4ce168db, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
host: neko.ugavel.com
|
host: 129.159.107.234
|
||||||
port: 3290
|
port: 3290
|
||||||
udpConnected: 0
|
udpConnected: 0
|
||||||
userid: -1
|
userid: -1
|
||||||
|
|
@ -3406,7 +3406,7 @@ PrefabInstance:
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 8565720275311462455, guid: 6e4a023f70e01405e8b249a4488fe319, type: 3}
|
- target: {fileID: 8565720275311462455, guid: 6e4a023f70e01405e8b249a4488fe319, type: 3}
|
||||||
propertyPath: m_LocalPosition.y
|
propertyPath: m_LocalPosition.y
|
||||||
value: 0
|
value: 2
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 8565720275311462455, guid: 6e4a023f70e01405e8b249a4488fe319, type: 3}
|
- target: {fileID: 8565720275311462455, guid: 6e4a023f70e01405e8b249a4488fe319, type: 3}
|
||||||
propertyPath: m_LocalPosition.z
|
propertyPath: m_LocalPosition.z
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace VelNetUnity
|
namespace VelNet
|
||||||
{
|
{
|
||||||
public abstract class NetworkComponent : MonoBehaviour
|
public abstract class NetworkComponent : MonoBehaviour
|
||||||
{
|
{
|
||||||
|
|
@ -24,7 +24,6 @@ namespace VelNetUnity
|
||||||
networkObject.SendBytesToGroup(this, group, message, reliable);
|
networkObject.SendBytesToGroup(this, group, message, reliable);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This is called by <see cref="NetworkObject"/> when messages are received for this component
|
/// This is called by <see cref="NetworkObject"/> when messages are received for this component
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace VelNetUnity
|
namespace VelNet
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This is a base class for all objects that a player can instantiated/owned
|
/// This is a base class for all objects that a player can instantiated/owned
|
||||||
|
|
@ -43,7 +43,7 @@ namespace VelNetUnity
|
||||||
|
|
||||||
public void SendBytesToGroup(NetworkComponent component, string group, byte[] message, bool reliable = true)
|
public void SendBytesToGroup(NetworkComponent component, string group, byte[] message, bool reliable = true)
|
||||||
{
|
{
|
||||||
if (owner == null || !owner.isLocal)
|
if (!IsMine)
|
||||||
{
|
{
|
||||||
Debug.LogError("Can't send message if owner is null or not local", this);
|
Debug.LogError("Can't send message if owner is null or not local", this);
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace VelNetUnity
|
namespace VelNet
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a network player
|
/// Represents a network player
|
||||||
|
|
@ -53,10 +53,11 @@ namespace VelNetUnity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// These are generally things that come from the "owner" and should be enacted locally, where appropriate
|
||||||
|
/// </summary>
|
||||||
public void HandleMessage(VelNetManager.Message m)
|
public void HandleMessage(VelNetManager.Message m)
|
||||||
{
|
{
|
||||||
//these are generally things that come from the "owner" and should be enacted locally, where appropriate
|
|
||||||
//we need to parse the message
|
//we need to parse the message
|
||||||
|
|
||||||
//types of messages
|
//types of messages
|
||||||
|
|
@ -104,7 +105,7 @@ namespace VelNetUnity
|
||||||
break; //we already have this one, ignore
|
break; //we already have this one, ignore
|
||||||
}
|
}
|
||||||
|
|
||||||
VelNetManager.InstantiateNetworkObject(networkId, prefabName, this);
|
VelNetManager.SomebodyInstantiatedNetworkObject(networkId, prefabName, this);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.Serialization;
|
using UnityEngine.Serialization;
|
||||||
|
|
||||||
namespace VelNetUnity
|
namespace VelNet
|
||||||
{
|
{
|
||||||
public abstract class NetworkSerializedObject : NetworkComponent
|
public abstract class NetworkSerializedObject : NetworkComponent
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace VelNetUnity
|
namespace VelNet
|
||||||
{
|
{
|
||||||
public static class BinaryWriterExtensions
|
public static class BinaryWriterExtensions
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,12 @@ using System.IO;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
|
|
||||||
namespace VelNetUnity
|
namespace VelNet
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A simple class that will sync the position and rotation of a network object
|
/// A simple class that will sync the position and rotation of a network object
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[AddComponentMenu("VelNetUnity/VelNet Sync Transform")]
|
[AddComponentMenu("VelNet/VelNet Sync Transform")]
|
||||||
public class SyncTransform : NetworkSerializedObject
|
public class SyncTransform : NetworkSerializedObject
|
||||||
{
|
{
|
||||||
public Vector3 targetPosition;
|
public Vector3 targetPosition;
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,9 @@ using System.Threading;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
|
||||||
namespace VelNetUnity
|
namespace VelNet
|
||||||
{
|
{
|
||||||
[AddComponentMenu("VelNetUnity/VelNet Manager")]
|
[AddComponentMenu("VelNet/VelNet Manager")]
|
||||||
public class VelNetManager : MonoBehaviour
|
public class VelNetManager : MonoBehaviour
|
||||||
{
|
{
|
||||||
public enum MessageType
|
public enum MessageType
|
||||||
|
|
@ -332,38 +332,36 @@ namespace VelNetUnity
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
// Get a stream object for reading
|
// Get a stream object for reading
|
||||||
using (NetworkStream stream = socketConnection.GetStream())
|
using NetworkStream stream = socketConnection.GetStream();
|
||||||
|
int length;
|
||||||
|
// Read incomming stream into byte arrary.
|
||||||
|
while ((length = stream.Read(bytes, 0, bytes.Length)) != 0)
|
||||||
{
|
{
|
||||||
int length;
|
byte[] incommingData = new byte[length];
|
||||||
// Read incomming stream into byte arrary.
|
Array.Copy(bytes, 0, incommingData, 0, length);
|
||||||
while ((length = stream.Read(bytes, 0, bytes.Length)) != 0)
|
// Convert byte array to string message.
|
||||||
|
string serverMessage = Encoding.ASCII.GetString(incommingData);
|
||||||
|
string[] sections = serverMessage.Split('\n');
|
||||||
|
if (sections.Length > 1)
|
||||||
{
|
{
|
||||||
byte[] incommingData = new byte[length];
|
lock (receivedMessages)
|
||||||
Array.Copy(bytes, 0, incommingData, 0, length);
|
|
||||||
// Convert byte array to string message.
|
|
||||||
string serverMessage = Encoding.ASCII.GetString(incommingData);
|
|
||||||
string[] sections = serverMessage.Split('\n');
|
|
||||||
if (sections.Length > 1)
|
|
||||||
{
|
{
|
||||||
lock (receivedMessages)
|
for (int i = 0; i < sections.Length - 1; i++)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < sections.Length - 1; i++)
|
if (i == 0)
|
||||||
{
|
{
|
||||||
if (i == 0)
|
HandleMessage(partialMessage + sections[0]);
|
||||||
{
|
partialMessage = "";
|
||||||
HandleMessage(partialMessage + sections[0]);
|
}
|
||||||
partialMessage = "";
|
else
|
||||||
}
|
{
|
||||||
else
|
HandleMessage(sections[i]);
|
||||||
{
|
|
||||||
HandleMessage(sections[i]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
partialMessage = partialMessage + sections[sections.Length - 1];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
partialMessage = partialMessage + sections[sections.Length - 1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -464,7 +462,7 @@ namespace VelNetUnity
|
||||||
if (stream.CanWrite)
|
if (stream.CanWrite)
|
||||||
{
|
{
|
||||||
// Convert string message to byte array.
|
// Convert string message to byte array.
|
||||||
clientMessage = clientMessage + "\n"; //append a new line to delineate the message
|
clientMessage += "\n"; // append a new line to delineate the message
|
||||||
byte[] clientMessageAsByteArray = Encoding.ASCII.GetBytes(clientMessage);
|
byte[] clientMessageAsByteArray = Encoding.ASCII.GetBytes(clientMessage);
|
||||||
// Write byte array to socketConnection stream.
|
// Write byte array to socketConnection stream.
|
||||||
stream.Write(clientMessageAsByteArray, 0, clientMessageAsByteArray.Length);
|
stream.Write(clientMessageAsByteArray, 0, clientMessageAsByteArray.Length);
|
||||||
|
|
@ -538,9 +536,12 @@ namespace VelNetUnity
|
||||||
newObject.prefabName = prefabName;
|
newObject.prefabName = prefabName;
|
||||||
newObject.owner = localPlayer;
|
newObject.owner = localPlayer;
|
||||||
instance.objects.Add(newObject.networkId, newObject);
|
instance.objects.Add(newObject.networkId, newObject);
|
||||||
|
|
||||||
|
// only sent to others, as I already instantiated this. Nice that it happens immediately.
|
||||||
|
instance.SendTo(MessageType.OTHERS, "7," + newObject.networkId + "," + prefabName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void InstantiateNetworkObject(string networkId, string prefabName, NetworkPlayer owner)
|
public static void SomebodyInstantiatedNetworkObject(string networkId, string prefabName, NetworkPlayer owner)
|
||||||
{
|
{
|
||||||
NetworkObject prefab = instance.prefabs.Find(p => p.name == prefabName);
|
NetworkObject prefab = instance.prefabs.Find(p => p.name == prefabName);
|
||||||
if (prefab == null) return;
|
if (prefab == null) return;
|
||||||
|
|
|
||||||
|
|
@ -5,13 +5,13 @@ using UnityEngine;
|
||||||
using UnityEngine.Serialization;
|
using UnityEngine.Serialization;
|
||||||
|
|
||||||
|
|
||||||
namespace VelNetUnity
|
namespace VelNet
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Added to the same object as DissonanceComms component. Only one in the scene.
|
/// Added to the same object as DissonanceComms component. Only one in the scene.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[RequireComponent(typeof(DissonanceComms))]
|
[RequireComponent(typeof(DissonanceComms))]
|
||||||
[AddComponentMenu("VelNetUnity/Dissonance/VelNet Comms Network")]
|
[AddComponentMenu("VelNet/Dissonance/VelNet Comms Network")]
|
||||||
public class VelCommsNetwork : MonoBehaviour, ICommsNetwork
|
public class VelCommsNetwork : MonoBehaviour, ICommsNetwork
|
||||||
{
|
{
|
||||||
public ConnectionStatus Status => manager.connected ? ConnectionStatus.Connected : ConnectionStatus.Disconnected;
|
public ConnectionStatus Status => manager.connected ? ConnectionStatus.Connected : ConnectionStatus.Disconnected;
|
||||||
|
|
|
||||||
|
|
@ -5,12 +5,12 @@ using System.Linq;
|
||||||
using Dissonance;
|
using Dissonance;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace VelNetUnity
|
namespace VelNet
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This should be added to your player object
|
/// This should be added to your player object
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[AddComponentMenu("VelNetUnity/Dissonance/VelNet Dissonance Player")]
|
[AddComponentMenu("VelNet/Dissonance/VelNet Dissonance Player")]
|
||||||
public class VelNetDissonancePlayer : NetworkComponent, IDissonancePlayer
|
public class VelNetDissonancePlayer : NetworkComponent, IDissonancePlayer
|
||||||
{
|
{
|
||||||
private VelCommsNetwork comms;
|
private VelCommsNetwork comms;
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ using UnityEngine;
|
||||||
using UnityEngine.Serialization;
|
using UnityEngine.Serialization;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
namespace VelNetUnity
|
namespace VelNet
|
||||||
{
|
{
|
||||||
public class NetworkGUI : MonoBehaviour
|
public class NetworkGUI : MonoBehaviour
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace VelNetUnity
|
namespace VelNet
|
||||||
{
|
{
|
||||||
public class PlayerController : NetworkSerializedObject
|
public class PlayerController : NetworkSerializedObject
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using VelNetUnity;
|
using VelNet;
|
||||||
|
|
||||||
public class VelNetMan : MonoBehaviour
|
public class VelNetMan : MonoBehaviour
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "VelNetUnity",
|
"name": "VelNet",
|
||||||
"rootNamespace": "VelNetUnity",
|
"rootNamespace": "VelNet",
|
||||||
"references": [],
|
"references": [],
|
||||||
"includePlatforms": [],
|
"includePlatforms": [],
|
||||||
"excludePlatforms": [],
|
"excludePlatforms": [],
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "edu.uga.engr.vel.velnetunity",
|
"name": "edu.uga.engr.vel.velnet",
|
||||||
"displayName": "VelNetUnity",
|
"displayName": "VelNet",
|
||||||
"version": "1.0.3",
|
"version": "1.0.3",
|
||||||
"unity": "2019.1",
|
"unity": "2019.1",
|
||||||
"description": "A custom networking library for Unity.",
|
"description": "A custom networking library for Unity.",
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@
|
||||||
"com.unity.modules.imgui": "1.0.0"
|
"com.unity.modules.imgui": "1.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"edu.uga.engr.vel.velnetunity": {
|
"edu.uga.engr.vel.velnet": {
|
||||||
"version": "file:VelNetUnity",
|
"version": "file:VelNetUnity",
|
||||||
"depth": 0,
|
"depth": 0,
|
||||||
"source": "embedded",
|
"source": "embedded",
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,12 @@ PlayerSettings:
|
||||||
androidRenderOutsideSafeArea: 1
|
androidRenderOutsideSafeArea: 1
|
||||||
androidUseSwappy: 1
|
androidUseSwappy: 1
|
||||||
androidBlitType: 0
|
androidBlitType: 0
|
||||||
|
androidResizableWindow: 0
|
||||||
|
androidDefaultWindowWidth: 1920
|
||||||
|
androidDefaultWindowHeight: 1080
|
||||||
|
androidMinimumWindowWidth: 400
|
||||||
|
androidMinimumWindowHeight: 300
|
||||||
|
androidFullscreenMode: 1
|
||||||
defaultIsNativeResolution: 0
|
defaultIsNativeResolution: 0
|
||||||
macRetinaSupport: 1
|
macRetinaSupport: 1
|
||||||
runInBackground: 1
|
runInBackground: 1
|
||||||
|
|
@ -121,6 +127,7 @@ PlayerSettings:
|
||||||
vulkanEnableSetSRGBWrite: 0
|
vulkanEnableSetSRGBWrite: 0
|
||||||
vulkanEnablePreTransform: 0
|
vulkanEnablePreTransform: 0
|
||||||
vulkanEnableLateAcquireNextImage: 0
|
vulkanEnableLateAcquireNextImage: 0
|
||||||
|
vulkanEnableCommandBufferRecycling: 1
|
||||||
m_SupportedAspectRatios:
|
m_SupportedAspectRatios:
|
||||||
4:3: 1
|
4:3: 1
|
||||||
5:4: 1
|
5:4: 1
|
||||||
|
|
@ -236,6 +243,7 @@ PlayerSettings:
|
||||||
useCustomGradlePropertiesTemplate: 0
|
useCustomGradlePropertiesTemplate: 0
|
||||||
useCustomProguardFile: 0
|
useCustomProguardFile: 0
|
||||||
AndroidTargetArchitectures: 1
|
AndroidTargetArchitectures: 1
|
||||||
|
AndroidTargetDevices: 0
|
||||||
AndroidSplashScreenScale: 0
|
AndroidSplashScreenScale: 0
|
||||||
androidSplashScreen: {fileID: 0}
|
androidSplashScreen: {fileID: 0}
|
||||||
AndroidKeystoreName:
|
AndroidKeystoreName:
|
||||||
|
|
@ -252,13 +260,106 @@ PlayerSettings:
|
||||||
height: 180
|
height: 180
|
||||||
banner: {fileID: 0}
|
banner: {fileID: 0}
|
||||||
androidGamepadSupportLevel: 0
|
androidGamepadSupportLevel: 0
|
||||||
|
chromeosInputEmulation: 1
|
||||||
AndroidMinifyWithR8: 0
|
AndroidMinifyWithR8: 0
|
||||||
AndroidMinifyRelease: 0
|
AndroidMinifyRelease: 0
|
||||||
AndroidMinifyDebug: 0
|
AndroidMinifyDebug: 0
|
||||||
AndroidValidateAppBundleSize: 1
|
AndroidValidateAppBundleSize: 1
|
||||||
AndroidAppBundleSizeToValidate: 150
|
AndroidAppBundleSizeToValidate: 150
|
||||||
m_BuildTargetIcons: []
|
m_BuildTargetIcons: []
|
||||||
m_BuildTargetPlatformIcons: []
|
m_BuildTargetPlatformIcons:
|
||||||
|
- m_BuildTarget: Android
|
||||||
|
m_Icons:
|
||||||
|
- m_Textures: []
|
||||||
|
m_Width: 432
|
||||||
|
m_Height: 432
|
||||||
|
m_Kind: 2
|
||||||
|
m_SubKind:
|
||||||
|
- m_Textures: []
|
||||||
|
m_Width: 324
|
||||||
|
m_Height: 324
|
||||||
|
m_Kind: 2
|
||||||
|
m_SubKind:
|
||||||
|
- m_Textures: []
|
||||||
|
m_Width: 216
|
||||||
|
m_Height: 216
|
||||||
|
m_Kind: 2
|
||||||
|
m_SubKind:
|
||||||
|
- m_Textures: []
|
||||||
|
m_Width: 162
|
||||||
|
m_Height: 162
|
||||||
|
m_Kind: 2
|
||||||
|
m_SubKind:
|
||||||
|
- m_Textures: []
|
||||||
|
m_Width: 108
|
||||||
|
m_Height: 108
|
||||||
|
m_Kind: 2
|
||||||
|
m_SubKind:
|
||||||
|
- m_Textures: []
|
||||||
|
m_Width: 81
|
||||||
|
m_Height: 81
|
||||||
|
m_Kind: 2
|
||||||
|
m_SubKind:
|
||||||
|
- m_Textures: []
|
||||||
|
m_Width: 192
|
||||||
|
m_Height: 192
|
||||||
|
m_Kind: 0
|
||||||
|
m_SubKind:
|
||||||
|
- m_Textures: []
|
||||||
|
m_Width: 144
|
||||||
|
m_Height: 144
|
||||||
|
m_Kind: 0
|
||||||
|
m_SubKind:
|
||||||
|
- m_Textures: []
|
||||||
|
m_Width: 96
|
||||||
|
m_Height: 96
|
||||||
|
m_Kind: 0
|
||||||
|
m_SubKind:
|
||||||
|
- m_Textures: []
|
||||||
|
m_Width: 72
|
||||||
|
m_Height: 72
|
||||||
|
m_Kind: 0
|
||||||
|
m_SubKind:
|
||||||
|
- m_Textures: []
|
||||||
|
m_Width: 48
|
||||||
|
m_Height: 48
|
||||||
|
m_Kind: 0
|
||||||
|
m_SubKind:
|
||||||
|
- m_Textures: []
|
||||||
|
m_Width: 36
|
||||||
|
m_Height: 36
|
||||||
|
m_Kind: 0
|
||||||
|
m_SubKind:
|
||||||
|
- m_Textures: []
|
||||||
|
m_Width: 192
|
||||||
|
m_Height: 192
|
||||||
|
m_Kind: 1
|
||||||
|
m_SubKind:
|
||||||
|
- m_Textures: []
|
||||||
|
m_Width: 144
|
||||||
|
m_Height: 144
|
||||||
|
m_Kind: 1
|
||||||
|
m_SubKind:
|
||||||
|
- m_Textures: []
|
||||||
|
m_Width: 96
|
||||||
|
m_Height: 96
|
||||||
|
m_Kind: 1
|
||||||
|
m_SubKind:
|
||||||
|
- m_Textures: []
|
||||||
|
m_Width: 72
|
||||||
|
m_Height: 72
|
||||||
|
m_Kind: 1
|
||||||
|
m_SubKind:
|
||||||
|
- m_Textures: []
|
||||||
|
m_Width: 48
|
||||||
|
m_Height: 48
|
||||||
|
m_Kind: 1
|
||||||
|
m_SubKind:
|
||||||
|
- m_Textures: []
|
||||||
|
m_Width: 36
|
||||||
|
m_Height: 36
|
||||||
|
m_Kind: 1
|
||||||
|
m_SubKind:
|
||||||
m_BuildTargetBatching:
|
m_BuildTargetBatching:
|
||||||
- m_BuildTarget: Standalone
|
- m_BuildTarget: Standalone
|
||||||
m_StaticBatching: 1
|
m_StaticBatching: 1
|
||||||
|
|
@ -346,6 +447,7 @@ PlayerSettings:
|
||||||
cameraUsageDescription:
|
cameraUsageDescription:
|
||||||
locationUsageDescription:
|
locationUsageDescription:
|
||||||
microphoneUsageDescription: Allow voice communications
|
microphoneUsageDescription: Allow voice communications
|
||||||
|
bluetoothUsageDescription:
|
||||||
switchNMETAOverride:
|
switchNMETAOverride:
|
||||||
switchNetLibKey:
|
switchNetLibKey:
|
||||||
switchSocketMemoryPoolSize: 6144
|
switchSocketMemoryPoolSize: 6144
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,2 @@
|
||||||
m_EditorVersion: 2020.3.16f1
|
m_EditorVersion: 2020.3.23f1
|
||||||
m_EditorVersionWithRevision: 2020.3.16f1 (049d6eca3c44)
|
m_EditorVersionWithRevision: 2020.3.23f1 (c5d91304a876)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue