added RPC support 😲

main
Anton Franzluebbers 2022-06-17 00:13:33 -04:00
parent 77f07b8f6a
commit fcfff4690f
21 changed files with 772 additions and 70 deletions

View File

@ -0,0 +1,32 @@
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using VelNet;
public class RPCTest : NetworkComponent
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
private void Update()
{
if (Input.GetKeyDown(KeyCode.R))
{
SendRPC(nameof(TestRPC), true);
}
}
private void TestRPC()
{
Debug.LogError("RPC RECEIVED!");
}
public override void ReceiveBytes(byte[] message)
{
Debug.LogError("WOW. BYTES");
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2bcc94802a5742d4299e48c898e52dfa
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -28,6 +28,7 @@ Transform:
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_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 3076416102083120807}
m_RootOrder: 0
@ -51,6 +52,7 @@ MeshRenderer:
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
@ -114,6 +116,7 @@ Transform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.5, y: 0.5, z: 0.5}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 6602982999811082154}
m_Father: {fileID: 0}
@ -138,6 +141,7 @@ MeshRenderer:
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1

View File

@ -193,6 +193,7 @@ RectTransform:
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_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 626742070}
m_RootOrder: 0
@ -296,6 +297,7 @@ RectTransform:
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_ConstrainProportionsScale: 0
m_Children:
- {fileID: 138032023}
- {fileID: 1557879931}
@ -416,6 +418,7 @@ RectTransform:
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_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 117638565}
m_RootOrder: 0
@ -453,6 +456,7 @@ RectTransform:
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_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 711524767}
m_RootOrder: 0
@ -595,6 +599,7 @@ RectTransform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0, y: 0, z: 0}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 1894247853}
- {fileID: 117638565}
@ -664,6 +669,7 @@ RectTransform:
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_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 948755938}
m_RootOrder: 0
@ -777,6 +783,7 @@ Transform:
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_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 5
@ -809,6 +816,7 @@ RectTransform:
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_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1992361063}
m_RootOrder: 0
@ -889,6 +897,7 @@ RectTransform:
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_ConstrainProportionsScale: 0
m_Children:
- {fileID: 1081889596}
m_Father: {fileID: 244561620}
@ -1021,6 +1030,7 @@ RectTransform:
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_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1047954372}
m_RootOrder: 1
@ -1138,7 +1148,10 @@ MonoBehaviour:
m_HideMobileInput: 0
m_CharacterValidation: 0
m_CharacterLimit: 0
m_OnEndEdit:
m_OnSubmit:
m_PersistentCalls:
m_Calls: []
m_OnDidEndEdit:
m_PersistentCalls:
m_Calls: []
m_OnValueChanged:
@ -1162,6 +1175,7 @@ RectTransform:
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_ConstrainProportionsScale: 0
m_Children:
- {fileID: 2034439}
- {fileID: 1560686264}
@ -1300,6 +1314,7 @@ Transform:
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
m_LocalPosition: {x: 0, y: 3, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 4
@ -1333,6 +1348,7 @@ RectTransform:
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_ConstrainProportionsScale: 0
m_Children:
- {fileID: 162005664}
- {fileID: 1484033256}
@ -1395,7 +1411,10 @@ MonoBehaviour:
m_HideMobileInput: 0
m_CharacterValidation: 0
m_CharacterLimit: 0
m_OnEndEdit:
m_OnSubmit:
m_PersistentCalls:
m_Calls: []
m_OnDidEndEdit:
m_PersistentCalls:
m_Calls: []
m_OnValueChanged:
@ -1517,6 +1536,7 @@ RectTransform:
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_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1047954372}
m_RootOrder: 2
@ -1555,6 +1575,7 @@ RectTransform:
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_ConstrainProportionsScale: 0
m_Children:
- {fileID: 1401860307}
m_Father: {fileID: 244561620}
@ -1753,6 +1774,7 @@ Transform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 1, z: -20}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 3
@ -1786,6 +1808,7 @@ RectTransform:
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_ConstrainProportionsScale: 0
m_Children:
- {fileID: 1055818112}
m_Father: {fileID: 927188573}
@ -1876,6 +1899,7 @@ RectTransform:
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_ConstrainProportionsScale: 0
m_Children:
- {fileID: 912887456}
- {fileID: 1154194182}
@ -1986,6 +2010,7 @@ RectTransform:
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_ConstrainProportionsScale: 0
m_Children:
- {fileID: 359309141}
- {fileID: 1840952814}
@ -2084,7 +2109,10 @@ MonoBehaviour:
m_HideMobileInput: 0
m_CharacterValidation: 0
m_CharacterLimit: 0
m_OnEndEdit:
m_OnSubmit:
m_PersistentCalls:
m_Calls: []
m_OnDidEndEdit:
m_PersistentCalls:
m_Calls: []
m_OnValueChanged:
@ -2164,6 +2192,7 @@ RectTransform:
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_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 244561620}
m_RootOrder: 10
@ -2242,6 +2271,7 @@ RectTransform:
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_ConstrainProportionsScale: 0
m_Children:
- {fileID: 2144436500}
- {fileID: 615558652}
@ -2328,6 +2358,7 @@ RectTransform:
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_ConstrainProportionsScale: 0
m_Children:
- {fileID: 1047954372}
m_Father: {fileID: 912887456}
@ -2366,6 +2397,7 @@ RectTransform:
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_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 545137760}
m_RootOrder: 0
@ -2471,6 +2503,7 @@ Transform:
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_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
@ -2487,7 +2520,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 233344de094f11341bdb834d564708dc, type: 3}
m_Name:
m_EditorClassIdentifier:
host: velnet-lts.ugavel.com
host: vn.ugavel.com
port: 5000
udpConnected: 0
userid: -1
@ -2526,6 +2559,7 @@ RectTransform:
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_ConstrainProportionsScale: 0
m_Children:
- {fileID: 1679565284}
m_Father: {fileID: 927188573}
@ -2652,6 +2686,7 @@ RectTransform:
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_ConstrainProportionsScale: 0
m_Children:
- {fileID: 1295274441}
m_Father: {fileID: 244561620}
@ -2784,6 +2819,7 @@ RectTransform:
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_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1278634767}
m_RootOrder: 0
@ -2863,6 +2899,7 @@ RectTransform:
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_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 864104176}
m_RootOrder: 0
@ -2942,6 +2979,7 @@ RectTransform:
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_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1997780490}
m_RootOrder: 0
@ -3037,6 +3075,7 @@ Transform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 818.5, y: 223, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 1
@ -3143,6 +3182,7 @@ RectTransform:
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_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 711524767}
m_RootOrder: 1
@ -3222,6 +3262,7 @@ RectTransform:
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_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 244561620}
m_RootOrder: 11
@ -3301,6 +3342,7 @@ RectTransform:
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_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 117638565}
m_RootOrder: 1
@ -3376,6 +3418,7 @@ RectTransform:
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_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 626742070}
m_RootOrder: 1
@ -3453,6 +3496,7 @@ RectTransform:
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_ConstrainProportionsScale: 0
m_Children:
- {fileID: 2033163677}
m_Father: {fileID: 1154194182}
@ -3492,6 +3536,7 @@ RectTransform:
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_ConstrainProportionsScale: 0
m_Children:
- {fileID: 2118429759}
m_Father: {fileID: 244561620}
@ -3624,6 +3669,7 @@ RectTransform:
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_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 948755938}
m_RootOrder: 1
@ -3703,6 +3749,7 @@ RectTransform:
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_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 244561620}
m_RootOrder: 0
@ -3783,6 +3830,7 @@ RectTransform:
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_ConstrainProportionsScale: 0
m_Children:
- {fileID: 498776800}
m_Father: {fileID: 948755938}
@ -3916,6 +3964,7 @@ RectTransform:
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_ConstrainProportionsScale: 0
m_Children:
- {fileID: 1428857710}
m_Father: {fileID: 244561620}
@ -4020,6 +4069,71 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1997780489}
m_CullTransparentMesh: 1
--- !u!1 &2021764943
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2021764946}
- component: {fileID: 2021764945}
- component: {fileID: 2021764944}
m_Layer: 0
m_Name: TestRPC Object
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &2021764944
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2021764943}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5515094c5c544b6b8ed7fd51a86548d4, type: 3}
m_Name:
m_EditorClassIdentifier:
ownershipLocked: 0
networkId:
sceneNetworkId: 102
prefabName:
isSceneObject: 1
syncedComponents:
- {fileID: 2021764945}
--- !u!114 &2021764945
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2021764943}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 2bcc94802a5742d4299e48c898e52dfa, type: 3}
m_Name:
m_EditorClassIdentifier:
networkObject: {fileID: 2021764944}
--- !u!4 &2021764946
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2021764943}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 2.9278836, y: 2.2367568, z: 0.06653424}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 7
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &2033163676
GameObject:
m_ObjectHideFlags: 0
@ -4048,6 +4162,7 @@ RectTransform:
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_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1679565284}
m_RootOrder: 0
@ -4123,6 +4238,7 @@ RectTransform:
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_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1760805525}
m_RootOrder: 0
@ -4202,6 +4318,7 @@ RectTransform:
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_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1047954372}
m_RootOrder: 0
@ -4264,6 +4381,10 @@ PrefabInstance:
propertyPath: sceneNetworkId
value: 100
objectReference: {fileID: 0}
- target: {fileID: 8565720275311462452, guid: 6e4a023f70e01405e8b249a4488fe319, type: 3}
propertyPath: m_Enabled
value: 1
objectReference: {fileID: 0}
- target: {fileID: 8565720275311462453, guid: 6e4a023f70e01405e8b249a4488fe319, type: 3}
propertyPath: m_Name
value: TestNetworkedGameObject

View File

@ -0,0 +1,34 @@
using UnityEngine;
using VelNet;
public class test : MonoBehaviour
{
// Start is called before the first frame update
private void Start()
{
VelNetManager.OnJoinedRoom += roomName =>
{
Debug.Log("VelNet room joined!!!!!: " + roomName);
//VelNetManager.GetRoomData(roomName);
byte[] testpacekt = new[] { (byte)244 };
VelNetManager.SendCustomMessage(testpacekt, true, true, false);
};
VelNetManager.CustomMessageReceived += (senderId, dataWithCategory) =>
{
//customPacketReceived(senderId, dataWithCategory);
if (dataWithCategory[0] == (byte)244)
{
Debug.Log("received test packet");
return;
}
;
};
}
// Update is called once per frame
void Update()
{
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5ea1fe0eb58e4184bbb2edcc99c51119
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,191 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!29 &1
OcclusionCullingSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
m_OcclusionBakeSettings:
smallestOccluder: 5
smallestHole: 0.25
backfaceThreshold: 100
m_SceneGUID: 00000000000000000000000000000000
m_OcclusionCullingData: {fileID: 0}
--- !u!104 &2
RenderSettings:
m_ObjectHideFlags: 0
serializedVersion: 9
m_Fog: 0
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
m_FogMode: 3
m_FogDensity: 0.01
m_LinearFogStart: 0
m_LinearFogEnd: 300
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, 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_AmbientIntensity: 1
m_AmbientMode: 0
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
m_HaloStrength: 0.5
m_FlareStrength: 1
m_FlareFadeSpeed: 3
m_HaloTexture: {fileID: 0}
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
m_DefaultReflectionMode: 0
m_DefaultReflectionResolution: 128
m_ReflectionBounces: 1
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0.37311953, g: 0.38074014, b: 0.3587274, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0
serializedVersion: 12
m_GIWorkflowMode: 1
m_GISettings:
serializedVersion: 2
m_BounceScale: 1
m_IndirectOutputScale: 1
m_AlbedoBoost: 1
m_EnvironmentLightingMode: 0
m_EnableBakedLightmaps: 1
m_EnableRealtimeLightmaps: 0
m_LightmapEditorSettings:
serializedVersion: 12
m_Resolution: 2
m_BakeResolution: 40
m_AtlasSize: 1024
m_AO: 0
m_AOMaxDistance: 1
m_CompAOExponent: 1
m_CompAOExponentDirect: 0
m_ExtractAmbientOcclusion: 0
m_Padding: 2
m_LightmapParameters: {fileID: 0}
m_LightmapsBakeMode: 1
m_TextureCompression: 1
m_FinalGather: 0
m_FinalGatherFiltering: 1
m_FinalGatherRayCount: 256
m_ReflectionCompression: 2
m_MixedBakeMode: 2
m_BakeBackend: 1
m_PVRSampling: 1
m_PVRDirectSampleCount: 32
m_PVRSampleCount: 512
m_PVRBounces: 2
m_PVREnvironmentSampleCount: 256
m_PVREnvironmentReferencePointCount: 2048
m_PVRFilteringMode: 1
m_PVRDenoiserTypeDirect: 1
m_PVRDenoiserTypeIndirect: 1
m_PVRDenoiserTypeAO: 1
m_PVRFilterTypeDirect: 0
m_PVRFilterTypeIndirect: 0
m_PVRFilterTypeAO: 0
m_PVREnvironmentMIS: 1
m_PVRCulling: 1
m_PVRFilteringGaussRadiusDirect: 1
m_PVRFilteringGaussRadiusIndirect: 5
m_PVRFilteringGaussRadiusAO: 2
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
m_PVRFilteringAtrousPositionSigmaIndirect: 2
m_PVRFilteringAtrousPositionSigmaAO: 1
m_ExportTrainingData: 0
m_TrainingDataDestination: TrainingData
m_LightProbeSampleCountMultiplier: 4
m_LightingDataAsset: {fileID: 0}
m_LightingSettings: {fileID: 0}
--- !u!196 &4
NavMeshSettings:
serializedVersion: 2
m_ObjectHideFlags: 0
m_BuildSettings:
serializedVersion: 2
agentTypeID: 0
agentRadius: 0.5
agentHeight: 2
agentSlope: 45
agentClimb: 0.4
ledgeDropHeight: 0
maxJumpAcrossDistance: 0
minRegionArea: 2
manualCellSize: 0
cellSize: 0.16666667
manualTileSize: 0
tileSize: 256
accuratePlacement: 0
maxJobWorkers: 0
preserveTilesOutsideBounds: 0
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &1148318672
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1148318674}
- component: {fileID: 1148318673}
- component: {fileID: 1148318675}
m_Layer: 0
m_Name: GameObject
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1148318673
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1148318672}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 233344de094f11341bdb834d564708dc, type: 3}
m_Name:
m_EditorClassIdentifier:
host: velnet-lts.ugavel.com
port: 5000
udpConnected: 0
userid: -1
connected: 0
prefabs:
- {fileID: 9102273340480352682, guid: d4158ab9c4a204cdbba28d3273fc1fb3, type: 3}
- {fileID: 3951900052977689805, guid: 6e4a023f70e01405e8b249a4488fe319, type: 3}
sceneObjects: []
deletedSceneObjects: []
--- !u!4 &1148318674
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1148318672}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 297.37976, y: 241.59624, z: -3.2564697}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1148318675
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1148318672}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5ea1fe0eb58e4184bbb2edcc99c51119, type: 3}
m_Name:
m_EditorClassIdentifier:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: dda4edde45d871c4c9cc53849f3b62c7
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,4 +1,8 @@
using UnityEngine;
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using UnityEngine;
namespace VelNet
{
@ -13,7 +17,7 @@ namespace VelNet
/// </summary>
protected void SendBytes(byte[] message, bool reliable = true)
{
networkObject.SendBytes(this, message, reliable);
networkObject.SendBytes(this, false, message, reliable);
}
/// <summary>
@ -21,12 +25,87 @@ namespace VelNet
/// </summary>
protected void SendBytesToGroup(string group, byte[] message, bool reliable = true)
{
networkObject.SendBytesToGroup(this, group, message, reliable);
networkObject.SendBytesToGroup(this, false, group, message, reliable);
}
/// <summary>
/// This is called by <see cref="NetworkObject"/> when messages are received for this component
/// </summary>
public abstract void ReceiveBytes(byte[] message);
public void ReceiveRPC(byte[] message)
{
using MemoryStream mem = new MemoryStream(message);
using BinaryReader reader = new BinaryReader(mem);
byte methodIndex = reader.ReadByte();
int length = reader.ReadInt32();
byte[] parameterData = reader.ReadBytes(length);
MethodInfo[] mInfos = GetType().GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic);
Array.Sort(mInfos, (m1, m2) => string.Compare(m1.Name, m2.Name, StringComparison.Ordinal));
try
{
mInfos[methodIndex].Invoke(this, length > 0 ? new object[] { parameterData } : Array.Empty<object>());
}
catch (Exception e)
{
Debug.LogError($"Error processing received RPC {e}");
}
}
protected void SendRPCToGroup(string group, bool runLocally, string methodName, byte[] parameterData = null)
{
if (GenerateRPC(methodName, parameterData, out byte[] bytes)) return;
if (runLocally) ReceiveRPC(bytes);
networkObject.SendBytesToGroup(this, true, group, bytes, true);
}
protected void SendRPC(string methodName, bool runLocally, byte[] parameterData = null)
{
if (GenerateRPC(methodName, parameterData, out byte[] bytes)) return;
if (networkObject.SendBytes(this, true, bytes, true))
{
// only run locally if we can successfully send
if (runLocally) ReceiveRPC(bytes);
}
}
private bool GenerateRPC(string methodName, byte[] parameterData, out byte[] bytes)
{
bytes = null;
using MemoryStream mem = new MemoryStream();
using BinaryWriter writer = new BinaryWriter(mem);
MethodInfo[] mInfos = GetType().GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic);
Array.Sort(mInfos, (m1, m2) => string.Compare(m1.Name, m2.Name, StringComparison.Ordinal));
int methodIndex = mInfos.ToList().FindIndex(m => m.Name == methodName);
switch (methodIndex)
{
case > 255:
Debug.LogError("Too many methods in this class.");
return true;
case < 0:
Debug.LogError("Can't find a method with that name.");
return true;
}
writer.Write((byte)methodIndex);
if (parameterData != null)
{
writer.Write(parameterData.Length);
writer.Write(parameterData);
}
else
{
writer.Write(0);
}
bytes = mem.ToArray();
return false;
}
}
}

View File

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.NetworkInformation;
#if UNITY_EDITOR
using UnityEditor;
#endif
@ -40,52 +41,96 @@ namespace VelNet
public List<NetworkComponent> syncedComponents;
public void SendBytes(NetworkComponent component, byte[] message, bool reliable = true)
/// <summary>
/// Player is the new owner
/// </summary>
public Action<VelNetPlayer> OwnershipChanged;
public bool SendBytes(NetworkComponent component, bool isRpc, byte[] message, bool reliable = true)
{
if (!IsMine)
// only needs to be owner if this isn't an RPC
// RPC calls can be called by non-owner
if (!IsMine && !isRpc)
{
Debug.LogError("Can't send message if owner is null or not local", this);
return;
return false;
}
if (!VelNetManager.InRoom)
{
Debug.LogError("Can't send message if not in a room", this);
return false;
}
// send the message and an identifier for which component it belongs to
if (!syncedComponents.Contains(component))
{
Debug.LogError("Can't send message if this component is not registered with the NetworkObject.", this);
return;
return false;
}
int index = syncedComponents.IndexOf(component);
if (index < 0)
int componentIndex = syncedComponents.IndexOf(component);
switch (componentIndex)
{
case > 127:
Debug.LogError("Too many components.", component);
return false;
case < 0:
Debug.LogError("WAAAAAAAH. NetworkObject doesn't have a reference to this component.", component);
}
else
{
VelNetPlayer.SendMessage(this, (byte)index, message, reliable);
}
return false;
}
public void SendBytesToGroup(NetworkComponent component, string group, byte[] message, bool reliable = true)
byte componentByte = (byte)(componentIndex << 1);
// the leftmost bit determines if this is an rpc or not
// this leaves only 128 possible NetworkComponents per NetworkObject
componentByte |= (byte)(isRpc ? 1 : 0);
return VelNetPlayer.SendMessage(this, componentByte, message, reliable);
}
public bool SendBytesToGroup(NetworkComponent component, bool isRpc, string group, byte[] message, bool reliable = true)
{
if (!IsMine)
// only needs to be owner if this isn't an RPC
// RPC calls can be called by non-owner
if (!IsMine && !isRpc)
{
Debug.LogError("Can't send message if owner is null or not local", this);
return;
return false;
}
// send the message and an identifier for which component it belongs to
int index = syncedComponents.IndexOf(component);
VelNetPlayer.SendGroupMessage(this, group, (byte)index, message, reliable);
int componentIndex = syncedComponents.IndexOf(component);
switch (componentIndex)
{
case > 127:
Debug.LogError("Too many components.", component);
return false;
case < 0:
Debug.LogError("WAAAAAAAH. NetworkObject doesn't have a reference to this component.", component);
return false;
}
public void ReceiveBytes(byte componentIdx, byte[] message)
byte componentByte = (byte)(componentIndex << 1);
componentByte |= (byte)(isRpc ? 1 : 0);
return VelNetPlayer.SendGroupMessage(this, group, componentByte, message, reliable);
}
public void ReceiveBytes(byte componentIdx, bool isRpc, byte[] message)
{
// send the message to the right component
try
{
if (isRpc)
{
syncedComponents[componentIdx].ReceiveRPC(message);
}
else
{
syncedComponents[componentIdx].ReceiveBytes(message);
}
}
catch (Exception e)
{
Debug.LogError($"Error in handling message:\n{e}", this);
@ -123,13 +168,14 @@ namespace VelNet
if (GUILayout.Button("Find Network Components and add backreferences."))
{
NetworkComponent[] comps = t.GetComponents<NetworkComponent>();
NetworkComponent[] comps = t.GetComponentsInChildren<NetworkComponent>();
t.syncedComponents = comps.ToList();
foreach (NetworkComponent c in comps)
{
c.networkObject = t;
PrefabUtility.RecordPrefabInstancePropertyModifications(c);
}
PrefabUtility.RecordPrefabInstancePropertyModifications(t);
}
@ -139,7 +185,7 @@ namespace VelNet
// find the first unused value
int[] used = FindObjectsOfType<NetworkObject>().Select(o => o.sceneNetworkId).ToArray();
int available = -1;
for (int i = 1; i <= used.Max()+1; i++)
for (int i = 1; i <= used.Max() + 1; i++)
{
if (!used.Contains(i))
{

View File

@ -1,5 +1,4 @@
using System.Collections;
using System.Collections.Generic;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEngine;
@ -33,6 +32,24 @@ namespace VelNet
writer.Write(c.a);
}
public static void Write(this BinaryWriter writer, List<int> l)
{
writer.Write(l.Count());
foreach (int i in l)
{
writer.Write(i);
}
}
public static void Write(this BinaryWriter writer, List<string> l)
{
writer.Write(l.Count());
foreach (string i in l)
{
writer.Write(i);
}
}
#endregion
#region Readers
@ -62,6 +79,30 @@ namespace VelNet
);
}
public static List<int> ReadIntList(this BinaryReader reader)
{
int length = reader.ReadInt32();
List<int> l = new List<int>(length);
for (int i = 0; i < length; i++)
{
l.Add(reader.ReadInt32());
}
return l;
}
public static List<string> ReadStringList(this BinaryReader reader)
{
int length = reader.ReadInt32();
List<string> l = new List<string>(length);
for (int i = 0; i < length; i++)
{
l.Add(reader.ReadString());
}
return l;
}
#endregion

View File

@ -139,5 +139,11 @@ namespace VelNet
);
}
}
[VelNetRPC]
private void Test()
{
}
}
}

View File

@ -11,6 +11,12 @@ using System.IO;
namespace VelNet
{
/// <summary>Used to flag methods as remote-callable.</summary>
public class VelNetRPC : Attribute
{
}
[AddComponentMenu("VelNet/VelNet Manager")]
public class VelNetManager : MonoBehaviour
{
@ -170,7 +176,7 @@ namespace VelNet
public class RoomDataMessage : Message
{
public string room;
public readonly List<Tuple<int, string>> members = new List<Tuple<int, string>>();
public readonly List<(int, string)> members = new List<(int, string)>();
}
public class JoinMessage : Message
@ -354,7 +360,6 @@ namespace VelNet
try
{
Debug.Log(jm.room);
OnJoinedRoom?.Invoke(jm.room);
}
// prevent errors in subscribers from breaking our code
@ -495,6 +500,13 @@ namespace VelNet
sceneObjects[i].networkId = -1 + "-" + sceneObjects[i].sceneNetworkId;
sceneObjects[i].owner = masterPlayer;
sceneObjects[i].isSceneObject = true; // needed for special handling when deleted
try {
sceneObjects[i].OwnershipChanged?.Invoke(masterPlayer);
}
catch (Exception e)
{
Debug.LogError("Error in event handling.\n" + e);
}
if (objects.ContainsKey(sceneObjects[i].networkId))
{
@ -681,7 +693,8 @@ namespace VelNet
while (socketConnection.Connected)
{
//read a byte
MessageReceivedType type = (MessageReceivedType)stream.ReadByte();
int b = stream.ReadByte();
MessageReceivedType type = (MessageReceivedType)b;
switch (type)
{
@ -735,8 +748,7 @@ namespace VelNet
int s = stream.ReadByte(); //size of string
utf8data = ReadExact(stream, s); //the username
string username = Encoding.UTF8.GetString(utf8data);
rdm.members.Add(new Tuple<int, string>(client_id, username));
Debug.Log(username);
rdm.members.Add((client_id, username));
}
AddMessage(rdm);
@ -1042,7 +1054,7 @@ namespace VelNet
SendToGroup(group, mem.ToArray(), reliable);
}
internal static void SendToRoom(byte[] message, bool include_self = false, bool reliable = true, bool ordered = false)
internal static bool SendToRoom(byte[] message, bool include_self = false, bool reliable = true, bool ordered = false)
{
byte sendType = (byte)MessageSendType.MESSAGE_OTHERS;
if (include_self && ordered) sendType = (byte)MessageSendType.MESSAGE_ALL_ORDERED;
@ -1057,7 +1069,7 @@ namespace VelNet
writer.Write(sendType);
writer.Write(get_be_bytes(message.Length));
writer.Write(message);
SendTcpMessage(mem.ToArray());
return SendTcpMessage(mem.ToArray());
}
else
{
@ -1066,11 +1078,12 @@ namespace VelNet
Array.Copy(get_be_bytes(instance.userid), 0, toSend, 1, 4);
Array.Copy(message, 0, toSend, 5, message.Length);
SendUdpMessage(toSend, message.Length + 5); //shouldn't be over 1024...
return true;
}
}
internal static void SendToGroup(string group, byte[] message, bool reliable = true)
internal static bool SendToGroup(string group, byte[] message, bool reliable = true)
{
byte[] utf8bytes = Encoding.UTF8.GetBytes(group);
if (reliable)
@ -1082,7 +1095,7 @@ namespace VelNet
writer.Write(message);
writer.Write((byte)utf8bytes.Length);
writer.Write(utf8bytes);
SendTcpMessage(stream.ToArray());
return SendTcpMessage(stream.ToArray());
}
else
{
@ -1093,6 +1106,7 @@ namespace VelNet
Array.Copy(utf8bytes, 0, toSend, 6, utf8bytes.Length);
Array.Copy(message, 0, toSend, 6 + utf8bytes.Length, message.Length);
SendUdpMessage(toSend, 6 + utf8bytes.Length + message.Length);
return true;
}
}
@ -1148,6 +1162,15 @@ namespace VelNet
newObject.networkId = networkId;
newObject.prefabName = prefabName;
newObject.owner = localPlayer;
try
{
newObject.OwnershipChanged?.Invoke(localPlayer);
}
catch (Exception e)
{
Debug.LogError("Error in event handling.\n" + e);
}
instance.objects.Add(newObject.networkId, newObject);
@ -1170,6 +1193,14 @@ namespace VelNet
newObject.networkId = networkId;
newObject.prefabName = prefabName;
newObject.owner = owner;
try
{
newObject.OwnershipChanged?.Invoke(owner);
}
catch (Exception e)
{
Debug.LogError("Error in event handling.\n" + e);
}
instance.objects.Add(newObject.networkId, newObject);
}
@ -1230,6 +1261,12 @@ namespace VelNet
/// <returns>True if successfully transferred, False if transfer message not sent</returns>
public static bool TakeOwnership(string networkId)
{
if (!InRoom)
{
Debug.LogError("Can't take ownership. Not in a room.");
return false;
}
// local player must exist
if (LocalPlayer == null)
{
@ -1253,6 +1290,14 @@ namespace VelNet
// immediately successful
instance.objects[networkId].owner = LocalPlayer;
try
{
instance.objects[networkId].OwnershipChanged?.Invoke(LocalPlayer);
}
catch (Exception e)
{
Debug.LogError("Error in event handling.\n" + e);
}
// must be ordered, so that ownership transfers are not confused.
// Also sent to all players, so that multiple simultaneous requests will result in the same outcome.

View File

@ -24,7 +24,7 @@ namespace VelNet
internal int lastObjectId;
private bool isMaster;
public bool IsMaster { get; private set; }
public VelNetPlayer()
@ -51,7 +51,7 @@ namespace VelNet
}
}
if (isMaster)
if (IsMaster)
{
//send a list of scene object ids when someone joins
SendSceneUpdate();
@ -78,7 +78,9 @@ namespace VelNet
switch (messageType)
{
case VelNetManager.MessageType.ObjectSync: // sync update for an object I may own
// sync update for an object "I" may own
// "I" being the person sending
case VelNetManager.MessageType.ObjectSync:
{
string objectKey = reader.ReadString();
byte componentIdx = reader.ReadByte();
@ -86,9 +88,13 @@ namespace VelNet
byte[] syncMessage = reader.ReadBytes(messageLength);
if (manager.objects.ContainsKey(objectKey))
{
if (manager.objects[objectKey].owner == this)
bool isRpc = (componentIdx & 1) == 1;
componentIdx = (byte)(componentIdx >> 1);
// rpcs can be sent by non-owners
if (isRpc || manager.objects[objectKey].owner == this)
{
manager.objects[objectKey].ReceiveBytes(componentIdx, syncMessage);
manager.objects[objectKey].ReceiveBytes(componentIdx, isRpc, syncMessage);
}
}
@ -101,6 +107,14 @@ namespace VelNet
if (manager.objects.ContainsKey(networkId))
{
manager.objects[networkId].owner = this;
try
{
manager.objects[networkId].OwnershipChanged?.Invoke(this);
}
catch (Exception e)
{
Debug.LogError("Error in event handling.\n" + e);
}
}
break;
@ -130,9 +144,12 @@ namespace VelNet
{
VelNetManager.SomebodyDestroyedNetworkObject(reader.ReadString());
}
break;
}
case VelNetManager.MessageType.Custom: // custom packets
// Custom packets. These are global data that can be sent from anywhere.
// Any script can subscribe to the callback to receive the message data.
case VelNetManager.MessageType.Custom:
{
int len = reader.ReadInt32();
try
@ -153,12 +170,12 @@ namespace VelNet
public void SetAsMasterPlayer()
{
isMaster = true;
IsMaster = true;
//if I'm master, I'm now responsible for updating all scene objects
//FindObjectsOfType<NetworkObject>();
}
public static void SendGroupMessage(NetworkObject obj, string group, byte componentIdx, byte[] data, bool reliable = true)
public static bool SendGroupMessage(NetworkObject obj, string group, byte componentIdx, byte[] data, bool reliable = true)
{
using MemoryStream mem = new MemoryStream();
using BinaryWriter writer = new BinaryWriter(mem);
@ -167,10 +184,10 @@ namespace VelNet
writer.Write(componentIdx);
writer.Write(data.Length);
writer.Write(data);
VelNetManager.SendToGroup(group, mem.ToArray(), reliable);
return VelNetManager.SendToGroup(group, mem.ToArray(), reliable);
}
public static void SendMessage(NetworkObject obj, byte componentIdx, byte[] data, bool reliable = true)
public static bool SendMessage(NetworkObject obj, byte componentIdx, byte[] data, bool reliable = true)
{
using MemoryStream mem = new MemoryStream();
using BinaryWriter writer = new BinaryWriter(mem);
@ -179,7 +196,7 @@ namespace VelNet
writer.Write(componentIdx);
writer.Write(data.Length);
writer.Write(data);
VelNetManager.SendToRoom(mem.ToArray(), false, reliable);
return VelNetManager.SendToRoom(mem.ToArray(), false, reliable);
}
public void SendSceneUpdate()
@ -223,6 +240,14 @@ namespace VelNet
// immediately successful
manager.objects[networkId].owner = this;
try
{
manager.objects[networkId].OwnershipChanged?.Invoke(this);
}
catch (Exception e)
{
Debug.LogError("Error in event handling.\n" + e);
}
// must be ordered, so that ownership transfers are not confused.
// Also sent to all players, so that multiple simultaneous requests will result in the same outcome.

View File

@ -1,7 +1,7 @@
{
"name": "edu.uga.engr.vel.velnet",
"displayName": "VelNet",
"version": "1.0.12",
"version": "1.0.13",
"unity": "2019.1",
"description": "A custom networking library for Unity.",
"keywords": [

View File

@ -2,14 +2,14 @@
"dependencies": {
"com.franzco.unityutilities": "https://github.com/AntonFranzluebbers/unityutilities.git",
"com.unity.collab-proxy": "1.15.15",
"com.unity.ide.rider": "2.0.7",
"com.unity.ide.rider": "3.0.13",
"com.unity.ide.visualstudio": "2.0.15",
"com.unity.ide.vscode": "1.2.5",
"com.unity.test-framework": "1.1.31",
"com.unity.textmeshpro": "3.0.6",
"com.unity.timeline": "1.4.8",
"com.unity.timeline": "1.6.4",
"com.unity.ugui": "1.0.0",
"edu.uga.engr.vel.velnet.dissonance": "https://github.com/velaboratory/VelNetDissonanceIntegration.git",
"edu.uga.engr.vel.velnet.dissonance": "file:S:/git_repo/VelNetDissonanceIntegration",
"com.unity.modules.ai": "1.0.0",
"com.unity.modules.androidjni": "1.0.0",
"com.unity.modules.animation": "1.0.0",

View File

@ -27,11 +27,11 @@
"url": "https://packages.unity.com"
},
"com.unity.ide.rider": {
"version": "2.0.7",
"version": "3.0.13",
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.test-framework": "1.1.1"
"com.unity.ext.nunit": "1.0.6"
},
"url": "https://packages.unity.com"
},
@ -52,7 +52,7 @@
"url": "https://packages.unity.com"
},
"com.unity.nuget.newtonsoft-json": {
"version": "2.0.0-preview",
"version": "2.0.0",
"depth": 1,
"source": "registry",
"dependencies": {},
@ -88,7 +88,7 @@
"url": "https://packages.unity.com"
},
"com.unity.timeline": {
"version": "1.4.8",
"version": "1.6.4",
"depth": 0,
"source": "registry",
"dependencies": {
@ -109,7 +109,7 @@
}
},
"com.unity.xr.legacyinputhelpers": {
"version": "2.1.8",
"version": "2.1.9",
"depth": 1,
"source": "registry",
"dependencies": {
@ -125,13 +125,12 @@
"dependencies": {}
},
"edu.uga.engr.vel.velnet.dissonance": {
"version": "https://github.com/velaboratory/VelNetDissonanceIntegration.git",
"version": "file:S:/git_repo/VelNetDissonanceIntegration",
"depth": 0,
"source": "git",
"source": "local",
"dependencies": {
"edu.uga.engr.vel.velnet": "1.0.4"
},
"hash": "2767cf12e6f1b5c568c44cd6f1753866ae2e6fca"
}
},
"com.unity.modules.ai": {
"version": "1.0.0",

View File

@ -0,0 +1,35 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!387306366 &1
MemorySettings:
m_ObjectHideFlags: 0
m_EditorMemorySettings:
m_MainAllocatorBlockSize: -1
m_ThreadAllocatorBlockSize: -1
m_MainGfxBlockSize: -1
m_ThreadGfxBlockSize: -1
m_CacheBlockSize: -1
m_TypetreeBlockSize: -1
m_ProfilerBlockSize: -1
m_ProfilerEditorBlockSize: -1
m_BucketAllocatorGranularity: -1
m_BucketAllocatorBucketsCount: -1
m_BucketAllocatorBlockSize: -1
m_BucketAllocatorBlockCount: -1
m_ProfilerBucketAllocatorGranularity: -1
m_ProfilerBucketAllocatorBucketsCount: -1
m_ProfilerBucketAllocatorBlockSize: -1
m_ProfilerBucketAllocatorBlockCount: -1
m_TempAllocatorSizeMain: -1
m_JobTempAllocatorBlockSize: -1
m_BackgroundJobTempAllocatorBlockSize: -1
m_JobTempAllocatorReducedBlockSize: -1
m_TempAllocatorSizeGIBakingWorker: -1
m_TempAllocatorSizeNavMeshWorker: -1
m_TempAllocatorSizeAudioWorker: -1
m_TempAllocatorSizeCloudWorker: -1
m_TempAllocatorSizeGfx: -1
m_TempAllocatorSizeJobWorker: -1
m_TempAllocatorSizeBackgroundWorker: -1
m_TempAllocatorSizePreloadManager: -1
m_PlatformMemorySettings: {}

View File

@ -1,2 +1,2 @@
m_EditorVersion: 2020.3.23f1
m_EditorVersionWithRevision: 2020.3.23f1 (c5d91304a876)
m_EditorVersion: 2021.3.1f1
m_EditorVersionWithRevision: 2021.3.1f1 (3b70a0754835)

View File

@ -0,0 +1,15 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &1
MonoBehaviour:
m_ObjectHideFlags: 61
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 0}
m_Name:
m_EditorClassIdentifier: Unity.Rider.Editor:Packages.Rider.Editor:RiderScriptEditorPersistedState
lastWriteTicks: -8585461721809239573