fixes for mouse dragger, visualization for audio range, added some more callbacks to velnetmanager, added color syncing extension, take ownership of synced textbox, fix for deleting all scene objects
parent
e42b499490
commit
80a16c4ce2
|
|
@ -20,7 +20,7 @@ public class MouseDragger : MonoBehaviour
|
||||||
{
|
{
|
||||||
foreach (string draggableTag in draggableTags)
|
foreach (string draggableTag in draggableTags)
|
||||||
{
|
{
|
||||||
if (hit.transform.CompareTag(draggableTag) || hit.transform.parent == null || hit.transform.parent.CompareTag(draggableTag))
|
if (hit.transform.CompareTag(draggableTag) || (hit.transform.parent != null && hit.transform.parent.CompareTag(draggableTag)))
|
||||||
{
|
{
|
||||||
NetworkObject netObj = hit.transform.GetComponent<NetworkObject>();
|
NetworkObject netObj = hit.transform.GetComponent<NetworkObject>();
|
||||||
netObj ??= hit.transform.GetComponentInParent<NetworkObject>();
|
netObj ??= hit.transform.GetComponentInParent<NetworkObject>();
|
||||||
|
|
|
||||||
|
|
@ -10,14 +10,16 @@ namespace VelNet
|
||||||
{
|
{
|
||||||
public class NetworkGUI : MonoBehaviour
|
public class NetworkGUI : MonoBehaviour
|
||||||
{
|
{
|
||||||
[FormerlySerializedAs("networkManager")] public VelNetManager velNetManager;
|
[FormerlySerializedAs("networkManager")]
|
||||||
|
public VelNetManager velNetManager;
|
||||||
|
|
||||||
public InputField userInput;
|
public InputField userInput;
|
||||||
public InputField sendInput;
|
public InputField sendInput;
|
||||||
public InputField roomInput;
|
public InputField roomInput;
|
||||||
public Text messages;
|
public Text messages;
|
||||||
public List<string> messageBuffer;
|
public List<string> messageBuffer;
|
||||||
public Dropdown microphones;
|
public Dropdown microphones;
|
||||||
DissonanceComms comms;
|
private DissonanceComms comms;
|
||||||
|
|
||||||
public void HandleSend()
|
public void HandleSend()
|
||||||
{
|
{
|
||||||
|
|
@ -42,6 +44,7 @@ namespace VelNet
|
||||||
VelNetManager.GetRooms();
|
VelNetManager.GetRooms();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void HandleJoin()
|
public void HandleJoin()
|
||||||
{
|
{
|
||||||
if (roomInput.text != "")
|
if (roomInput.text != "")
|
||||||
|
|
@ -61,34 +64,14 @@ namespace VelNet
|
||||||
comms = FindObjectOfType<DissonanceComms>();
|
comms = FindObjectOfType<DissonanceComms>();
|
||||||
microphones.AddOptions(new List<string>(Microphone.devices));
|
microphones.AddOptions(new List<string>(Microphone.devices));
|
||||||
|
|
||||||
/* todo
|
|
||||||
VelNetManager.MessageReceived += (m) =>
|
|
||||||
{
|
|
||||||
string s = m.type + ":" + m.sender + ":" + m.text;
|
|
||||||
messageBuffer.Add(s);
|
|
||||||
messages.text = "";
|
|
||||||
|
|
||||||
|
|
||||||
if (messageBuffer.Count > 10)
|
|
||||||
{
|
|
||||||
messageBuffer.RemoveAt(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (string msg in messageBuffer)
|
|
||||||
{
|
|
||||||
messages.text = messages.text + msg + "\n";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
*/
|
|
||||||
StartCoroutine(testes());
|
StartCoroutine(testes());
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IEnumerator testes()
|
IEnumerator testes()
|
||||||
{
|
{
|
||||||
yield return new WaitForSeconds(1.0f);
|
yield return new WaitForSeconds(1.0f);
|
||||||
HandleLogin();
|
HandleLogin();
|
||||||
yield return new WaitForSeconds(1.0f);
|
yield return new WaitForSeconds(1.0f);
|
||||||
HandleJoin();
|
HandleJoin();
|
||||||
yield return null;
|
yield return null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,25 +1,30 @@
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using Random = UnityEngine.Random;
|
||||||
|
|
||||||
namespace VelNet
|
namespace VelNet
|
||||||
{
|
{
|
||||||
public class PlayerController : NetworkComponent
|
public class PlayerController : NetworkSerializedObjectStream
|
||||||
{
|
{
|
||||||
public Vector3 targetPosition;
|
private Renderer rend;
|
||||||
public Quaternion targetRotation;
|
public Color color;
|
||||||
|
|
||||||
|
private void Start()
|
||||||
|
{
|
||||||
|
rend = GetComponent<MeshRenderer>();
|
||||||
|
if (IsMine)
|
||||||
|
{
|
||||||
|
color = new Color(Random.Range(0, 1f), Random.Range(0, 1f), Random.Range(0, 1f));
|
||||||
|
rend.material.color = color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
private void Update()
|
private void Update()
|
||||||
{
|
{
|
||||||
// if (!IsMine)
|
|
||||||
// {
|
|
||||||
// transform.position = Vector3.Lerp(transform.position, targetPosition, .1f);
|
|
||||||
// transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, .1f);
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
if (IsMine)
|
if (IsMine)
|
||||||
{
|
{
|
||||||
Vector3 movement = new Vector3();
|
Vector3 movement = new Vector3();
|
||||||
|
|
@ -43,37 +48,30 @@ namespace VelNet
|
||||||
|
|
||||||
if (Input.GetKeyDown(KeyCode.Backspace))
|
if (Input.GetKeyDown(KeyCode.Backspace))
|
||||||
{
|
{
|
||||||
foreach (KeyValuePair<string, NetworkObject> kvp in VelNetManager.instance.objects.Where(kvp => !kvp.Value.ownershipLocked))
|
foreach (string key in VelNetManager.instance.objects
|
||||||
|
.Where(kvp => !kvp.Value.ownershipLocked)
|
||||||
|
.Select(kvp => kvp.Key).ToArray())
|
||||||
{
|
{
|
||||||
VelNetManager.NetworkDestroy(kvp.Key);
|
VelNetManager.NetworkDestroy(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
protected override void SendState(BinaryWriter binaryWriter)
|
||||||
// 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)
|
|
||||||
{
|
{
|
||||||
throw new System.NotImplementedException();
|
binaryWriter.Write(color);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void ReceiveState(BinaryReader binaryReader)
|
||||||
|
{
|
||||||
|
Color newColor = binaryReader.ReadColor();
|
||||||
|
if (newColor != color)
|
||||||
|
{
|
||||||
|
rend.material.color = newColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
color = newColor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,5 +1,86 @@
|
||||||
%YAML 1.1
|
%YAML 1.1
|
||||||
%TAG !u! tag:unity3d.com,2011:
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!1 &2802320351940726854
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 6602982999811082154}
|
||||||
|
- component: {fileID: 6433756913090684124}
|
||||||
|
- component: {fileID: 6919422133110223353}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: Dissonance Range
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!4 &6602982999811082154
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 2802320351940726854}
|
||||||
|
m_LocalRotation: {x: -0.70710635, y: -0, z: -0, w: 0.7071073}
|
||||||
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
|
m_LocalScale: {x: 8, y: 0.1, z: 8}
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 3076416102083120807}
|
||||||
|
m_RootOrder: 0
|
||||||
|
m_LocalEulerAnglesHint: {x: -90, y: 0, z: 0}
|
||||||
|
--- !u!33 &6433756913090684124
|
||||||
|
MeshFilter:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 2802320351940726854}
|
||||||
|
m_Mesh: {fileID: 10206, guid: 0000000000000000e000000000000000, type: 0}
|
||||||
|
--- !u!23 &6919422133110223353
|
||||||
|
MeshRenderer:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 2802320351940726854}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_CastShadows: 1
|
||||||
|
m_ReceiveShadows: 1
|
||||||
|
m_DynamicOccludee: 1
|
||||||
|
m_MotionVectors: 1
|
||||||
|
m_LightProbeUsage: 1
|
||||||
|
m_ReflectionProbeUsage: 1
|
||||||
|
m_RayTracingMode: 2
|
||||||
|
m_RayTraceProcedural: 0
|
||||||
|
m_RenderingLayerMask: 1
|
||||||
|
m_RendererPriority: 0
|
||||||
|
m_Materials:
|
||||||
|
- {fileID: 2100000, guid: 6fad1ca32acea73489c2c4b898cdb9d4, type: 2}
|
||||||
|
m_StaticBatchInfo:
|
||||||
|
firstSubMesh: 0
|
||||||
|
subMeshCount: 0
|
||||||
|
m_StaticBatchRoot: {fileID: 0}
|
||||||
|
m_ProbeAnchor: {fileID: 0}
|
||||||
|
m_LightProbeVolumeOverride: {fileID: 0}
|
||||||
|
m_ScaleInLightmap: 1
|
||||||
|
m_ReceiveGI: 1
|
||||||
|
m_PreserveUVs: 0
|
||||||
|
m_IgnoreNormalsForChartDetection: 0
|
||||||
|
m_ImportantGI: 0
|
||||||
|
m_StitchLightmapSeams: 1
|
||||||
|
m_SelectedEditorRenderState: 3
|
||||||
|
m_MinimumChartSize: 4
|
||||||
|
m_AutoUVMaxDistance: 0.5
|
||||||
|
m_AutoUVMaxAngle: 89
|
||||||
|
m_LightmapParameters: {fileID: 0}
|
||||||
|
m_SortingLayerID: 0
|
||||||
|
m_SortingLayer: 0
|
||||||
|
m_SortingOrder: 0
|
||||||
|
m_AdditionalVertexStreams: {fileID: 0}
|
||||||
--- !u!1 &6139051692386484099
|
--- !u!1 &6139051692386484099
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
@ -33,7 +114,8 @@ Transform:
|
||||||
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: 0.5, y: 0.5, z: 0.5}
|
m_LocalScale: {x: 0.5, y: 0.5, z: 0.5}
|
||||||
m_Children: []
|
m_Children:
|
||||||
|
- {fileID: 6602982999811082154}
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_RootOrder: 0
|
m_RootOrder: 0
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
|
@ -113,6 +195,7 @@ MonoBehaviour:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
ownershipLocked: 1
|
ownershipLocked: 1
|
||||||
networkId:
|
networkId:
|
||||||
|
sceneNetworkId: 0
|
||||||
prefabName:
|
prefabName:
|
||||||
isSceneObject: 0
|
isSceneObject: 0
|
||||||
syncedComponents:
|
syncedComponents:
|
||||||
|
|
@ -132,8 +215,8 @@ MonoBehaviour:
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
networkObject: {fileID: 9102273340480352682}
|
networkObject: {fileID: 9102273340480352682}
|
||||||
targetPosition: {x: 0, y: 0, z: 0}
|
serializationRateHz: 30
|
||||||
targetRotation: {x: 0, y: 0, z: 0, w: 0}
|
color: {r: 0, g: 0, b: 0, a: 0}
|
||||||
--- !u!114 &1181612843795795320
|
--- !u!114 &1181612843795795320
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
@ -147,6 +230,7 @@ MonoBehaviour:
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
networkObject: {fileID: 9102273340480352682}
|
networkObject: {fileID: 9102273340480352682}
|
||||||
|
useTcp: 0
|
||||||
dissonanceID:
|
dissonanceID:
|
||||||
closePlayers:
|
closePlayers:
|
||||||
maxDistance: 2
|
maxDistance: 2
|
||||||
|
|
@ -163,5 +247,7 @@ MonoBehaviour:
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
networkObject: {fileID: 9102273340480352682}
|
networkObject: {fileID: 9102273340480352682}
|
||||||
serializationRateHz: 1
|
serializationRateHz: 60
|
||||||
useLocalTransform: 0
|
useLocalTransform: 0
|
||||||
|
teleportDistance: 0
|
||||||
|
teleportAngle: 0
|
||||||
|
|
|
||||||
|
|
@ -16,4 +16,9 @@ public class SyncedTextbox : NetworkSerializedObjectStream
|
||||||
{
|
{
|
||||||
text.text = binaryReader.ReadString();
|
text.text = binaryReader.ReadString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void TakeOwnership()
|
||||||
|
{
|
||||||
|
networkObject.TakeOwnership();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,5 +1,100 @@
|
||||||
%YAML 1.1
|
%YAML 1.1
|
||||||
%TAG !u! tag:unity3d.com,2011:
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!1 &6003361529827848619
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 7099230484513283147}
|
||||||
|
- component: {fileID: 8811139817265458480}
|
||||||
|
- component: {fileID: 3776025769317911085}
|
||||||
|
- component: {fileID: 1426238303320144522}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: Cube
|
||||||
|
m_TagString: TestSphere
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!4 &7099230484513283147
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 6003361529827848619}
|
||||||
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 8565720275311462455}
|
||||||
|
m_RootOrder: 0
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!33 &8811139817265458480
|
||||||
|
MeshFilter:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 6003361529827848619}
|
||||||
|
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
|
||||||
|
--- !u!23 &3776025769317911085
|
||||||
|
MeshRenderer:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 6003361529827848619}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_CastShadows: 1
|
||||||
|
m_ReceiveShadows: 1
|
||||||
|
m_DynamicOccludee: 1
|
||||||
|
m_MotionVectors: 1
|
||||||
|
m_LightProbeUsage: 1
|
||||||
|
m_ReflectionProbeUsage: 1
|
||||||
|
m_RayTracingMode: 2
|
||||||
|
m_RayTraceProcedural: 0
|
||||||
|
m_RenderingLayerMask: 1
|
||||||
|
m_RendererPriority: 0
|
||||||
|
m_Materials:
|
||||||
|
- {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
|
||||||
|
m_StaticBatchInfo:
|
||||||
|
firstSubMesh: 0
|
||||||
|
subMeshCount: 0
|
||||||
|
m_StaticBatchRoot: {fileID: 0}
|
||||||
|
m_ProbeAnchor: {fileID: 0}
|
||||||
|
m_LightProbeVolumeOverride: {fileID: 0}
|
||||||
|
m_ScaleInLightmap: 1
|
||||||
|
m_ReceiveGI: 1
|
||||||
|
m_PreserveUVs: 0
|
||||||
|
m_IgnoreNormalsForChartDetection: 0
|
||||||
|
m_ImportantGI: 0
|
||||||
|
m_StitchLightmapSeams: 1
|
||||||
|
m_SelectedEditorRenderState: 3
|
||||||
|
m_MinimumChartSize: 4
|
||||||
|
m_AutoUVMaxDistance: 0.5
|
||||||
|
m_AutoUVMaxAngle: 89
|
||||||
|
m_LightmapParameters: {fileID: 0}
|
||||||
|
m_SortingLayerID: 0
|
||||||
|
m_SortingLayer: 0
|
||||||
|
m_SortingOrder: 0
|
||||||
|
m_AdditionalVertexStreams: {fileID: 0}
|
||||||
|
--- !u!65 &1426238303320144522
|
||||||
|
BoxCollider:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 6003361529827848619}
|
||||||
|
m_Material: {fileID: 0}
|
||||||
|
m_IsTrigger: 0
|
||||||
|
m_Enabled: 1
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Size: {x: 1, y: 1, z: 1}
|
||||||
|
m_Center: {x: 0, y: 0, z: 0}
|
||||||
--- !u!1 &8565720275311462453
|
--- !u!1 &8565720275311462453
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
@ -13,7 +108,7 @@ GameObject:
|
||||||
- component: {fileID: 8565720275311462452}
|
- component: {fileID: 8565720275311462452}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: TestNetworkedGameObject
|
m_Name: TestNetworkedGameObject
|
||||||
m_TagString: TestSphere
|
m_TagString: Untagged
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
|
|
@ -29,7 +124,7 @@ Transform:
|
||||||
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: 1, y: 1, z: 1}
|
||||||
m_Children:
|
m_Children:
|
||||||
- {fileID: 8565720276181857624}
|
- {fileID: 7099230484513283147}
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_RootOrder: 0
|
m_RootOrder: 0
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
|
@ -67,98 +162,5 @@ MonoBehaviour:
|
||||||
networkObject: {fileID: 3951900052977689805}
|
networkObject: {fileID: 3951900052977689805}
|
||||||
serializationRateHz: 60
|
serializationRateHz: 60
|
||||||
useLocalTransform: 0
|
useLocalTransform: 0
|
||||||
--- !u!1 &8565720276181857625
|
teleportDistance: 0
|
||||||
GameObject:
|
teleportAngle: 0
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
serializedVersion: 6
|
|
||||||
m_Component:
|
|
||||||
- component: {fileID: 8565720276181857624}
|
|
||||||
- component: {fileID: 8565720276181857605}
|
|
||||||
- component: {fileID: 8565720276181857626}
|
|
||||||
- component: {fileID: 8565720276181857627}
|
|
||||||
m_Layer: 0
|
|
||||||
m_Name: Sphere
|
|
||||||
m_TagString: Untagged
|
|
||||||
m_Icon: {fileID: 0}
|
|
||||||
m_NavMeshLayer: 0
|
|
||||||
m_StaticEditorFlags: 0
|
|
||||||
m_IsActive: 1
|
|
||||||
--- !u!4 &8565720276181857624
|
|
||||||
Transform:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 8565720276181857625}
|
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
|
||||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
|
||||||
m_Children: []
|
|
||||||
m_Father: {fileID: 8565720275311462455}
|
|
||||||
m_RootOrder: 0
|
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
|
||||||
--- !u!33 &8565720276181857605
|
|
||||||
MeshFilter:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 8565720276181857625}
|
|
||||||
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
|
|
||||||
--- !u!23 &8565720276181857626
|
|
||||||
MeshRenderer:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 8565720276181857625}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_CastShadows: 1
|
|
||||||
m_ReceiveShadows: 1
|
|
||||||
m_DynamicOccludee: 1
|
|
||||||
m_MotionVectors: 1
|
|
||||||
m_LightProbeUsage: 1
|
|
||||||
m_ReflectionProbeUsage: 1
|
|
||||||
m_RayTracingMode: 2
|
|
||||||
m_RayTraceProcedural: 0
|
|
||||||
m_RenderingLayerMask: 1
|
|
||||||
m_RendererPriority: 0
|
|
||||||
m_Materials:
|
|
||||||
- {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
|
|
||||||
m_StaticBatchInfo:
|
|
||||||
firstSubMesh: 0
|
|
||||||
subMeshCount: 0
|
|
||||||
m_StaticBatchRoot: {fileID: 0}
|
|
||||||
m_ProbeAnchor: {fileID: 0}
|
|
||||||
m_LightProbeVolumeOverride: {fileID: 0}
|
|
||||||
m_ScaleInLightmap: 1
|
|
||||||
m_ReceiveGI: 1
|
|
||||||
m_PreserveUVs: 0
|
|
||||||
m_IgnoreNormalsForChartDetection: 0
|
|
||||||
m_ImportantGI: 0
|
|
||||||
m_StitchLightmapSeams: 1
|
|
||||||
m_SelectedEditorRenderState: 3
|
|
||||||
m_MinimumChartSize: 4
|
|
||||||
m_AutoUVMaxDistance: 0.5
|
|
||||||
m_AutoUVMaxAngle: 89
|
|
||||||
m_LightmapParameters: {fileID: 0}
|
|
||||||
m_SortingLayerID: 0
|
|
||||||
m_SortingLayer: 0
|
|
||||||
m_SortingOrder: 0
|
|
||||||
m_AdditionalVertexStreams: {fileID: 0}
|
|
||||||
--- !u!135 &8565720276181857627
|
|
||||||
SphereCollider:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 8565720276181857625}
|
|
||||||
m_Material: {fileID: 0}
|
|
||||||
m_IsTrigger: 0
|
|
||||||
m_Enabled: 1
|
|
||||||
serializedVersion: 2
|
|
||||||
m_Radius: 0.5
|
|
||||||
m_Center: {x: 0, y: 0, z: 0}
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,79 @@
|
||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!21 &2100000
|
||||||
|
Material:
|
||||||
|
serializedVersion: 6
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_Name: TransparentMat
|
||||||
|
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
|
||||||
|
m_ShaderKeywords: _ALPHAPREMULTIPLY_ON _GLOSSYREFLECTIONS_OFF _SPECULARHIGHLIGHTS_OFF
|
||||||
|
m_LightmapFlags: 4
|
||||||
|
m_EnableInstancingVariants: 0
|
||||||
|
m_DoubleSidedGI: 0
|
||||||
|
m_CustomRenderQueue: 3000
|
||||||
|
stringTagMap:
|
||||||
|
RenderType: Transparent
|
||||||
|
disabledShaderPasses: []
|
||||||
|
m_SavedProperties:
|
||||||
|
serializedVersion: 3
|
||||||
|
m_TexEnvs:
|
||||||
|
- _BumpMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _DetailAlbedoMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _DetailMask:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _DetailNormalMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _EmissionMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _MainTex:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _MetallicGlossMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _OcclusionMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _ParallaxMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
m_Floats:
|
||||||
|
- _BumpScale: 1
|
||||||
|
- _Cutoff: 0.5
|
||||||
|
- _DetailNormalMapScale: 1
|
||||||
|
- _DstBlend: 10
|
||||||
|
- _GlossMapScale: 1
|
||||||
|
- _Glossiness: 0.5
|
||||||
|
- _GlossyReflections: 0
|
||||||
|
- _Metallic: 0
|
||||||
|
- _Mode: 3
|
||||||
|
- _OcclusionStrength: 1
|
||||||
|
- _Parallax: 0.02
|
||||||
|
- _SmoothnessTextureChannel: 0
|
||||||
|
- _SpecularHighlights: 0
|
||||||
|
- _SrcBlend: 1
|
||||||
|
- _UVSec: 0
|
||||||
|
- _ZWrite: 0
|
||||||
|
m_Colors:
|
||||||
|
- _Color: {r: 1, g: 1, b: 1, a: 0.03137255}
|
||||||
|
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||||
|
m_BuildTextureStacks: []
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 6fad1ca32acea73489c2c4b898cdb9d4
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 2100000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 009dc4ba29f14b649beb8c3eaad89f15
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
|
@ -20,13 +20,13 @@ RenderSettings:
|
||||||
m_FogDensity: 0.01
|
m_FogDensity: 0.01
|
||||||
m_LinearFogStart: 0
|
m_LinearFogStart: 0
|
||||||
m_LinearFogEnd: 300
|
m_LinearFogEnd: 300
|
||||||
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
|
m_AmbientSkyColor: {r: 0.5137255, g: 0.53333336, b: 0.5647059, a: 1}
|
||||||
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
|
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
|
||||||
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
|
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
|
||||||
m_AmbientIntensity: 1
|
m_AmbientIntensity: 1
|
||||||
m_AmbientMode: 0
|
m_AmbientMode: 3
|
||||||
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
|
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
|
||||||
m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
|
m_SkyboxMaterial: {fileID: 0}
|
||||||
m_HaloStrength: 0.5
|
m_HaloStrength: 0.5
|
||||||
m_FlareStrength: 1
|
m_FlareStrength: 1
|
||||||
m_FlareFadeSpeed: 3
|
m_FlareFadeSpeed: 3
|
||||||
|
|
@ -37,8 +37,8 @@ RenderSettings:
|
||||||
m_ReflectionBounces: 1
|
m_ReflectionBounces: 1
|
||||||
m_ReflectionIntensity: 1
|
m_ReflectionIntensity: 1
|
||||||
m_CustomReflection: {fileID: 0}
|
m_CustomReflection: {fileID: 0}
|
||||||
m_Sun: {fileID: 0}
|
m_Sun: {fileID: 652307110}
|
||||||
m_IndirectSpecularColor: {r: 0.44657898, g: 0.4964133, b: 0.5748178, a: 1}
|
m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1}
|
||||||
m_UseRadianceAmbientProbe: 0
|
m_UseRadianceAmbientProbe: 0
|
||||||
--- !u!157 &3
|
--- !u!157 &3
|
||||||
LightmapSettings:
|
LightmapSettings:
|
||||||
|
|
@ -97,7 +97,7 @@ LightmapSettings:
|
||||||
m_ExportTrainingData: 0
|
m_ExportTrainingData: 0
|
||||||
m_TrainingDataDestination: TrainingData
|
m_TrainingDataDestination: TrainingData
|
||||||
m_LightProbeSampleCountMultiplier: 4
|
m_LightProbeSampleCountMultiplier: 4
|
||||||
m_LightingDataAsset: {fileID: 0}
|
m_LightingDataAsset: {fileID: 112000000, guid: d1b34f106c04378428823df374b0e07c, type: 2}
|
||||||
m_LightingSettings: {fileID: 0}
|
m_LightingSettings: {fileID: 0}
|
||||||
--- !u!196 &4
|
--- !u!196 &4
|
||||||
NavMeshSettings:
|
NavMeshSettings:
|
||||||
|
|
@ -608,7 +608,7 @@ RectTransform:
|
||||||
- {fileID: 948755938}
|
- {fileID: 948755938}
|
||||||
- {fileID: 545137760}
|
- {fileID: 545137760}
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_RootOrder: 4
|
m_RootOrder: 2
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0, y: 0}
|
m_AnchorMin: {x: 0, y: 0}
|
||||||
m_AnchorMax: {x: 0, y: 0}
|
m_AnchorMax: {x: 0, y: 0}
|
||||||
|
|
@ -779,6 +779,85 @@ Transform:
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_RootOrder: 5
|
m_RootOrder: 5
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!1 &498776799
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 498776800}
|
||||||
|
- component: {fileID: 498776802}
|
||||||
|
- component: {fileID: 498776801}
|
||||||
|
m_Layer: 5
|
||||||
|
m_Name: Text
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!224 &498776800
|
||||||
|
RectTransform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 498776799}
|
||||||
|
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||||
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 1992361063}
|
||||||
|
m_RootOrder: 0
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
m_AnchorMin: {x: 0, y: 0}
|
||||||
|
m_AnchorMax: {x: 1, y: 1}
|
||||||
|
m_AnchoredPosition: {x: 0, y: 0}
|
||||||
|
m_SizeDelta: {x: 0, y: 0}
|
||||||
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
|
--- !u!114 &498776801
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 498776799}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
m_Material: {fileID: 0}
|
||||||
|
m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
|
||||||
|
m_RaycastTarget: 1
|
||||||
|
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
m_Maskable: 1
|
||||||
|
m_OnCullStateChanged:
|
||||||
|
m_PersistentCalls:
|
||||||
|
m_Calls: []
|
||||||
|
m_FontData:
|
||||||
|
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
||||||
|
m_FontSize: 14
|
||||||
|
m_FontStyle: 0
|
||||||
|
m_BestFit: 0
|
||||||
|
m_MinSize: 10
|
||||||
|
m_MaxSize: 40
|
||||||
|
m_Alignment: 4
|
||||||
|
m_AlignByGeometry: 0
|
||||||
|
m_RichText: 1
|
||||||
|
m_HorizontalOverflow: 0
|
||||||
|
m_VerticalOverflow: 0
|
||||||
|
m_LineSpacing: 1
|
||||||
|
m_Text: Take Ownership
|
||||||
|
--- !u!222 &498776802
|
||||||
|
CanvasRenderer:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 498776799}
|
||||||
|
m_CullTransparentMesh: 1
|
||||||
--- !u!1 &545137759
|
--- !u!1 &545137759
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
@ -813,11 +892,11 @@ RectTransform:
|
||||||
m_Father: {fileID: 244561620}
|
m_Father: {fileID: 244561620}
|
||||||
m_RootOrder: 10
|
m_RootOrder: 10
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
m_AnchorMin: {x: 0, y: 0}
|
||||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
m_AnchorMax: {x: 0, y: 0}
|
||||||
m_AnchoredPosition: {x: -382, y: -321}
|
m_AnchoredPosition: {x: 5, y: 165.7}
|
||||||
m_SizeDelta: {x: 160, y: 30}
|
m_SizeDelta: {x: 160, y: 30}
|
||||||
m_Pivot: {x: 0.5, y: 0.5}
|
m_Pivot: {x: 0, y: 0}
|
||||||
--- !u!114 &545137761
|
--- !u!114 &545137761
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
@ -1221,7 +1300,7 @@ Transform:
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_RootOrder: 1
|
m_RootOrder: 4
|
||||||
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
|
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
|
||||||
--- !u!1 &711524766
|
--- !u!1 &711524766
|
||||||
GameObject:
|
GameObject:
|
||||||
|
|
@ -1629,7 +1708,7 @@ Camera:
|
||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_ClearFlags: 1
|
m_ClearFlags: 1
|
||||||
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
|
m_BackGroundColor: {r: 0.2735849, g: 0.2735849, b: 0.2735849, a: 0}
|
||||||
m_projectionMatrixMode: 1
|
m_projectionMatrixMode: 1
|
||||||
m_GateFitMode: 2
|
m_GateFitMode: 2
|
||||||
m_FOVAxisMode: 0
|
m_FOVAxisMode: 0
|
||||||
|
|
@ -1644,7 +1723,7 @@ Camera:
|
||||||
height: 1
|
height: 1
|
||||||
near clip plane: 0.3
|
near clip plane: 0.3
|
||||||
far clip plane: 1000
|
far clip plane: 1000
|
||||||
field of view: 60
|
field of view: 40
|
||||||
orthographic: 0
|
orthographic: 0
|
||||||
orthographic size: 5
|
orthographic size: 5
|
||||||
m_Depth: -1
|
m_Depth: -1
|
||||||
|
|
@ -1670,11 +1749,11 @@ Transform:
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 903768653}
|
m_GameObject: {fileID: 903768653}
|
||||||
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: 1, z: -10}
|
m_LocalPosition: {x: 0, y: 1, z: -20}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_RootOrder: 0
|
m_RootOrder: 3
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!1 &912887455
|
--- !u!1 &912887455
|
||||||
GameObject:
|
GameObject:
|
||||||
|
|
@ -2051,6 +2130,7 @@ RectTransform:
|
||||||
m_Children:
|
m_Children:
|
||||||
- {fileID: 359309141}
|
- {fileID: 359309141}
|
||||||
- {fileID: 1840952814}
|
- {fileID: 1840952814}
|
||||||
|
- {fileID: 1992361063}
|
||||||
m_Father: {fileID: 244561620}
|
m_Father: {fileID: 244561620}
|
||||||
m_RootOrder: 9
|
m_RootOrder: 9
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
|
@ -2088,6 +2168,7 @@ MonoBehaviour:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
ownershipLocked: 0
|
ownershipLocked: 0
|
||||||
networkId:
|
networkId:
|
||||||
|
sceneNetworkId: 2
|
||||||
prefabName:
|
prefabName:
|
||||||
isSceneObject: 1
|
isSceneObject: 1
|
||||||
syncedComponents:
|
syncedComponents:
|
||||||
|
|
@ -2440,7 +2521,7 @@ Transform:
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_RootOrder: 3
|
m_RootOrder: 0
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!114 &1099803616
|
--- !u!114 &1099803616
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
|
|
@ -2454,11 +2535,10 @@ MonoBehaviour:
|
||||||
m_Script: {fileID: 11500000, guid: 233344de094f11341bdb834d564708dc, type: 3}
|
m_Script: {fileID: 11500000, guid: 233344de094f11341bdb834d564708dc, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
host: 127.0.0.1
|
host: 129.159.107.234
|
||||||
port: 80
|
port: 80
|
||||||
udpConnected: 0
|
udpConnected: 0
|
||||||
userid: -1
|
userid: -1
|
||||||
room:
|
|
||||||
connected: 0
|
connected: 0
|
||||||
prefabs:
|
prefabs:
|
||||||
- {fileID: 9102273340480352682, guid: d4158ab9c4a204cdbba28d3273fc1fb3, type: 3}
|
- {fileID: 9102273340480352682, guid: d4158ab9c4a204cdbba28d3273fc1fb3, type: 3}
|
||||||
|
|
@ -3007,7 +3087,7 @@ Transform:
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_RootOrder: 2
|
m_RootOrder: 1
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!114 &1434745021
|
--- !u!114 &1434745021
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
|
|
@ -3793,7 +3873,7 @@ GameObject:
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
m_IsActive: 1
|
m_IsActive: 0
|
||||||
--- !u!224 &1894247853
|
--- !u!224 &1894247853
|
||||||
RectTransform:
|
RectTransform:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
@ -3934,6 +4014,139 @@ RectTransform:
|
||||||
m_AnchoredPosition: {x: 0, y: -0.5}
|
m_AnchoredPosition: {x: 0, y: -0.5}
|
||||||
m_SizeDelta: {x: -20, y: -13}
|
m_SizeDelta: {x: -20, y: -13}
|
||||||
m_Pivot: {x: 0.5, y: 0.5}
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
|
--- !u!1 &1992361062
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 1992361063}
|
||||||
|
- component: {fileID: 1992361066}
|
||||||
|
- component: {fileID: 1992361065}
|
||||||
|
- component: {fileID: 1992361064}
|
||||||
|
m_Layer: 5
|
||||||
|
m_Name: Button
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!224 &1992361063
|
||||||
|
RectTransform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1992361062}
|
||||||
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_Children:
|
||||||
|
- {fileID: 498776800}
|
||||||
|
m_Father: {fileID: 948755938}
|
||||||
|
m_RootOrder: 2
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
m_AnchorMin: {x: 1, y: 1}
|
||||||
|
m_AnchorMax: {x: 1, y: 1}
|
||||||
|
m_AnchoredPosition: {x: 0, y: 31.6}
|
||||||
|
m_SizeDelta: {x: 160, y: 30}
|
||||||
|
m_Pivot: {x: 1, y: 1}
|
||||||
|
--- !u!114 &1992361064
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1992361062}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
m_Navigation:
|
||||||
|
m_Mode: 3
|
||||||
|
m_WrapAround: 0
|
||||||
|
m_SelectOnUp: {fileID: 0}
|
||||||
|
m_SelectOnDown: {fileID: 0}
|
||||||
|
m_SelectOnLeft: {fileID: 0}
|
||||||
|
m_SelectOnRight: {fileID: 0}
|
||||||
|
m_Transition: 1
|
||||||
|
m_Colors:
|
||||||
|
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
|
||||||
|
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
|
||||||
|
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
|
||||||
|
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
|
||||||
|
m_ColorMultiplier: 1
|
||||||
|
m_FadeDuration: 0.1
|
||||||
|
m_SpriteState:
|
||||||
|
m_HighlightedSprite: {fileID: 0}
|
||||||
|
m_PressedSprite: {fileID: 0}
|
||||||
|
m_SelectedSprite: {fileID: 0}
|
||||||
|
m_DisabledSprite: {fileID: 0}
|
||||||
|
m_AnimationTriggers:
|
||||||
|
m_NormalTrigger: Normal
|
||||||
|
m_HighlightedTrigger: Highlighted
|
||||||
|
m_PressedTrigger: Pressed
|
||||||
|
m_SelectedTrigger: Selected
|
||||||
|
m_DisabledTrigger: Disabled
|
||||||
|
m_Interactable: 1
|
||||||
|
m_TargetGraphic: {fileID: 1992361065}
|
||||||
|
m_OnClick:
|
||||||
|
m_PersistentCalls:
|
||||||
|
m_Calls:
|
||||||
|
- m_Target: {fileID: 948755939}
|
||||||
|
m_TargetAssemblyTypeName: SyncedTextbox, Assembly-CSharp
|
||||||
|
m_MethodName: TakeOwnership
|
||||||
|
m_Mode: 1
|
||||||
|
m_Arguments:
|
||||||
|
m_ObjectArgument: {fileID: 0}
|
||||||
|
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
|
||||||
|
m_IntArgument: 0
|
||||||
|
m_FloatArgument: 0
|
||||||
|
m_StringArgument:
|
||||||
|
m_BoolArgument: 0
|
||||||
|
m_CallState: 2
|
||||||
|
--- !u!114 &1992361065
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1992361062}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
m_Material: {fileID: 0}
|
||||||
|
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
m_RaycastTarget: 1
|
||||||
|
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
m_Maskable: 1
|
||||||
|
m_OnCullStateChanged:
|
||||||
|
m_PersistentCalls:
|
||||||
|
m_Calls: []
|
||||||
|
m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0}
|
||||||
|
m_Type: 1
|
||||||
|
m_PreserveAspect: 0
|
||||||
|
m_FillCenter: 1
|
||||||
|
m_FillMethod: 4
|
||||||
|
m_FillAmount: 1
|
||||||
|
m_FillClockwise: 1
|
||||||
|
m_FillOrigin: 0
|
||||||
|
m_UseSpriteMesh: 0
|
||||||
|
m_PixelsPerUnitMultiplier: 1
|
||||||
|
--- !u!222 &1992361066
|
||||||
|
CanvasRenderer:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1992361062}
|
||||||
|
m_CullTransparentMesh: 1
|
||||||
--- !u!1 &2033163676
|
--- !u!1 &2033163676
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
@ -4174,8 +4387,8 @@ PrefabInstance:
|
||||||
propertyPath: isSceneObject
|
propertyPath: isSceneObject
|
||||||
value: 1
|
value: 1
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 8565720275311462452, guid: 6e4a023f70e01405e8b249a4488fe319, type: 3}
|
- target: {fileID: 3951900052977689805, guid: 6e4a023f70e01405e8b249a4488fe319, type: 3}
|
||||||
propertyPath: serializationRateHz
|
propertyPath: sceneNetworkId
|
||||||
value: 1
|
value: 1
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 8565720275311462453, guid: 6e4a023f70e01405e8b249a4488fe319, type: 3}
|
- target: {fileID: 8565720275311462453, guid: 6e4a023f70e01405e8b249a4488fe319, type: 3}
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d1b34f106c04378428823df374b0e07c
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 112000000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
|
@ -8,6 +8,8 @@ namespace VelNet
|
||||||
{
|
{
|
||||||
public static class BinaryWriterExtensions
|
public static class BinaryWriterExtensions
|
||||||
{
|
{
|
||||||
|
#region Writers
|
||||||
|
|
||||||
public static void Write(this BinaryWriter writer, Vector3 v)
|
public static void Write(this BinaryWriter writer, Vector3 v)
|
||||||
{
|
{
|
||||||
writer.Write(v.x);
|
writer.Write(v.x);
|
||||||
|
|
@ -23,6 +25,18 @@ namespace VelNet
|
||||||
writer.Write(q.w);
|
writer.Write(q.w);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void Write(this BinaryWriter writer, Color c)
|
||||||
|
{
|
||||||
|
writer.Write(c.r);
|
||||||
|
writer.Write(c.g);
|
||||||
|
writer.Write(c.b);
|
||||||
|
writer.Write(c.a);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Readers
|
||||||
|
|
||||||
public static Vector3 ReadVector3(this BinaryReader reader)
|
public static Vector3 ReadVector3(this BinaryReader reader)
|
||||||
{
|
{
|
||||||
return new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
|
return new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
|
||||||
|
|
@ -31,19 +45,32 @@ namespace VelNet
|
||||||
public static Quaternion ReadQuaternion(this BinaryReader reader)
|
public static Quaternion ReadQuaternion(this BinaryReader reader)
|
||||||
{
|
{
|
||||||
return new Quaternion(
|
return new Quaternion(
|
||||||
reader.ReadSingle(),
|
reader.ReadSingle(),
|
||||||
reader.ReadSingle(),
|
reader.ReadSingle(),
|
||||||
reader.ReadSingle(),
|
reader.ReadSingle(),
|
||||||
reader.ReadSingle()
|
reader.ReadSingle()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Color ReadColor(this BinaryReader reader)
|
||||||
|
{
|
||||||
|
return new Color(
|
||||||
|
reader.ReadSingle(),
|
||||||
|
reader.ReadSingle(),
|
||||||
|
reader.ReadSingle(),
|
||||||
|
reader.ReadSingle()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Compresses the list of bools into bytes using a bitmask
|
/// Compresses the list of bools into bytes using a bitmask
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static byte[] GetBitmasks(this IEnumerable<bool> bools)
|
public static byte[] GetBitmasks(this IEnumerable<bool> bools)
|
||||||
{
|
{
|
||||||
List<bool> values = bools.ToList();
|
List<bool> values = bools.ToList();
|
||||||
List<byte> bytes = new List<byte>();
|
List<byte> bytes = new List<byte>();
|
||||||
for (int b = 0; b < Mathf.Ceil(values.Count / 8f); b++)
|
for (int b = 0; b < Mathf.Ceil(values.Count / 8f); b++)
|
||||||
{
|
{
|
||||||
|
|
@ -61,7 +88,7 @@ namespace VelNet
|
||||||
|
|
||||||
return bytes.ToArray();
|
return bytes.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<bool> GetBitmaskValues(this IEnumerable<byte> bytes)
|
public static List<bool> GetBitmaskValues(this IEnumerable<byte> bytes)
|
||||||
{
|
{
|
||||||
List<bool> l = new List<bool>();
|
List<bool> l = new List<bool>();
|
||||||
|
|
@ -72,7 +99,7 @@ namespace VelNet
|
||||||
|
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<bool> GetBitmaskValues(this byte b)
|
public static List<bool> GetBitmaskValues(this byte b)
|
||||||
{
|
{
|
||||||
List<bool> l = new List<bool>();
|
List<bool> l = new List<bool>();
|
||||||
|
|
@ -83,11 +110,10 @@ namespace VelNet
|
||||||
|
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool GetBitmaskValue(this byte b, int index)
|
public static bool GetBitmaskValue(this byte b, int index)
|
||||||
{
|
{
|
||||||
return (b & (1 << index)) != 0;
|
return (b & (1 << index)) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
|
|
@ -8,8 +7,6 @@ using System.Threading;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using UnityEngine.SceneManagement;
|
using UnityEngine.SceneManagement;
|
||||||
using System.Runtime.Serialization.Formatters.Binary;
|
|
||||||
using System.Runtime.Serialization;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
namespace VelNet
|
namespace VelNet
|
||||||
|
|
@ -42,10 +39,11 @@ namespace VelNet
|
||||||
private Thread clientReceiveThread;
|
private Thread clientReceiveThread;
|
||||||
private Thread clientReceiveThreadUDP;
|
private Thread clientReceiveThreadUDP;
|
||||||
public int userid = -1;
|
public int userid = -1;
|
||||||
private int messagesReceived = 0;
|
|
||||||
|
|
||||||
public readonly Dictionary<int, VelNetPlayer> players = new Dictionary<int, VelNetPlayer>();
|
public readonly Dictionary<int, VelNetPlayer> players = new Dictionary<int, VelNetPlayer>();
|
||||||
|
|
||||||
|
#region Callbacks
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// We just joined a room
|
/// We just joined a room
|
||||||
/// string - the room name
|
/// string - the room name
|
||||||
|
|
@ -69,8 +67,12 @@ namespace VelNet
|
||||||
public static Action<VelNetPlayer> OnPlayerLeft;
|
public static Action<VelNetPlayer> OnPlayerLeft;
|
||||||
|
|
||||||
public static Action OnConnectedToServer;
|
public static Action OnConnectedToServer;
|
||||||
public static Action LoggedIn;
|
public static Action OnLoggedIn;
|
||||||
public static Action<string[], int> RoomsReceived;
|
public static Action<RoomsMessage> RoomsReceived;
|
||||||
|
|
||||||
|
public static Action<Message> MessageReceived;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
public bool connected;
|
public bool connected;
|
||||||
|
|
||||||
|
|
@ -92,7 +94,7 @@ namespace VelNet
|
||||||
public static VelNetPlayer LocalPlayer => instance != null ? instance.players.Where(p => p.Value.isLocal).Select(p => p.Value).FirstOrDefault() : null;
|
public static VelNetPlayer LocalPlayer => instance != null ? instance.players.Where(p => p.Value.isLocal).Select(p => p.Value).FirstOrDefault() : null;
|
||||||
public static bool InRoom => LocalPlayer != null && LocalPlayer.room != "-1" && LocalPlayer.room != "";
|
public static bool InRoom => LocalPlayer != null && LocalPlayer.room != "-1" && LocalPlayer.room != "";
|
||||||
public static string Room => LocalPlayer?.room;
|
public static string Room => LocalPlayer?.room;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The player count in this room.
|
/// The player count in this room.
|
||||||
/// -1 if not in a room.
|
/// -1 if not in a room.
|
||||||
|
|
@ -107,46 +109,59 @@ namespace VelNet
|
||||||
|
|
||||||
public static bool IsConnected => instance != null && instance.connected && instance.udpConnected;
|
public static bool IsConnected => instance != null && instance.connected && instance.udpConnected;
|
||||||
|
|
||||||
|
|
||||||
//this is for sending udp packets
|
//this is for sending udp packets
|
||||||
static byte[] toSend = new byte[1024];
|
private static readonly byte[] toSend = new byte[1024];
|
||||||
|
|
||||||
// Use this for initialization
|
// Use this for initialization
|
||||||
public abstract class Message
|
public abstract class Message
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ListedRoom
|
public class ListedRoom
|
||||||
{
|
{
|
||||||
public string name;
|
public string name;
|
||||||
public int numUsers;
|
public int numUsers;
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return "Room Name: " + name + "\tUsers: " + numUsers;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public class LoginMessage: Message
|
|
||||||
|
public class LoginMessage : Message
|
||||||
{
|
{
|
||||||
public int userId;
|
public int userId;
|
||||||
}
|
}
|
||||||
public class RoomsMessage: Message
|
|
||||||
|
public class RoomsMessage : Message
|
||||||
{
|
{
|
||||||
public List<ListedRoom> rooms;
|
public List<ListedRoom> rooms;
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return string.Join("\n", rooms);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public class JoinMessage: Message
|
|
||||||
|
public class JoinMessage : Message
|
||||||
{
|
{
|
||||||
public int userId;
|
public int userId;
|
||||||
public string room;
|
public string room;
|
||||||
}
|
}
|
||||||
public class DataMessage: Message
|
|
||||||
|
public class DataMessage : Message
|
||||||
{
|
{
|
||||||
public int senderId;
|
public int senderId;
|
||||||
public byte[] data;
|
public byte[] data;
|
||||||
}
|
}
|
||||||
public class ChangeMasterMessage: Message
|
|
||||||
|
public class ChangeMasterMessage : Message
|
||||||
{
|
{
|
||||||
public int masterId;
|
public int masterId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ConnectedMessage: Message
|
public class ConnectedMessage : Message
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public readonly List<Message> receivedMessages = new List<Message>();
|
public readonly List<Message> receivedMessages = new List<Message>();
|
||||||
|
|
@ -180,6 +195,15 @@ namespace VelNet
|
||||||
//Debug.Log(messagesReceived++);
|
//Debug.Log(messagesReceived++);
|
||||||
receivedMessages.Add(m);
|
receivedMessages.Add(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
MessageReceived?.Invoke(m);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Debug.LogError(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
|
|
@ -191,216 +215,236 @@ namespace VelNet
|
||||||
{
|
{
|
||||||
switch (m)
|
switch (m)
|
||||||
{
|
{
|
||||||
case ConnectedMessage connected:
|
case ConnectedMessage msg:
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
try
|
OnConnectedToServer?.Invoke();
|
||||||
{
|
|
||||||
OnConnectedToServer?.Invoke();
|
|
||||||
}
|
|
||||||
// prevent errors in subscribers from breaking our code
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Debug.LogError(e);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
// prevent errors in subscribers from breaking our code
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Debug.LogError(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
case LoginMessage lm:
|
case LoginMessage lm:
|
||||||
|
{
|
||||||
|
userid = lm.userId;
|
||||||
|
Debug.Log("Joined server " + userid);
|
||||||
|
|
||||||
|
try
|
||||||
{
|
{
|
||||||
userid = lm.userId;
|
OnLoggedIn?.Invoke();
|
||||||
Debug.Log("joined server " + userid);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
LoggedIn?.Invoke();
|
|
||||||
}
|
|
||||||
// prevent errors in subscribers from breaking our code
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Debug.LogError(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
//start the udp thread
|
|
||||||
clientReceiveThreadUDP = new Thread(ListenForDataUDP);
|
|
||||||
clientReceiveThreadUDP.IsBackground = true;
|
|
||||||
clientReceiveThreadUDP.Start();
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case RoomsMessage rm: {
|
// prevent errors in subscribers from breaking our code
|
||||||
Debug.Log("Got Rooms Message");
|
catch (Exception e)
|
||||||
|
{
|
||||||
break;
|
Debug.LogError(e);
|
||||||
}
|
}
|
||||||
case JoinMessage jm: {
|
|
||||||
if(userid == jm.userId) //this is us
|
//start the udp thread
|
||||||
|
clientReceiveThreadUDP = new Thread(ListenForDataUDP);
|
||||||
|
clientReceiveThreadUDP.Start();
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case RoomsMessage rm:
|
||||||
|
{
|
||||||
|
Debug.Log("Got Rooms Message:\n" + rm);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
RoomsReceived?.Invoke(rm);
|
||||||
|
}
|
||||||
|
// prevent errors in subscribers from breaking our code
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Debug.LogError(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case JoinMessage jm:
|
||||||
|
{
|
||||||
|
if (userid == jm.userId) //this is us
|
||||||
|
{
|
||||||
|
string oldRoom = LocalPlayer?.room;
|
||||||
|
|
||||||
|
// we clear the list, but will recreate as we get messages from people in our room
|
||||||
|
players.Clear();
|
||||||
|
masterPlayer = null;
|
||||||
|
|
||||||
|
if (jm.room != "")
|
||||||
{
|
{
|
||||||
string oldRoom = LocalPlayer?.room;
|
VelNetPlayer player = new VelNetPlayer
|
||||||
|
|
||||||
// we clear the list, but will recreate as we get messages from people in our room
|
|
||||||
players.Clear();
|
|
||||||
masterPlayer = null;
|
|
||||||
|
|
||||||
if (jm.room != "")
|
|
||||||
{
|
{
|
||||||
VelNetPlayer player = new VelNetPlayer
|
isLocal = true,
|
||||||
{
|
userid = jm.userId,
|
||||||
isLocal = true,
|
room = jm.room
|
||||||
userid = jm.userId,
|
};
|
||||||
room = jm.room
|
|
||||||
};
|
|
||||||
|
|
||||||
players.Add(userid, player);
|
players.Add(userid, player);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
OnJoinedRoom?.Invoke(jm.room);
|
OnJoinedRoom?.Invoke(jm.room);
|
||||||
}
|
|
||||||
// prevent errors in subscribers from breaking our code
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Debug.LogError(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
// we just left a room
|
// prevent errors in subscribers from breaking our code
|
||||||
else
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
// delete all networkobjects that aren't sceneobjects or are null now
|
Debug.LogError(e);
|
||||||
objects
|
|
||||||
.Where(kvp => kvp.Value == null || !kvp.Value.isSceneObject)
|
|
||||||
.Select(o => o.Key)
|
|
||||||
.ToList().ForEach(NetworkDestroy);
|
|
||||||
|
|
||||||
// then remove references to the ones that are left
|
|
||||||
objects.Clear();
|
|
||||||
|
|
||||||
// empty all the groups
|
|
||||||
foreach (string group in instance.groups.Keys)
|
|
||||||
{
|
|
||||||
SetupMessageGroup(group, new List<int>());
|
|
||||||
}
|
|
||||||
|
|
||||||
instance.groups.Clear();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
OnLeftRoom?.Invoke(oldRoom);
|
|
||||||
}
|
|
||||||
// prevent errors in subscribers from breaking our code
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Debug.LogError(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// we just left a room
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
VelNetPlayer me = players[userid];
|
// delete all networkobjects that aren't sceneobjects or are null now
|
||||||
|
objects
|
||||||
|
.Where(kvp => kvp.Value == null || !kvp.Value.isSceneObject)
|
||||||
|
.Select(o => o.Key)
|
||||||
|
.ToList().ForEach(NetworkDestroy);
|
||||||
|
|
||||||
if (me.room != jm.room)
|
// then remove references to the ones that are left
|
||||||
|
objects.Clear();
|
||||||
|
|
||||||
|
// empty all the groups
|
||||||
|
foreach (string group in instance.groups.Keys)
|
||||||
{
|
{
|
||||||
// we got a left message, kill it
|
SetupMessageGroup(group, new List<int>());
|
||||||
// change ownership of all objects to master
|
}
|
||||||
List<string> deleteObjects = new List<string>();
|
|
||||||
foreach (KeyValuePair<string, NetworkObject> kvp in objects)
|
instance.groups.Clear();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
OnLeftRoom?.Invoke(oldRoom);
|
||||||
|
}
|
||||||
|
// prevent errors in subscribers from breaking our code
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Debug.LogError(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
VelNetPlayer me = players[userid];
|
||||||
|
|
||||||
|
if (me.room != jm.room)
|
||||||
|
{
|
||||||
|
// we got a left message, kill it
|
||||||
|
// change ownership of all objects to master
|
||||||
|
List<string> deleteObjects = new List<string>();
|
||||||
|
foreach (KeyValuePair<string, NetworkObject> kvp in objects)
|
||||||
|
{
|
||||||
|
if (kvp.Value.owner == players[jm.userId]) // the owner is the player that left
|
||||||
{
|
{
|
||||||
if (kvp.Value.owner == players[jm.userId]) // the owner is the player that left
|
// if this object has locked ownership, delete it
|
||||||
|
if (kvp.Value.ownershipLocked)
|
||||||
{
|
{
|
||||||
// if this object has locked ownership, delete it
|
deleteObjects.Add(kvp.Value.networkId);
|
||||||
if (kvp.Value.ownershipLocked)
|
}
|
||||||
{
|
// I'm the local master player, so can take ownership immediately
|
||||||
deleteObjects.Add(kvp.Value.networkId);
|
else if (me.isLocal && me == masterPlayer)
|
||||||
}
|
{
|
||||||
// I'm the local master player, so can take ownership immediately
|
TakeOwnership(kvp.Key);
|
||||||
else if (me.isLocal && me == masterPlayer)
|
}
|
||||||
{
|
// the master player left, so everyone should set the owner null (we should get a new master shortly)
|
||||||
TakeOwnership(kvp.Key);
|
else if (players[jm.userId] == masterPlayer)
|
||||||
}
|
{
|
||||||
// the master player left, so everyone should set the owner null (we should get a new master shortly)
|
kvp.Value.owner = null;
|
||||||
else if (players[jm.userId] == masterPlayer)
|
|
||||||
{
|
|
||||||
kvp.Value.owner = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO this may check for ownership in the future. We don't need ownership here
|
|
||||||
deleteObjects.ForEach(NetworkDestroy);
|
|
||||||
|
|
||||||
players.Remove(jm.userId);
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
// TODO this may check for ownership in the future. We don't need ownership here
|
||||||
|
deleteObjects.ForEach(NetworkDestroy);
|
||||||
|
|
||||||
|
VelNetPlayer leftPlayer = players[jm.userId];
|
||||||
|
players.Remove(jm.userId);
|
||||||
|
|
||||||
|
try
|
||||||
{
|
{
|
||||||
// we got a join message, create it
|
OnPlayerLeft?.Invoke(leftPlayer);
|
||||||
VelNetPlayer player = new VelNetPlayer
|
|
||||||
{
|
|
||||||
isLocal = false,
|
|
||||||
room = jm.room,
|
|
||||||
userid = jm.userId
|
|
||||||
};
|
|
||||||
players.Add(jm.userId, player);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
OnPlayerJoined?.Invoke(player);
|
|
||||||
}
|
|
||||||
// prevent errors in subscribers from breaking our code
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Debug.LogError(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
// prevent errors in subscribers from breaking our code
|
||||||
break;
|
catch (Exception e)
|
||||||
|
|
||||||
}
|
|
||||||
case DataMessage dm: {
|
|
||||||
if (players.ContainsKey(dm.senderId))
|
|
||||||
{
|
|
||||||
players[dm.senderId]?.HandleMessage(dm); //todo
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Debug.LogError("Received message from player that doesn't exist ");
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
case ChangeMasterMessage cm: {
|
|
||||||
|
|
||||||
if (masterPlayer == null)
|
|
||||||
{
|
|
||||||
masterPlayer = players[cm.masterId];
|
|
||||||
|
|
||||||
// no master player yet, add the scene objects
|
|
||||||
|
|
||||||
for (int i = 0; i < sceneObjects.Length; i++)
|
|
||||||
{
|
{
|
||||||
sceneObjects[i].networkId = -1 + "-" + i;
|
Debug.LogError(e);
|
||||||
sceneObjects[i].owner = masterPlayer;
|
|
||||||
sceneObjects[i].isSceneObject = true; // needed for special handling when deleted
|
|
||||||
objects.Add(sceneObjects[i].networkId, sceneObjects[i]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
masterPlayer = players[cm.masterId];
|
// we got a join message, create it
|
||||||
|
VelNetPlayer player = new VelNetPlayer
|
||||||
|
{
|
||||||
|
isLocal = false,
|
||||||
|
room = jm.room,
|
||||||
|
userid = jm.userId
|
||||||
|
};
|
||||||
|
players.Add(jm.userId, player);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
OnPlayerJoined?.Invoke(player);
|
||||||
|
}
|
||||||
|
// prevent errors in subscribers from breaking our code
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Debug.LogError(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
masterPlayer.SetAsMasterPlayer();
|
|
||||||
|
|
||||||
// master player should take over any objects that do not have an owner
|
|
||||||
foreach (KeyValuePair<string, NetworkObject> kvp in objects)
|
|
||||||
{
|
|
||||||
kvp.Value.owner ??= masterPlayer;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DataMessage dm:
|
||||||
|
{
|
||||||
|
if (players.ContainsKey(dm.senderId))
|
||||||
|
{
|
||||||
|
players[dm.senderId]?.HandleMessage(dm); //todo
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.LogError("Received message from player that doesn't exist ");
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ChangeMasterMessage cm:
|
||||||
|
{
|
||||||
|
if (masterPlayer == null)
|
||||||
|
{
|
||||||
|
masterPlayer = players[cm.masterId];
|
||||||
|
|
||||||
|
// no master player yet, add the scene objects
|
||||||
|
|
||||||
|
for (int i = 0; i < sceneObjects.Length; i++)
|
||||||
|
{
|
||||||
|
sceneObjects[i].networkId = -1 + "-" + i;
|
||||||
|
sceneObjects[i].owner = masterPlayer;
|
||||||
|
sceneObjects[i].isSceneObject = true; // needed for special handling when deleted
|
||||||
|
objects.Add(sceneObjects[i].networkId, sceneObjects[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
masterPlayer = players[cm.masterId];
|
||||||
|
}
|
||||||
|
|
||||||
|
masterPlayer.SetAsMasterPlayer();
|
||||||
|
|
||||||
|
// master player should take over any objects that do not have an owner
|
||||||
|
foreach (KeyValuePair<string, NetworkObject> kvp in objects)
|
||||||
|
{
|
||||||
|
kvp.Value.owner ??= masterPlayer;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//MessageReceived?.Invoke(m);
|
//MessageReceived?.Invoke(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -421,7 +465,6 @@ namespace VelNet
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
clientReceiveThread = new Thread(ListenForData);
|
clientReceiveThread = new Thread(ListenForData);
|
||||||
clientReceiveThread.IsBackground = true;
|
|
||||||
clientReceiveThread.Start();
|
clientReceiveThread.Start();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
|
@ -432,10 +475,9 @@ namespace VelNet
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Runs in background clientReceiveThread; Listens for incomming data.
|
/// Runs in background clientReceiveThread; Listens for incoming data.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
///
|
private static byte[] ReadExact(Stream stream, int N)
|
||||||
private byte[] ReadExact(NetworkStream stream, int N)
|
|
||||||
{
|
{
|
||||||
byte[] toReturn = new byte[N];
|
byte[] toReturn = new byte[N];
|
||||||
|
|
||||||
|
|
@ -446,20 +488,15 @@ namespace VelNet
|
||||||
numRead += stream.Read(toReturn, numRead, numLeft);
|
numRead += stream.Read(toReturn, numRead, numLeft);
|
||||||
numLeft = N - numRead;
|
numLeft = N - numRead;
|
||||||
}
|
}
|
||||||
|
|
||||||
return toReturn;
|
return toReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int GetIntFromBytes(byte[] bytes)
|
private static int GetIntFromBytes(byte[] bytes)
|
||||||
{
|
{
|
||||||
if (BitConverter.IsLittleEndian)
|
return BitConverter.ToInt32(BitConverter.IsLittleEndian ? bytes.Reverse().ToArray() : bytes, 0);
|
||||||
{
|
|
||||||
return BitConverter.ToInt32(bytes.Reverse().ToArray(),0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return BitConverter.ToInt32(bytes, 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ListenForData()
|
private void ListenForData()
|
||||||
{
|
{
|
||||||
connected = true;
|
connected = true;
|
||||||
|
|
@ -476,44 +513,43 @@ namespace VelNet
|
||||||
//SendToGroup("close", Encoding.UTF8.GetBytes("HelloGroup"));
|
//SendToGroup("close", Encoding.UTF8.GetBytes("HelloGroup"));
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
|
||||||
// Get a stream object for reading
|
// Get a stream object for reading
|
||||||
|
|
||||||
|
|
||||||
//read a byte
|
//read a byte
|
||||||
byte type = (byte)stream.ReadByte();
|
byte type = (byte)stream.ReadByte();
|
||||||
|
|
||||||
if (type == 0) //login
|
if (type == 0) //login
|
||||||
{
|
{
|
||||||
LoginMessage m = new LoginMessage();
|
LoginMessage m = new LoginMessage();
|
||||||
m.userId = GetIntFromBytes(ReadExact(stream, 4)); //not really the sender...
|
m.userId = GetIntFromBytes(ReadExact(stream, 4)); //not really the sender...
|
||||||
AddMessage(m);
|
AddMessage(m);
|
||||||
}
|
}
|
||||||
else if(type == 1) //rooms
|
else if (type == 1) //rooms
|
||||||
{
|
{
|
||||||
|
|
||||||
RoomsMessage m = new RoomsMessage();
|
RoomsMessage m = new RoomsMessage();
|
||||||
m.rooms = new List<ListedRoom>();
|
m.rooms = new List<ListedRoom>();
|
||||||
int N = GetIntFromBytes(ReadExact(stream, 4)); //the size of the payload
|
int N = GetIntFromBytes(ReadExact(stream, 4)); //the size of the payload
|
||||||
byte[] utf8data = ReadExact(stream, N);
|
byte[] utf8data = ReadExact(stream, N);
|
||||||
string roomMessage = Encoding.UTF8.GetString(utf8data);
|
string roomMessage = Encoding.UTF8.GetString(utf8data);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
string[] sections = roomMessage.Split(',');
|
string[] sections = roomMessage.Split(',');
|
||||||
foreach (string s in sections)
|
foreach (string s in sections)
|
||||||
{
|
{
|
||||||
string[] pieces = s.Split(':');
|
string[] pieces = s.Split(':');
|
||||||
if (pieces.Length == 2) {
|
if (pieces.Length == 2)
|
||||||
|
{
|
||||||
ListedRoom lr = new ListedRoom();
|
ListedRoom lr = new ListedRoom();
|
||||||
lr.name = pieces[0];
|
lr.name = pieces[0];
|
||||||
lr.numUsers = int.Parse(pieces[1]);
|
lr.numUsers = int.Parse(pieces[1]);
|
||||||
m.rooms.Add(lr);
|
m.rooms.Add(lr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AddMessage(m);
|
AddMessage(m);
|
||||||
}
|
}
|
||||||
else if(type == 2) //joined
|
else if (type == 2) //joined
|
||||||
{
|
{
|
||||||
JoinMessage m = new JoinMessage();
|
JoinMessage m = new JoinMessage();
|
||||||
m.userId = GetIntFromBytes(ReadExact(stream, 4));
|
m.userId = GetIntFromBytes(ReadExact(stream, 4));
|
||||||
|
|
@ -521,7 +557,8 @@ namespace VelNet
|
||||||
byte[] utf8data = ReadExact(stream, N); //the room name, encoded as utf-8
|
byte[] utf8data = ReadExact(stream, N); //the room name, encoded as utf-8
|
||||||
m.room = Encoding.UTF8.GetString(utf8data);
|
m.room = Encoding.UTF8.GetString(utf8data);
|
||||||
AddMessage(m);
|
AddMessage(m);
|
||||||
}else if(type == 3) //data
|
}
|
||||||
|
else if (type == 3) //data
|
||||||
{
|
{
|
||||||
DataMessage m = new DataMessage();
|
DataMessage m = new DataMessage();
|
||||||
m.senderId = GetIntFromBytes(ReadExact(stream, 4));
|
m.senderId = GetIntFromBytes(ReadExact(stream, 4));
|
||||||
|
|
@ -529,10 +566,10 @@ namespace VelNet
|
||||||
m.data = ReadExact(stream, N); //the message
|
m.data = ReadExact(stream, N); //the message
|
||||||
AddMessage(m);
|
AddMessage(m);
|
||||||
}
|
}
|
||||||
else if(type == 4) //new master
|
else if (type == 4) //new master
|
||||||
{
|
{
|
||||||
ChangeMasterMessage m = new ChangeMasterMessage();
|
ChangeMasterMessage m = new ChangeMasterMessage();
|
||||||
m.masterId = (int)GetIntFromBytes(ReadExact(stream, 4)); //sender is the new master
|
m.masterId = GetIntFromBytes(ReadExact(stream, 4)); //sender is the new master
|
||||||
AddMessage(m);
|
AddMessage(m);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -584,20 +621,24 @@ namespace VelNet
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
int numReceived = udpSocket.Receive(buffer);
|
int numReceived = udpSocket.Receive(buffer);
|
||||||
if (buffer[0] == 0)
|
switch (buffer[0])
|
||||||
{
|
{
|
||||||
Debug.Log("UDP connected");
|
case 0:
|
||||||
}else if (buffer[0] == 3)
|
Debug.Log("UDP connected");
|
||||||
{
|
break;
|
||||||
DataMessage m = new DataMessage();
|
case 3:
|
||||||
//we should get the sender address
|
{
|
||||||
byte[] senderBytes = new byte[4];
|
DataMessage m = new DataMessage();
|
||||||
Array.Copy(buffer, 1, senderBytes, 0, 4);
|
//we should get the sender address
|
||||||
m.senderId = GetIntFromBytes(senderBytes);
|
byte[] senderBytes = new byte[4];
|
||||||
byte[] messageBytes = new byte[numReceived - 5];
|
Array.Copy(buffer, 1, senderBytes, 0, 4);
|
||||||
Array.Copy(buffer, 5, messageBytes, 0, messageBytes.Length);
|
m.senderId = GetIntFromBytes(senderBytes);
|
||||||
m.data = messageBytes;
|
byte[] messageBytes = new byte[numReceived - 5];
|
||||||
AddMessage(m);
|
Array.Copy(buffer, 5, messageBytes, 0, messageBytes.Length);
|
||||||
|
m.data = messageBytes;
|
||||||
|
AddMessage(m);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -634,8 +675,7 @@ namespace VelNet
|
||||||
NetworkStream stream = instance.socketConnection.GetStream();
|
NetworkStream stream = instance.socketConnection.GetStream();
|
||||||
if (stream.CanWrite)
|
if (stream.CanWrite)
|
||||||
{
|
{
|
||||||
|
stream.Write(message, 0, message.Length);
|
||||||
stream.Write(message,0,message.Length);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (SocketException socketException)
|
catch (SocketException socketException)
|
||||||
|
|
@ -652,9 +692,9 @@ namespace VelNet
|
||||||
{
|
{
|
||||||
return BitConverter.GetBytes(n).Reverse().ToArray();
|
return BitConverter.GetBytes(n).Reverse().ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Login(string username, string password)
|
public static void Login(string username, string password)
|
||||||
{
|
{
|
||||||
|
|
||||||
MemoryStream stream = new MemoryStream();
|
MemoryStream stream = new MemoryStream();
|
||||||
BinaryWriter writer = new BinaryWriter(stream);
|
BinaryWriter writer = new BinaryWriter(stream);
|
||||||
|
|
||||||
|
|
@ -667,14 +707,11 @@ namespace VelNet
|
||||||
writer.Write(pB);
|
writer.Write(pB);
|
||||||
|
|
||||||
SendTcpMessage(stream.ToArray());
|
SendTcpMessage(stream.ToArray());
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void GetRooms()
|
public static void GetRooms()
|
||||||
{
|
{
|
||||||
|
SendTcpMessage(new byte[] { 1 }); //very simple message
|
||||||
SendTcpMessage(new byte[1] { 1 }); //very simple message
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -691,13 +728,8 @@ namespace VelNet
|
||||||
writer.Write((byte)R.Length);
|
writer.Write((byte)R.Length);
|
||||||
writer.Write(R);
|
writer.Write(R);
|
||||||
SendTcpMessage(stream.ToArray());
|
SendTcpMessage(stream.ToArray());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Leaves a room if we're in one
|
/// Leaves a room if we're in one
|
||||||
|
|
@ -712,12 +744,12 @@ namespace VelNet
|
||||||
|
|
||||||
public static void SendToRoom(byte[] message, bool include_self = false, bool reliable = true, bool ordered = false)
|
public static void SendToRoom(byte[] message, bool include_self = false, bool reliable = true, bool ordered = false)
|
||||||
{
|
{
|
||||||
byte sendType = (byte) MessageSendType.MESSAGE_OTHERS;
|
byte sendType = (byte)MessageSendType.MESSAGE_OTHERS;
|
||||||
if (include_self && ordered) sendType = (byte)MessageSendType.MESSAGE_ALL_ORDERED;
|
if (include_self && ordered) sendType = (byte)MessageSendType.MESSAGE_ALL_ORDERED;
|
||||||
if (include_self && !ordered) sendType = (byte)MessageSendType.MESSAGE_ALL;
|
if (include_self && !ordered) sendType = (byte)MessageSendType.MESSAGE_ALL;
|
||||||
if (!include_self && ordered) sendType = (byte)MessageSendType.MESSAGE_OTHERS_ORDERED;
|
if (!include_self && ordered) sendType = (byte)MessageSendType.MESSAGE_OTHERS_ORDERED;
|
||||||
|
|
||||||
|
|
||||||
if (reliable)
|
if (reliable)
|
||||||
{
|
{
|
||||||
MemoryStream stream = new MemoryStream();
|
MemoryStream stream = new MemoryStream();
|
||||||
|
|
@ -730,10 +762,10 @@ namespace VelNet
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//udp message needs the type
|
//udp message needs the type
|
||||||
toSend[0] = sendType; //we don't
|
toSend[0] = sendType; //we don't
|
||||||
Array.Copy(get_be_bytes(instance.userid), 0, toSend, 1, 4);
|
Array.Copy(get_be_bytes(instance.userid), 0, toSend, 1, 4);
|
||||||
Array.Copy(message, 0, toSend, 5, message.Length);
|
Array.Copy(message, 0, toSend, 5, message.Length);
|
||||||
SendUdpMessage(toSend,message.Length+5); //shouldn't be over 1024...
|
SendUdpMessage(toSend, message.Length + 5); //shouldn't be over 1024...
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -759,7 +791,7 @@ namespace VelNet
|
||||||
//also need to send the group
|
//also need to send the group
|
||||||
toSend[5] = (byte)utf8bytes.Length;
|
toSend[5] = (byte)utf8bytes.Length;
|
||||||
Array.Copy(utf8bytes, 0, toSend, 6, utf8bytes.Length);
|
Array.Copy(utf8bytes, 0, toSend, 6, utf8bytes.Length);
|
||||||
Array.Copy(message, 0, toSend, 6+utf8bytes.Length, message.Length);
|
Array.Copy(message, 0, toSend, 6 + utf8bytes.Length, message.Length);
|
||||||
SendUdpMessage(toSend, 6 + utf8bytes.Length + message.Length);
|
SendUdpMessage(toSend, 6 + utf8bytes.Length + message.Length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -785,6 +817,7 @@ namespace VelNet
|
||||||
{
|
{
|
||||||
writer.Write(get_be_bytes(client_ids[i]));
|
writer.Write(get_be_bytes(client_ids[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
SendTcpMessage(stream.ToArray());
|
SendTcpMessage(stream.ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -805,6 +838,7 @@ namespace VelNet
|
||||||
Debug.LogError("Can't instantiate object. Obj with that network ID was already instantiated.", instance.objects[networkId]);
|
Debug.LogError("Can't instantiate object. Obj with that network ID was already instantiated.", instance.objects[networkId]);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
NetworkObject newObject = Instantiate(prefab);
|
NetworkObject newObject = Instantiate(prefab);
|
||||||
newObject.networkId = networkId;
|
newObject.networkId = networkId;
|
||||||
newObject.prefabName = prefabName;
|
newObject.prefabName = prefabName;
|
||||||
|
|
@ -812,7 +846,7 @@ namespace VelNet
|
||||||
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.
|
// only sent to others, as I already instantiated this. Nice that it happens immediately.
|
||||||
SendToRoom(Encoding.UTF8.GetBytes("7," + newObject.networkId + "," + prefabName),false,true);
|
SendToRoom(Encoding.UTF8.GetBytes("7," + newObject.networkId + "," + prefabName), false, true);
|
||||||
|
|
||||||
return newObject;
|
return newObject;
|
||||||
}
|
}
|
||||||
|
|
@ -842,6 +876,7 @@ namespace VelNet
|
||||||
instance.objects.Remove(networkId);
|
instance.objects.Remove(networkId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj.isSceneObject)
|
if (obj.isSceneObject)
|
||||||
{
|
{
|
||||||
instance.deletedSceneObjects.Add(networkId);
|
instance.deletedSceneObjects.Add(networkId);
|
||||||
|
|
@ -864,7 +899,7 @@ namespace VelNet
|
||||||
Debug.LogError("Can't take ownership. No local player.");
|
Debug.LogError("Can't take ownership. No local player.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// obj must exist
|
// obj must exist
|
||||||
if (!instance.objects.ContainsKey(networkId))
|
if (!instance.objects.ContainsKey(networkId))
|
||||||
{
|
{
|
||||||
|
|
@ -878,7 +913,7 @@ namespace VelNet
|
||||||
Debug.LogError("Can't take ownership. Ownership for this object is locked.");
|
Debug.LogError("Can't take ownership. Ownership for this object is locked.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// immediately successful
|
// immediately successful
|
||||||
instance.objects[networkId].owner = LocalPlayer;
|
instance.objects[networkId].owner = LocalPlayer;
|
||||||
|
|
||||||
|
|
@ -888,4 +923,4 @@ namespace VelNet
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "edu.uga.engr.vel.velnet",
|
"name": "edu.uga.engr.vel.velnet",
|
||||||
"displayName": "VelNet",
|
"displayName": "VelNet",
|
||||||
"version": "1.0.7",
|
"version": "1.0.8",
|
||||||
"unity": "2019.1",
|
"unity": "2019.1",
|
||||||
"description": "A custom networking library for Unity.",
|
"description": "A custom networking library for Unity.",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,13 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"com.unity.collab-proxy": "1.15.7",
|
"com.unity.collab-proxy": "1.15.7",
|
||||||
"com.unity.ide.rider": "2.0.7",
|
"com.unity.ide.rider": "2.0.7",
|
||||||
"com.unity.ide.visualstudio": "2.0.12",
|
"com.unity.ide.visualstudio": "2.0.14",
|
||||||
"com.unity.ide.vscode": "1.2.4",
|
"com.unity.ide.vscode": "1.2.4",
|
||||||
"com.unity.test-framework": "1.1.30",
|
"com.unity.test-framework": "1.1.30",
|
||||||
"com.unity.textmeshpro": "3.0.6",
|
"com.unity.textmeshpro": "3.0.6",
|
||||||
"com.unity.timeline": "1.4.8",
|
"com.unity.timeline": "1.4.8",
|
||||||
"com.unity.ugui": "1.0.0",
|
"com.unity.ugui": "1.0.0",
|
||||||
"edu.uga.engr.vel.velnet.dissonance": "file:c:/git_repo/VelNetDissonanceIntegration",
|
"edu.uga.engr.vel.velnet.dissonance": "https://github.com/velaboratory/VelNetDissonanceIntegration.git",
|
||||||
"com.unity.modules.ai": "1.0.0",
|
"com.unity.modules.ai": "1.0.0",
|
||||||
"com.unity.modules.androidjni": "1.0.0",
|
"com.unity.modules.androidjni": "1.0.0",
|
||||||
"com.unity.modules.animation": "1.0.0",
|
"com.unity.modules.animation": "1.0.0",
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
"url": "https://packages.unity.com"
|
"url": "https://packages.unity.com"
|
||||||
},
|
},
|
||||||
"com.unity.ide.visualstudio": {
|
"com.unity.ide.visualstudio": {
|
||||||
"version": "2.0.12",
|
"version": "2.0.14",
|
||||||
"depth": 0,
|
"depth": 0,
|
||||||
"source": "registry",
|
"source": "registry",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
@ -106,12 +106,13 @@
|
||||||
"dependencies": {}
|
"dependencies": {}
|
||||||
},
|
},
|
||||||
"edu.uga.engr.vel.velnet.dissonance": {
|
"edu.uga.engr.vel.velnet.dissonance": {
|
||||||
"version": "file:c:/git_repo/VelNetDissonanceIntegration",
|
"version": "https://github.com/velaboratory/VelNetDissonanceIntegration.git",
|
||||||
"depth": 0,
|
"depth": 0,
|
||||||
"source": "local",
|
"source": "git",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"edu.uga.engr.vel.velnet": "1.0.4"
|
"edu.uga.engr.vel.velnet": "1.0.4"
|
||||||
}
|
},
|
||||||
|
"hash": "2767cf12e6f1b5c568c44cd6f1753866ae2e6fca"
|
||||||
},
|
},
|
||||||
"com.unity.modules.ai": {
|
"com.unity.modules.ai": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,2 @@
|
||||||
m_EditorVersion: 2020.3.11f1
|
m_EditorVersion: 2020.3.23f1
|
||||||
m_EditorVersionWithRevision: 2020.3.11f1 (99c7afb366b3)
|
m_EditorVersionWithRevision: 2020.3.23f1 (c5d91304a876)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue