Successful sync test
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,13 +1,12 @@
|
|||||||
namespace Marro.PacManUdon
|
namespace Marro.PacManUdon
|
||||||
{
|
{
|
||||||
using Assets.Scripts;
|
|
||||||
using UdonSharp;
|
using UdonSharp;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using VRC.SDK3.Data;
|
using VRC.SDK3.Data;
|
||||||
using VRC.SDKBase;
|
using VRC.SDKBase;
|
||||||
using VRC.Udon;
|
using VRC.Udon;
|
||||||
|
|
||||||
public class BonusFruit : SyncedObject
|
public class BonusFruit : UdonSharpBehaviour
|
||||||
{
|
{
|
||||||
[SerializeField, UdonSynced, FieldChangeCallback(nameof(FruitType))] PacManFruitType fruitType;
|
[SerializeField, UdonSynced, FieldChangeCallback(nameof(FruitType))] PacManFruitType fruitType;
|
||||||
|
|
||||||
@@ -84,16 +83,6 @@
|
|||||||
RequestSerialization();
|
RequestSerialization();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void AppendSyncedData(byte[][] data, ref int offset)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool SetSyncedData(byte[] data, ref int offset)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PacManFruitType FruitType
|
public PacManFruitType FruitType
|
||||||
{
|
{
|
||||||
set
|
set
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace Marro.PacManUdon
|
namespace Marro.PacManUdon
|
||||||
{
|
{
|
||||||
using Assets.Scripts;
|
|
||||||
using System;
|
using System;
|
||||||
using UdonSharp;
|
using UdonSharp;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
@@ -78,7 +77,7 @@ namespace Marro.PacManUdon
|
|||||||
playerInput.Initialize(this);
|
playerInput.Initialize(this);
|
||||||
soundManager.Initialize();
|
soundManager.Initialize();
|
||||||
intermission2Pole.Initialize(this, ghostManager.Ghosts[0]);
|
intermission2Pole.Initialize(this, ghostManager.Ghosts[0]);
|
||||||
networkManager.Initialize(Networking.IsOwner(gameObject));
|
networkManager.Initialize();
|
||||||
|
|
||||||
HideEverything();
|
HideEverything();
|
||||||
|
|
||||||
@@ -423,7 +422,7 @@ namespace Marro.PacManUdon
|
|||||||
ghostManager.SetOwner(Networking.LocalPlayer);
|
ghostManager.SetOwner(Networking.LocalPlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void AppendSyncedData(byte[][] data, ref int offset)
|
public override void AppendSyncedData(byte[][] data, ref int offset, NetworkEventType eventType, uint eventTime)
|
||||||
{
|
{
|
||||||
data[offset++] = new byte[] { Int32ToByte((int)gameState) };
|
data[offset++] = new byte[] { Int32ToByte((int)gameState) };
|
||||||
data[offset++] = BitConverter.GetBytes(currentlyInTimeSequence);
|
data[offset++] = BitConverter.GetBytes(currentlyInTimeSequence);
|
||||||
@@ -431,7 +430,7 @@ namespace Marro.PacManUdon
|
|||||||
data[offset++] = BitConverter.GetBytes(timeSequenceProgress);
|
data[offset++] = BitConverter.GetBytes(timeSequenceProgress);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool SetSyncedData(byte[] data, ref int offset)
|
public override bool SetSyncedData(byte[] data, ref int offset, NetworkEventType eventType, uint eventTime)
|
||||||
{
|
{
|
||||||
SetGameState((PacManGameState)data[offset++]);
|
SetGameState((PacManGameState)data[offset++]);
|
||||||
|
|
||||||
@@ -444,6 +443,11 @@ namespace Marro.PacManUdon
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void SyncedToNewTime(uint oldTime, uint newTime)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public int ExtraLives
|
public int ExtraLives
|
||||||
{
|
{
|
||||||
set
|
set
|
||||||
@@ -499,6 +503,7 @@ namespace Marro.PacManUdon
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static byte Int32ToByte(int value) =>
|
public static byte Int32ToByte(int value) =>
|
||||||
byte.Parse(value.ToString()); // This is the only way I could find to cast an int to byte in Udon, a regular cast crashes in runtime...
|
(byte)value;
|
||||||
|
//byte.Parse(value.ToString()); // This is the only way I could find to cast an int to byte in Udon, a regular cast crashes in runtime...
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -779,9 +779,9 @@ namespace Marro.PacManUdon
|
|||||||
UpdateAnimator();
|
UpdateAnimator();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void AppendSyncedData(byte[][] data, ref int offset)
|
public override void AppendSyncedData(byte[][] data, ref int offset, NetworkEventType eventType, uint eventTime)
|
||||||
{
|
{
|
||||||
base.AppendSyncedData(data, ref offset);
|
base.AppendSyncedData(data, ref offset, eventType, eventTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnTriggerEnter(Collider other)
|
void OnTriggerEnter(Collider other)
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
namespace Marro.PacManUdon
|
namespace Marro.PacManUdon
|
||||||
{
|
{
|
||||||
using Assets.Scripts;
|
|
||||||
using System;
|
using System;
|
||||||
using UdonSharp;
|
using UdonSharp;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
@@ -33,7 +32,7 @@ namespace Marro.PacManUdon
|
|||||||
|
|
||||||
protected abstract void UpdateAnimator();
|
protected abstract void UpdateAnimator();
|
||||||
|
|
||||||
public override void AppendSyncedData(byte[][] data, ref int offset)
|
public override void AppendSyncedData(byte[][] data, ref int offset, NetworkEventType eventType, uint eventTime)
|
||||||
{
|
{
|
||||||
var position = GetPosition();
|
var position = GetPosition();
|
||||||
data[offset++] = BitConverter.GetBytes(position.x);
|
data[offset++] = BitConverter.GetBytes(position.x);
|
||||||
@@ -44,7 +43,7 @@ namespace Marro.PacManUdon
|
|||||||
data[offset++] = BitConverter.GetBytes(direction.y);
|
data[offset++] = BitConverter.GetBytes(direction.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool SetSyncedData(byte[] data, ref int offset)
|
public override bool SetSyncedData(byte[] data, ref int offset, NetworkEventType eventType, uint eventTime)
|
||||||
{
|
{
|
||||||
SetPosition(new Vector2(BitConverter.ToSingle(data, offset), BitConverter.ToSingle(data, offset + 2)));
|
SetPosition(new Vector2(BitConverter.ToSingle(data, offset), BitConverter.ToSingle(data, offset + 2)));
|
||||||
SetDirection(new Vector2(BitConverter.ToSingle(data, offset + 4), BitConverter.ToSingle(data, offset + 6)));
|
SetDirection(new Vector2(BitConverter.ToSingle(data, offset + 4), BitConverter.ToSingle(data, offset + 6)));
|
||||||
@@ -52,5 +51,10 @@ namespace Marro.PacManUdon
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void SyncedToNewTime(uint oldTime, uint newTime)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -43,7 +43,7 @@ MonoBehaviour:
|
|||||||
Data:
|
Data:
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 12
|
Entry: 12
|
||||||
Data: 7
|
Data: 10
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data:
|
Data:
|
||||||
@@ -61,7 +61,7 @@ MonoBehaviour:
|
|||||||
Data: 3|System.RuntimeType, mscorlib
|
Data: 3|System.RuntimeType, mscorlib
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: Assets.Scripts.SyncedObject[], Assembly-CSharp
|
Data: Marro.PacManUdon.SyncedObject[], Assembly-CSharp
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 8
|
Entry: 8
|
||||||
Data:
|
Data:
|
||||||
@@ -115,19 +115,19 @@ MonoBehaviour:
|
|||||||
Data:
|
Data:
|
||||||
- Name: $k
|
- Name: $k
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: isOwner
|
Data: DebugImageToIndicateOwner
|
||||||
- Name: $v
|
- Name: $v
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 7|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
Data: 7|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
- Name: <Name>k__BackingField
|
- Name: <Name>k__BackingField
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: isOwner
|
Data: DebugImageToIndicateOwner
|
||||||
- Name: <UserType>k__BackingField
|
- Name: <UserType>k__BackingField
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 8|System.RuntimeType, mscorlib
|
Data: 8|System.RuntimeType, mscorlib
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: System.Boolean, mscorlib
|
Data: UnityEngine.Animator, UnityEngine.AnimationModule
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 8
|
Entry: 8
|
||||||
Data:
|
Data:
|
||||||
@@ -145,13 +145,19 @@ MonoBehaviour:
|
|||||||
Data:
|
Data:
|
||||||
- Name: <IsSerialized>k__BackingField
|
- Name: <IsSerialized>k__BackingField
|
||||||
Entry: 5
|
Entry: 5
|
||||||
Data: false
|
Data: true
|
||||||
- Name: _fieldAttributes
|
- Name: _fieldAttributes
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 9|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
Data: 9|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 12
|
Entry: 12
|
||||||
Data: 0
|
Data: 1
|
||||||
|
- Name:
|
||||||
|
Entry: 7
|
||||||
|
Data: 10|UnityEngine.SerializeField, UnityEngine.CoreModule
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 13
|
Entry: 13
|
||||||
Data:
|
Data:
|
||||||
@@ -169,25 +175,25 @@ MonoBehaviour:
|
|||||||
Data:
|
Data:
|
||||||
- Name: $k
|
- Name: $k
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: startTimeTicks
|
Data: isOwner
|
||||||
- Name: $v
|
- Name: $v
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 10|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
Data: 11|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
- Name: <Name>k__BackingField
|
- Name: <Name>k__BackingField
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: startTimeTicks
|
Data: isOwner
|
||||||
- Name: <UserType>k__BackingField
|
- Name: <UserType>k__BackingField
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 11|System.RuntimeType, mscorlib
|
Data: 12|System.RuntimeType, mscorlib
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: System.Int64, mscorlib
|
Data: System.Boolean, mscorlib
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 8
|
Entry: 8
|
||||||
Data:
|
Data:
|
||||||
- Name: <SystemType>k__BackingField
|
- Name: <SystemType>k__BackingField
|
||||||
Entry: 9
|
Entry: 9
|
||||||
Data: 11
|
Data: 12
|
||||||
- Name: <SyncMode>k__BackingField
|
- Name: <SyncMode>k__BackingField
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||||
@@ -202,7 +208,7 @@ MonoBehaviour:
|
|||||||
Data: false
|
Data: false
|
||||||
- Name: _fieldAttributes
|
- Name: _fieldAttributes
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 12|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
Data: 13|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 12
|
Entry: 12
|
||||||
Data: 0
|
Data: 0
|
||||||
@@ -223,25 +229,19 @@ MonoBehaviour:
|
|||||||
Data:
|
Data:
|
||||||
- Name: $k
|
- Name: $k
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: nextEventTime
|
Data: isSynced
|
||||||
- Name: $v
|
- Name: $v
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 13|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
Data: 14|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
- Name: <Name>k__BackingField
|
- Name: <Name>k__BackingField
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: nextEventTime
|
Data: isSynced
|
||||||
- Name: <UserType>k__BackingField
|
- Name: <UserType>k__BackingField
|
||||||
Entry: 7
|
Entry: 9
|
||||||
Data: 14|System.RuntimeType, mscorlib
|
Data: 12
|
||||||
- Name:
|
|
||||||
Entry: 1
|
|
||||||
Data: System.UInt32, mscorlib
|
|
||||||
- Name:
|
|
||||||
Entry: 8
|
|
||||||
Data:
|
|
||||||
- Name: <SystemType>k__BackingField
|
- Name: <SystemType>k__BackingField
|
||||||
Entry: 9
|
Entry: 9
|
||||||
Data: 14
|
Data: 12
|
||||||
- Name: <SyncMode>k__BackingField
|
- Name: <SyncMode>k__BackingField
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||||
@@ -277,19 +277,19 @@ MonoBehaviour:
|
|||||||
Data:
|
Data:
|
||||||
- Name: $k
|
- Name: $k
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: buffer
|
Data: startTimeTicks
|
||||||
- Name: $v
|
- Name: $v
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 16|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
Data: 16|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
- Name: <Name>k__BackingField
|
- Name: <Name>k__BackingField
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: buffer
|
Data: startTimeTicks
|
||||||
- Name: <UserType>k__BackingField
|
- Name: <UserType>k__BackingField
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 17|System.RuntimeType, mscorlib
|
Data: 17|System.RuntimeType, mscorlib
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: System.Byte[], mscorlib
|
Data: System.Int64, mscorlib
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 8
|
Entry: 8
|
||||||
Data:
|
Data:
|
||||||
@@ -331,19 +331,19 @@ MonoBehaviour:
|
|||||||
Data:
|
Data:
|
||||||
- Name: $k
|
- Name: $k
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: index
|
Data: nextEventTime
|
||||||
- Name: $v
|
- Name: $v
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 19|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
Data: 19|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
- Name: <Name>k__BackingField
|
- Name: <Name>k__BackingField
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: index
|
Data: nextEventTime
|
||||||
- Name: <UserType>k__BackingField
|
- Name: <UserType>k__BackingField
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 20|System.RuntimeType, mscorlib
|
Data: 20|System.RuntimeType, mscorlib
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: System.Int32, mscorlib
|
Data: System.UInt32, mscorlib
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 8
|
Entry: 8
|
||||||
Data:
|
Data:
|
||||||
@@ -385,19 +385,175 @@ MonoBehaviour:
|
|||||||
Data:
|
Data:
|
||||||
- Name: $k
|
- Name: $k
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: networkedData
|
Data: retriesWithoutSuccess
|
||||||
- Name: $v
|
- Name: $v
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 22|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
Data: 22|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
|
- Name: <Name>k__BackingField
|
||||||
|
Entry: 1
|
||||||
|
Data: retriesWithoutSuccess
|
||||||
|
- Name: <UserType>k__BackingField
|
||||||
|
Entry: 7
|
||||||
|
Data: 23|System.RuntimeType, mscorlib
|
||||||
|
- Name:
|
||||||
|
Entry: 1
|
||||||
|
Data: System.Int32, mscorlib
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name: <SystemType>k__BackingField
|
||||||
|
Entry: 9
|
||||||
|
Data: 23
|
||||||
|
- Name: <SyncMode>k__BackingField
|
||||||
|
Entry: 7
|
||||||
|
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||||
|
- Name:
|
||||||
|
Entry: 6
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name: <IsSerialized>k__BackingField
|
||||||
|
Entry: 5
|
||||||
|
Data: false
|
||||||
|
- Name: _fieldAttributes
|
||||||
|
Entry: 7
|
||||||
|
Data: 24|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||||
|
- Name:
|
||||||
|
Entry: 12
|
||||||
|
Data: 0
|
||||||
|
- Name:
|
||||||
|
Entry: 13
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 7
|
||||||
|
Data:
|
||||||
|
- Name: $k
|
||||||
|
Entry: 1
|
||||||
|
Data: buffer
|
||||||
|
- Name: $v
|
||||||
|
Entry: 7
|
||||||
|
Data: 25|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
|
- Name: <Name>k__BackingField
|
||||||
|
Entry: 1
|
||||||
|
Data: buffer
|
||||||
|
- Name: <UserType>k__BackingField
|
||||||
|
Entry: 7
|
||||||
|
Data: 26|System.RuntimeType, mscorlib
|
||||||
|
- Name:
|
||||||
|
Entry: 1
|
||||||
|
Data: System.Byte[], mscorlib
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name: <SystemType>k__BackingField
|
||||||
|
Entry: 9
|
||||||
|
Data: 26
|
||||||
|
- Name: <SyncMode>k__BackingField
|
||||||
|
Entry: 7
|
||||||
|
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||||
|
- Name:
|
||||||
|
Entry: 6
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name: <IsSerialized>k__BackingField
|
||||||
|
Entry: 5
|
||||||
|
Data: false
|
||||||
|
- Name: _fieldAttributes
|
||||||
|
Entry: 7
|
||||||
|
Data: 27|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||||
|
- Name:
|
||||||
|
Entry: 12
|
||||||
|
Data: 0
|
||||||
|
- Name:
|
||||||
|
Entry: 13
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 7
|
||||||
|
Data:
|
||||||
|
- Name: $k
|
||||||
|
Entry: 1
|
||||||
|
Data: index
|
||||||
|
- Name: $v
|
||||||
|
Entry: 7
|
||||||
|
Data: 28|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
|
- Name: <Name>k__BackingField
|
||||||
|
Entry: 1
|
||||||
|
Data: index
|
||||||
|
- Name: <UserType>k__BackingField
|
||||||
|
Entry: 9
|
||||||
|
Data: 23
|
||||||
|
- Name: <SystemType>k__BackingField
|
||||||
|
Entry: 9
|
||||||
|
Data: 23
|
||||||
|
- Name: <SyncMode>k__BackingField
|
||||||
|
Entry: 7
|
||||||
|
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||||
|
- Name:
|
||||||
|
Entry: 6
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name: <IsSerialized>k__BackingField
|
||||||
|
Entry: 5
|
||||||
|
Data: false
|
||||||
|
- Name: _fieldAttributes
|
||||||
|
Entry: 7
|
||||||
|
Data: 29|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||||
|
- Name:
|
||||||
|
Entry: 12
|
||||||
|
Data: 0
|
||||||
|
- Name:
|
||||||
|
Entry: 13
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 7
|
||||||
|
Data:
|
||||||
|
- Name: $k
|
||||||
|
Entry: 1
|
||||||
|
Data: networkedData
|
||||||
|
- Name: $v
|
||||||
|
Entry: 7
|
||||||
|
Data: 30|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
- Name: <Name>k__BackingField
|
- Name: <Name>k__BackingField
|
||||||
Entry: 1
|
Entry: 1
|
||||||
Data: networkedData
|
Data: networkedData
|
||||||
- Name: <UserType>k__BackingField
|
- Name: <UserType>k__BackingField
|
||||||
Entry: 9
|
Entry: 9
|
||||||
Data: 17
|
Data: 26
|
||||||
- Name: <SystemType>k__BackingField
|
- Name: <SystemType>k__BackingField
|
||||||
Entry: 9
|
Entry: 9
|
||||||
Data: 17
|
Data: 26
|
||||||
- Name: <SyncMode>k__BackingField
|
- Name: <SyncMode>k__BackingField
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||||
@@ -412,13 +568,13 @@ MonoBehaviour:
|
|||||||
Data: false
|
Data: false
|
||||||
- Name: _fieldAttributes
|
- Name: _fieldAttributes
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 23|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
Data: 31|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 12
|
Entry: 12
|
||||||
Data: 1
|
Data: 1
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data: 24|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime
|
Data: 32|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 8
|
Entry: 8
|
||||||
Data:
|
Data:
|
||||||
|
|||||||
@@ -1,21 +1,19 @@
|
|||||||
using Assets.Scripts;
|
using System;
|
||||||
using JetBrains.Annotations;
|
using System.Drawing;
|
||||||
using System;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using UdonSharp;
|
using UdonSharp;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UIElements;
|
|
||||||
using VRC.SDK3.Data;
|
|
||||||
using VRC.SDK3.UdonNetworkCalling;
|
using VRC.SDK3.UdonNetworkCalling;
|
||||||
|
using VRC.SDKBase;
|
||||||
|
using VRC.Udon.ClientBindings.Interfaces;
|
||||||
using VRC.Udon.Common;
|
using VRC.Udon.Common;
|
||||||
using static VRC.SDKBase.Networking;
|
|
||||||
|
|
||||||
namespace Marro.PacManUdon
|
namespace Marro.PacManUdon
|
||||||
{
|
{
|
||||||
enum NetworkEventType
|
public enum NetworkEventType
|
||||||
{
|
{
|
||||||
FullSync = 0,
|
FullSync = 0,
|
||||||
|
PacManTurn = 1,
|
||||||
}
|
}
|
||||||
public class NetworkManager : UdonSharpBehaviour
|
public class NetworkManager : UdonSharpBehaviour
|
||||||
{
|
{
|
||||||
@@ -32,33 +30,58 @@ namespace Marro.PacManUdon
|
|||||||
// Correct parsing is dependend upon everything being read out identially to how it was created.
|
// Correct parsing is dependend upon everything being read out identially to how it was created.
|
||||||
|
|
||||||
// An event has the following structure:
|
// An event has the following structure:
|
||||||
// [0-3]: (uint) Time in seconds at which event occured.
|
// [0-1]: (ushort) Size of event.
|
||||||
// [4]: (byte) Type of event: 0 = Full Sync, others will be defined later.
|
// [2-5]: (uint) Time in seconds at which event occured.
|
||||||
// [5+]: Event-specific data
|
// [6]: (byte) Type of event. 0 = Full Sync, which is used to sync up from an undefinted state.
|
||||||
|
// [7+]: Event-specific data
|
||||||
|
|
||||||
const int BufferSizeBytes = 1000;
|
private const int BufferMaxSizeBytes = 10000;
|
||||||
|
private const int BufferIncrementSizeBytes = 1000;
|
||||||
|
|
||||||
[SerializeField]
|
[SerializeField] private SyncedObject[] syncedObjects;
|
||||||
private SyncedObject[] syncedObjects;
|
|
||||||
|
[SerializeField] private Animator DebugImageToIndicateOwner;
|
||||||
|
|
||||||
private bool isOwner;
|
private bool isOwner;
|
||||||
|
private bool isSynced;
|
||||||
|
|
||||||
private long startTimeTicks;
|
private long startTimeTicks = DateTime.UtcNow.Ticks; // Initialize to prevent errors
|
||||||
|
|
||||||
private uint nextEventTime;
|
private uint nextEventTime;
|
||||||
|
|
||||||
|
private int retriesWithoutSuccess;
|
||||||
|
|
||||||
// Main buffer of events
|
// Main buffer of events
|
||||||
private byte[] buffer;
|
private byte[] buffer;
|
||||||
private int index;
|
private int index;
|
||||||
|
|
||||||
[UdonSynced] private byte[] networkedData;
|
private const ushort HeaderEventSizeIndex = 0;
|
||||||
|
private const ushort HeaderTimestampIndex = 2;
|
||||||
|
private const ushort HeaderEventTypeIndex = 6;
|
||||||
|
private const ushort HeaderLength = 7;
|
||||||
|
|
||||||
public void Initialize(bool isOwner)
|
private const int Delay = 250;
|
||||||
|
|
||||||
|
[UdonSynced] private byte[] networkedData = new byte[0];
|
||||||
|
|
||||||
|
public void Initialize()
|
||||||
{
|
{
|
||||||
buffer = new byte[BufferSizeBytes];
|
if (!BitConverter.IsLittleEndian)
|
||||||
|
{
|
||||||
|
Debug.LogError($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Fatal: NetworkManager only supports little endian! Network sync will not be possible.");
|
||||||
|
var zero = 0;
|
||||||
|
Debug.Log(1 / zero); // Intentionally crash
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer = new byte[BufferIncrementSizeBytes];
|
||||||
index = 0;
|
index = 0;
|
||||||
startTimeTicks = DateTime.UtcNow.Ticks;
|
startTimeTicks = DateTime.UtcNow.Ticks;
|
||||||
this.isOwner = isOwner;
|
isSynced = false;
|
||||||
|
retriesWithoutSuccess = 0;
|
||||||
|
SetOwner(Networking.IsOwner(gameObject));
|
||||||
|
|
||||||
|
Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Initialized, startTimeTicks: {startTimeTicks}");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Update()
|
public void Update()
|
||||||
@@ -69,65 +92,141 @@ namespace Marro.PacManUdon
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[NetworkCallable]
|
public void SendEvent(NetworkEventType eventType)
|
||||||
public void DoFullSync()
|
|
||||||
{
|
{
|
||||||
if (!isOwner)
|
if (!isOwner)
|
||||||
{
|
{
|
||||||
Debug.LogError($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Attempted {nameof(DoFullSync)} while not the owner!");
|
Debug.LogError($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Attempted {nameof(SendEvent)} while not the owner!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
InitializeEvent(NetworkEventType.FullSync, 1000, out byte[][] data, out var index);
|
var eventTime = CurrentTime;
|
||||||
|
|
||||||
|
InitializeEvent(eventType, eventTime, BufferMaxSizeBytes, out byte[][] data, out var index);
|
||||||
|
|
||||||
foreach (var obj in syncedObjects)
|
foreach (var obj in syncedObjects)
|
||||||
{
|
{
|
||||||
obj.AppendSyncedData(data, ref index);
|
obj.AppendSyncedData(data, ref index, eventType, eventTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
var eventSize = 0;
|
// Get event size, skipping over the event size which is not yet included
|
||||||
|
ushort eventSize = 0;
|
||||||
for (int i = 0; i < index; i++)
|
for (int i = 0; i < index; i++)
|
||||||
{
|
{
|
||||||
eventSize += data[i].Length;
|
eventSize += (ushort)data[i].Length;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!EnsureSpaceToStorePreparedEvent(eventSize))
|
if (!EnsureSpaceToStoreEvent(eventSize))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data[0] = BitConverter.GetBytes(eventSize);
|
||||||
|
|
||||||
var oldIndex = this.index;
|
var oldIndex = this.index;
|
||||||
|
|
||||||
FlattenAndCopy(data, index, buffer, ref this.index);
|
FlattenAndCopy(data, index, buffer, ref this.index);
|
||||||
|
|
||||||
Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Prepared event with {eventSize} bytes for serialization, index went from {oldIndex} to {this.index}");
|
Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Prepared event with {eventSize} bytes and timestamp {eventTime} for serialization, index went from {oldIndex} to {this.index}");
|
||||||
|
|
||||||
RequestSerialization();
|
RequestSerialization();
|
||||||
|
|
||||||
|
retriesWithoutSuccess = 0; // We had success!
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RequestFullSync()
|
public void RequestEvent(NetworkEventType eventType)
|
||||||
{
|
{
|
||||||
if (isOwner)
|
if (isOwner)
|
||||||
{
|
{
|
||||||
Debug.LogError($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Attempted {nameof(RequestFullSync)} while we are the owner!");
|
Debug.LogError($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Attempted {nameof(RequestEvent)} while we are the owner!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SendCustomNetworkEvent(VRC.Udon.Common.Interfaces.NetworkEventTarget.Owner, "DoFullSync");
|
SendCustomNetworkEvent(VRC.Udon.Common.Interfaces.NetworkEventTarget.Owner, "RequestEventReceived", eventType);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NetworkCallable]
|
||||||
|
public void RequestEventReceived(NetworkEventType eventType)
|
||||||
|
{
|
||||||
|
if (!isOwner)
|
||||||
|
{
|
||||||
|
Debug.LogError($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Attempted {nameof(RequestEventReceived)} while we are not the owner!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SendEvent(eventType);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ProcessIncomingData()
|
private void ProcessIncomingData()
|
||||||
{
|
{
|
||||||
var syncType = (NetworkEventType)networkedData[4];
|
if (networkedData.Length == 0)
|
||||||
var size = networkedData.Length;
|
{
|
||||||
|
return; // Nothing to process
|
||||||
|
}
|
||||||
|
|
||||||
if (!EnsureSpaceToStoreReceivedEvent(size, syncType == NetworkEventType.FullSync))
|
var length = networkedData.Length;
|
||||||
|
int index = 0;
|
||||||
|
while (index < length)
|
||||||
|
{
|
||||||
|
if (length - index < HeaderLength)
|
||||||
|
{
|
||||||
|
Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)}) {nameof(ProcessIncomingData)}: Remaining data in networkedData is not long enough to form a complete event!");
|
||||||
|
HandleError();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var eventSize = networkedData[index + HeaderEventSizeIndex];
|
||||||
|
var eventType = (NetworkEventType)networkedData[index + HeaderEventTypeIndex];
|
||||||
|
|
||||||
|
if (eventType == NetworkEventType.FullSync)
|
||||||
|
{
|
||||||
|
ProcessIncomingFullSync(index, eventSize); // Immediately process full sync
|
||||||
|
index += eventSize;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isSynced)
|
||||||
|
{
|
||||||
|
Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Received event of type {eventType} while we are not yet synced to the remote time, ignoring event.");
|
||||||
|
index += eventSize;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
AppendEventToBuffer(index, eventSize);
|
||||||
|
index += eventSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Received {networkedData.Length} bytes!\nBytes received:\n{BytesToString(networkedData)}");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ProcessIncomingFullSync(int index, int size)
|
||||||
|
{
|
||||||
|
// Intentionally not doing a buffer size check here, since this is not appending to the buffer
|
||||||
|
// (and there is no good way to continue if event is too large)
|
||||||
|
|
||||||
|
// Clear buffer and copy the full sync into it
|
||||||
|
buffer = new byte[size];
|
||||||
|
Array.Copy(networkedData, index, buffer, 0, size);
|
||||||
|
this.index = size;
|
||||||
|
|
||||||
|
// Sync up to the time in the full sync
|
||||||
|
var time = BitConverter.ToUInt32(networkedData, index + HeaderTimestampIndex);
|
||||||
|
SyncToTime(time);
|
||||||
|
|
||||||
|
// Immediately apply the full sync
|
||||||
|
nextEventTime = time;
|
||||||
|
isSynced = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AppendEventToBuffer(int index, int size)
|
||||||
|
{
|
||||||
|
if (!EnsureSpaceToStoreEvent(size))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Array.Copy(networkedData, 0, buffer, index, size);
|
Array.Copy(networkedData, index, buffer, this.index, size);
|
||||||
index += size;
|
this.index += size;
|
||||||
|
|
||||||
UpdateNextEventTime();
|
UpdateNextEventTime();
|
||||||
}
|
}
|
||||||
@@ -137,120 +236,140 @@ namespace Marro.PacManUdon
|
|||||||
var currentTime = CurrentTime;
|
var currentTime = CurrentTime;
|
||||||
while (index != 0 && nextEventTime <= currentTime)
|
while (index != 0 && nextEventTime <= currentTime)
|
||||||
{
|
{
|
||||||
ProcessNextEvent();
|
ProcessIncomingEvent();
|
||||||
UpdateNextEventTime();
|
UpdateNextEventTime();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateNextEventTime()
|
private void UpdateNextEventTime()
|
||||||
{
|
{
|
||||||
if (index > 0)
|
if (index == 0)
|
||||||
{
|
{
|
||||||
var nextEventTime = BitConverter.ToUInt32(buffer, 0);
|
return;
|
||||||
if (nextEventTime >= this.nextEventTime)
|
}
|
||||||
{
|
|
||||||
this.nextEventTime = nextEventTime;
|
var nextEventTime = BitConverter.ToUInt32(buffer, HeaderTimestampIndex);
|
||||||
}
|
if (nextEventTime >= this.nextEventTime)
|
||||||
else
|
{
|
||||||
{
|
this.nextEventTime = nextEventTime;
|
||||||
Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Events are in invalid order! Clearing buffer.");
|
}
|
||||||
ClearBuffer();
|
else
|
||||||
return;
|
{
|
||||||
}
|
Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)}) New event is earlier than previous event!");
|
||||||
|
HandleError();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ProcessNextEvent()
|
private void ProcessIncomingEvent()
|
||||||
{
|
{
|
||||||
var eventType = (NetworkEventType)buffer[4];
|
var eventTime = BitConverter.ToUInt32(buffer, HeaderTimestampIndex);
|
||||||
|
var eventType = (NetworkEventType)buffer[HeaderEventTypeIndex];
|
||||||
|
var index = (int)HeaderLength; // Skip header
|
||||||
|
|
||||||
switch (eventType)
|
if (false) // TODO: check event type
|
||||||
{
|
{
|
||||||
default:
|
Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Invalid event type for incoming data! Buffer will be cleared.");
|
||||||
Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Invalid sync type for incoming data! Buffer will be cleared.");
|
HandleError();
|
||||||
ClearBuffer();
|
return;
|
||||||
return;
|
|
||||||
case NetworkEventType.FullSync:
|
|
||||||
ProcessFullSync();
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void ProcessFullSync()
|
|
||||||
{
|
|
||||||
var index = 5; // Skip header
|
|
||||||
foreach (var obj in syncedObjects)
|
foreach (var obj in syncedObjects)
|
||||||
{
|
{
|
||||||
var success = obj.SetSyncedData(buffer, ref index);
|
var success = obj.SetSyncedData(buffer, ref index, eventType, eventTime);
|
||||||
|
|
||||||
if (!success)
|
if (!success)
|
||||||
{
|
{
|
||||||
Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Malformed data reported by {obj.name} during full sync! Clearing buffer and requesting new full sync.");
|
Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Malformed data reported by {obj.name} during event type {eventType}! Resetting state.");
|
||||||
ClearBuffer();
|
HandleError();
|
||||||
RequestFullSync();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (index > this.index)
|
||||||
|
{
|
||||||
|
Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Buffer overflow during SetSyncedData for {obj.name} in event type {eventType}! Resetting state.");
|
||||||
|
HandleError();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var eventSize = BitConverter.ToUInt16(buffer, HeaderEventSizeIndex);
|
||||||
|
if (index != eventSize)
|
||||||
|
{
|
||||||
|
Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Amount of data read does not match event size! Expected {eventSize}, read {index}.");
|
||||||
|
HandleError();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
RemoveProcessedDataFromBuffer(index);
|
RemoveProcessedDataFromBuffer(index);
|
||||||
|
|
||||||
Debug.Log($"Processed full sync! Total {index} bytes.");
|
Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Processed incoming event! Total {index} bytes.");
|
||||||
|
|
||||||
|
retriesWithoutSuccess = 0; // We had success!
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool EnsureSpaceToStorePreparedEvent(int eventSize)
|
private void SyncToTime(uint newTime)
|
||||||
|
{
|
||||||
|
var timeToSyncTo = newTime - Delay;
|
||||||
|
startTimeTicks = DateTime.UtcNow.Ticks - timeToSyncTo * TimeSpan.TicksPerMillisecond;
|
||||||
|
Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Synced to time {newTime}, startTimeTicks is now {startTimeTicks}");
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool EnsureSpaceToStoreEvent(int eventSize)
|
||||||
{
|
{
|
||||||
if (index + eventSize <= buffer.Length)
|
if (index + eventSize <= buffer.Length)
|
||||||
{
|
{
|
||||||
return true; // Enough space!
|
return true; // Enough space!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var newBufferSize = ((index + eventSize) / BufferIncrementSizeBytes + 1) * BufferIncrementSizeBytes;
|
||||||
|
|
||||||
|
var success = IncreaseBufferSize(newBufferSize);
|
||||||
|
if (success)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (index == 0)
|
if (index == 0)
|
||||||
{
|
{
|
||||||
Debug.LogError($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Buffer is not large enough to store event! Viewing remote play is not possible.");
|
Debug.LogError($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Buffer is not large enough to store event!");
|
||||||
return false; // Unable to store event, networking features will not function.
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Too much data in buffer to store event!");
|
||||||
}
|
}
|
||||||
|
|
||||||
ClearBuffer();
|
HandleError(); // We can store event now that we cleared the buffer.
|
||||||
|
return false;
|
||||||
Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Too much data in buffer to store event! Old events will be discarded.");
|
|
||||||
return true; // We can store event now that we cleared the buffer.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool EnsureSpaceToStoreReceivedEvent(int eventSize, bool isFullSync)
|
private bool IncreaseBufferSize(int newSize)
|
||||||
{
|
{
|
||||||
if (index + eventSize <= buffer.Length)
|
if (newSize < buffer.Length)
|
||||||
{
|
{
|
||||||
return true; // Enough space!
|
Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Cannot decrease the size of the buffer!");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isFullSync && index == 0)
|
if (newSize > BufferMaxSizeBytes)
|
||||||
{
|
{
|
||||||
Debug.LogError($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Buffer is not large enough to store full sync! Viewing remote play is not possible.");
|
return false;
|
||||||
return false; // Unable to store full sync, networking features will not function.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ClearBuffer();
|
var oldBuffer = buffer;
|
||||||
|
buffer = new byte[newSize];
|
||||||
if (!isFullSync)
|
oldBuffer.CopyTo(buffer, 0);
|
||||||
{
|
return true;
|
||||||
Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Too much data in buffer to store event! Old events will be discarded, and full sync will be performed.");
|
|
||||||
|
|
||||||
RequestFullSync();
|
|
||||||
|
|
||||||
return false; // No use storing this event, we're going to wait for the full sync.
|
|
||||||
}
|
|
||||||
|
|
||||||
Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Too much data in buffer to store full sync! Old events will be discarded.");
|
|
||||||
return true; // We can store event now that we cleared the buffer.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitializeEvent(NetworkEventType eventType, int maxSize, out byte[][] data, out int index)
|
private void InitializeEvent(NetworkEventType eventType, uint eventTime, int maxSize, out byte[][] data, out int index)
|
||||||
{
|
{
|
||||||
data = new byte[maxSize][];
|
data = new byte[maxSize][];
|
||||||
index = 2;
|
index = 3;
|
||||||
|
|
||||||
data[0] = BitConverter.GetBytes(CurrentTime);
|
data[0] = new byte[2]; // Placeholder for event size
|
||||||
data[1] = new byte[] { GameManager.Int32ToByte((int)eventType) };
|
data[1] = BitConverter.GetBytes(eventTime);
|
||||||
|
data[2] = new byte[] { GameManager.Int32ToByte((int)eventType) };
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FlattenAndCopy(byte[][] data, int length, byte[] target, ref int index)
|
private void FlattenAndCopy(byte[][] data, int length, byte[] target, ref int index)
|
||||||
@@ -267,16 +386,62 @@ namespace Marro.PacManUdon
|
|||||||
{
|
{
|
||||||
var oldBuffer = buffer;
|
var oldBuffer = buffer;
|
||||||
index -= amountProcessed;
|
index -= amountProcessed;
|
||||||
buffer = new byte[BufferSizeBytes];
|
buffer = new byte[BufferMaxSizeBytes];
|
||||||
Array.Copy(oldBuffer, amountProcessed, buffer, 0, index);
|
Array.Copy(oldBuffer, amountProcessed, buffer, 0, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ClearBuffer()
|
private void ClearBuffer()
|
||||||
{
|
{
|
||||||
buffer = new byte[BufferSizeBytes];
|
buffer = new byte[BufferMaxSizeBytes];
|
||||||
index = 0;
|
index = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void HandleError()
|
||||||
|
{
|
||||||
|
retriesWithoutSuccess++;
|
||||||
|
|
||||||
|
if (retriesWithoutSuccess > 3)
|
||||||
|
{
|
||||||
|
Debug.LogError($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Fatal: Retried 3 times without success.");
|
||||||
|
var zero = 0;
|
||||||
|
Debug.Log(1 / zero); // Intentionally crash
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Encountered data error, attempting to recover via full sync.");
|
||||||
|
|
||||||
|
ClearBuffer();
|
||||||
|
|
||||||
|
if (!isOwner)
|
||||||
|
{
|
||||||
|
RequestEvent(NetworkEventType.FullSync);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SendEvent(NetworkEventType.FullSync);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetOwner(bool isOwner)
|
||||||
|
{
|
||||||
|
this.isOwner = isOwner;
|
||||||
|
|
||||||
|
if (DebugImageToIndicateOwner != null)
|
||||||
|
{
|
||||||
|
DebugImageToIndicateOwner.SetFloat("Color", isOwner ? 1 : 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnOwnershipTransferred(VRCPlayerApi newOwner)
|
||||||
|
{
|
||||||
|
SetOwner(newOwner == Networking.LocalPlayer);
|
||||||
|
|
||||||
|
if(isOwner)
|
||||||
|
{
|
||||||
|
HandleError();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override void OnPreSerialization()
|
public override void OnPreSerialization()
|
||||||
{
|
{
|
||||||
if (isOwner)
|
if (isOwner)
|
||||||
@@ -284,24 +449,30 @@ namespace Marro.PacManUdon
|
|||||||
networkedData = new byte[index];
|
networkedData = new byte[index];
|
||||||
Array.Copy(buffer, networkedData, index);
|
Array.Copy(buffer, networkedData, index);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
networkedData = new byte[0]; // Prevent exception loop in VRChat SDK
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnPostSerialization(SerializationResult result)
|
public override void OnPostSerialization(SerializationResult result)
|
||||||
{
|
{
|
||||||
if (!result.success)
|
if (!result.success)
|
||||||
{
|
{
|
||||||
Debug.LogWarning($"Serialization failed! Tried to send {result.byteCount} bytes.");
|
Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Serialization failed! Tried to send {result.byteCount} bytes.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.Log($"Serialized with {result.byteCount} bytes!");
|
|
||||||
|
|
||||||
if (isOwner)
|
if (!isOwner || networkedData.Length == 0)
|
||||||
{
|
{
|
||||||
// Remove all transferred data from the buffer, leaving data that came in after serialization
|
return;
|
||||||
RemoveProcessedDataFromBuffer(networkedData.Length);
|
|
||||||
networkedData = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Serialized with {networkedData.Length} bytes!\nBytes sent:\n{BytesToString(networkedData)}");
|
||||||
|
|
||||||
|
// Remove all transferred data from the buffer, leaving data that came in after serialization
|
||||||
|
RemoveProcessedDataFromBuffer(networkedData.Length);
|
||||||
|
networkedData = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnDeserialization()
|
public override void OnDeserialization()
|
||||||
@@ -312,8 +483,24 @@ namespace Marro.PacManUdon
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public float GetDtInSeconds(uint currentTime, uint lastUpdate)
|
||||||
|
{
|
||||||
|
return (CurrentTime - lastUpdate) / 1000f;
|
||||||
|
}
|
||||||
|
|
||||||
public uint CurrentTime => (uint)((DateTime.UtcNow.Ticks - startTimeTicks) / TimeSpan.TicksPerMillisecond);
|
public uint CurrentTime => (uint)((DateTime.UtcNow.Ticks - startTimeTicks) / TimeSpan.TicksPerMillisecond);
|
||||||
|
|
||||||
public bool IsOwner => isOwner;
|
public bool IsOwner => isOwner;
|
||||||
|
|
||||||
|
public string BytesToString(byte[] bytes)
|
||||||
|
{
|
||||||
|
var sb = new StringBuilder("new byte[] { ");
|
||||||
|
foreach (var b in bytes)
|
||||||
|
{
|
||||||
|
sb.Append(b + ", ");
|
||||||
|
}
|
||||||
|
sb.Append("}");
|
||||||
|
return sb.ToString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,11 +2,12 @@
|
|||||||
using UdonSharp;
|
using UdonSharp;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace Assets.Scripts
|
namespace Marro.PacManUdon
|
||||||
{
|
{
|
||||||
public abstract class SyncedObject : UdonSharpBehaviour
|
public abstract class SyncedObject : UdonSharpBehaviour
|
||||||
{
|
{
|
||||||
public abstract void AppendSyncedData(byte[][] data, ref int index);
|
public abstract void AppendSyncedData(byte[][] data, ref int index, NetworkEventType eventType, uint eventTime);
|
||||||
public abstract bool SetSyncedData(byte[] data, ref int index);
|
public abstract bool SetSyncedData(byte[] data, ref int index, NetworkEventType eventType, uint eventTime);
|
||||||
|
public abstract void SyncedToNewTime(uint oldTime, uint newTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
8
Assets/Test stuff.meta
Normal file
8
Assets/Test stuff.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1ab80220efbebb2489a3218f3ee9b00b
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
109
Assets/Test stuff/ColoredTexture.controller
Normal file
109
Assets/Test stuff/ColoredTexture.controller
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!91 &9100000
|
||||||
|
AnimatorController:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_Name: ColoredTexture
|
||||||
|
serializedVersion: 5
|
||||||
|
m_AnimatorParameters:
|
||||||
|
- m_Name: Color
|
||||||
|
m_Type: 1
|
||||||
|
m_DefaultFloat: 0
|
||||||
|
m_DefaultInt: 0
|
||||||
|
m_DefaultBool: 0
|
||||||
|
m_Controller: {fileID: 0}
|
||||||
|
m_AnimatorLayers:
|
||||||
|
- serializedVersion: 5
|
||||||
|
m_Name: Base Layer
|
||||||
|
m_StateMachine: {fileID: 2235177317997810699}
|
||||||
|
m_Mask: {fileID: 0}
|
||||||
|
m_Motions: []
|
||||||
|
m_Behaviours: []
|
||||||
|
m_BlendingMode: 0
|
||||||
|
m_SyncedLayerIndex: -1
|
||||||
|
m_DefaultWeight: 0
|
||||||
|
m_IKPass: 0
|
||||||
|
m_SyncedLayerAffectsTiming: 0
|
||||||
|
m_Controller: {fileID: 9100000}
|
||||||
|
--- !u!1107 &2235177317997810699
|
||||||
|
AnimatorStateMachine:
|
||||||
|
serializedVersion: 6
|
||||||
|
m_ObjectHideFlags: 1
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_Name: Base Layer
|
||||||
|
m_ChildStates:
|
||||||
|
- serializedVersion: 1
|
||||||
|
m_State: {fileID: 6251436573727931732}
|
||||||
|
m_Position: {x: 384.82895, y: 133.70117, z: 0}
|
||||||
|
m_ChildStateMachines: []
|
||||||
|
m_AnyStateTransitions: []
|
||||||
|
m_EntryTransitions: []
|
||||||
|
m_StateMachineTransitions: {}
|
||||||
|
m_StateMachineBehaviours: []
|
||||||
|
m_AnyStatePosition: {x: 50, y: 20, z: 0}
|
||||||
|
m_EntryPosition: {x: 50, y: 120, z: 0}
|
||||||
|
m_ExitPosition: {x: 800, y: 120, z: 0}
|
||||||
|
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
|
||||||
|
m_DefaultState: {fileID: 6251436573727931732}
|
||||||
|
--- !u!1102 &6251436573727931732
|
||||||
|
AnimatorState:
|
||||||
|
serializedVersion: 6
|
||||||
|
m_ObjectHideFlags: 1
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_Name: Blend Tree
|
||||||
|
m_Speed: 1
|
||||||
|
m_CycleOffset: 0
|
||||||
|
m_Transitions: []
|
||||||
|
m_StateMachineBehaviours: []
|
||||||
|
m_Position: {x: 50, y: 50, z: 0}
|
||||||
|
m_IKOnFeet: 0
|
||||||
|
m_WriteDefaultValues: 1
|
||||||
|
m_Mirror: 0
|
||||||
|
m_SpeedParameterActive: 0
|
||||||
|
m_MirrorParameterActive: 0
|
||||||
|
m_CycleOffsetParameterActive: 0
|
||||||
|
m_TimeParameterActive: 0
|
||||||
|
m_Motion: {fileID: 7315205519034161812}
|
||||||
|
m_Tag:
|
||||||
|
m_SpeedParameter:
|
||||||
|
m_MirrorParameter:
|
||||||
|
m_CycleOffsetParameter:
|
||||||
|
m_TimeParameter:
|
||||||
|
--- !u!206 &7315205519034161812
|
||||||
|
BlendTree:
|
||||||
|
m_ObjectHideFlags: 1
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_Name: Blend Tree
|
||||||
|
m_Childs:
|
||||||
|
- serializedVersion: 2
|
||||||
|
m_Motion: {fileID: 7400000, guid: f06a4450a22bb184bb3881fbc7ddc36f, type: 2}
|
||||||
|
m_Threshold: 0
|
||||||
|
m_Position: {x: 0, y: 0}
|
||||||
|
m_TimeScale: 1
|
||||||
|
m_CycleOffset: 0
|
||||||
|
m_DirectBlendParameter: Color
|
||||||
|
m_Mirror: 0
|
||||||
|
- serializedVersion: 2
|
||||||
|
m_Motion: {fileID: 7400000, guid: 152a2df117ac1c948b25f28a386ac289, type: 2}
|
||||||
|
m_Threshold: 1
|
||||||
|
m_Position: {x: 0, y: 0}
|
||||||
|
m_TimeScale: 1
|
||||||
|
m_CycleOffset: 0
|
||||||
|
m_DirectBlendParameter: Color
|
||||||
|
m_Mirror: 0
|
||||||
|
m_BlendParameter: Color
|
||||||
|
m_BlendParameterY: Blend
|
||||||
|
m_MinThreshold: 0
|
||||||
|
m_MaxThreshold: 1
|
||||||
|
m_UseAutomaticThresholds: 0
|
||||||
|
m_NormalizedBlendValues: 0
|
||||||
|
m_BlendType: 0
|
||||||
8
Assets/Test stuff/ColoredTexture.controller.meta
Normal file
8
Assets/Test stuff/ColoredTexture.controller.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 72593807222e776478e455c600f7ccf9
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 9100000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
206
Assets/Test stuff/GreenTexture.anim
Normal file
206
Assets/Test stuff/GreenTexture.anim
Normal file
@@ -0,0 +1,206 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!74 &7400000
|
||||||
|
AnimationClip:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_Name: GreenTexture
|
||||||
|
serializedVersion: 7
|
||||||
|
m_Legacy: 0
|
||||||
|
m_Compressed: 0
|
||||||
|
m_UseHighQualityCurve: 1
|
||||||
|
m_RotationCurves: []
|
||||||
|
m_CompressedRotationCurves: []
|
||||||
|
m_EulerCurves: []
|
||||||
|
m_PositionCurves: []
|
||||||
|
m_ScaleCurves: []
|
||||||
|
m_FloatCurves:
|
||||||
|
- serializedVersion: 2
|
||||||
|
curve:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 136
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0
|
||||||
|
outWeight: 0
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
attribute: m_Color.r
|
||||||
|
path:
|
||||||
|
classID: 114
|
||||||
|
script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||||
|
flags: 0
|
||||||
|
- serializedVersion: 2
|
||||||
|
curve:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 1
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 136
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0
|
||||||
|
outWeight: 0
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
attribute: m_Color.g
|
||||||
|
path:
|
||||||
|
classID: 114
|
||||||
|
script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||||
|
flags: 0
|
||||||
|
- serializedVersion: 2
|
||||||
|
curve:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 136
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0
|
||||||
|
outWeight: 0
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
attribute: m_Color.b
|
||||||
|
path:
|
||||||
|
classID: 114
|
||||||
|
script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||||
|
flags: 0
|
||||||
|
m_PPtrCurves: []
|
||||||
|
m_SampleRate: 1
|
||||||
|
m_WrapMode: 0
|
||||||
|
m_Bounds:
|
||||||
|
m_Center: {x: 0, y: 0, z: 0}
|
||||||
|
m_Extent: {x: 0, y: 0, z: 0}
|
||||||
|
m_ClipBindingConstant:
|
||||||
|
genericBindings:
|
||||||
|
- serializedVersion: 2
|
||||||
|
path: 0
|
||||||
|
attribute: 2526845255
|
||||||
|
script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||||
|
typeID: 114
|
||||||
|
customType: 0
|
||||||
|
isPPtrCurve: 0
|
||||||
|
isIntCurve: 0
|
||||||
|
isSerializeReferenceCurve: 0
|
||||||
|
- serializedVersion: 2
|
||||||
|
path: 0
|
||||||
|
attribute: 4215373228
|
||||||
|
script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||||
|
typeID: 114
|
||||||
|
customType: 0
|
||||||
|
isPPtrCurve: 0
|
||||||
|
isIntCurve: 0
|
||||||
|
isSerializeReferenceCurve: 0
|
||||||
|
- serializedVersion: 2
|
||||||
|
path: 0
|
||||||
|
attribute: 2334886179
|
||||||
|
script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||||
|
typeID: 114
|
||||||
|
customType: 0
|
||||||
|
isPPtrCurve: 0
|
||||||
|
isIntCurve: 0
|
||||||
|
isSerializeReferenceCurve: 0
|
||||||
|
pptrCurveMapping: []
|
||||||
|
m_AnimationClipSettings:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_AdditiveReferencePoseClip: {fileID: 0}
|
||||||
|
m_AdditiveReferencePoseTime: 0
|
||||||
|
m_StartTime: 0
|
||||||
|
m_StopTime: 0
|
||||||
|
m_OrientationOffsetY: 0
|
||||||
|
m_Level: 0
|
||||||
|
m_CycleOffset: 0
|
||||||
|
m_HasAdditiveReferencePose: 0
|
||||||
|
m_LoopTime: 0
|
||||||
|
m_LoopBlend: 0
|
||||||
|
m_LoopBlendOrientation: 0
|
||||||
|
m_LoopBlendPositionY: 0
|
||||||
|
m_LoopBlendPositionXZ: 0
|
||||||
|
m_KeepOriginalOrientation: 0
|
||||||
|
m_KeepOriginalPositionY: 1
|
||||||
|
m_KeepOriginalPositionXZ: 0
|
||||||
|
m_HeightFromFeet: 0
|
||||||
|
m_Mirror: 0
|
||||||
|
m_EditorCurves:
|
||||||
|
- serializedVersion: 2
|
||||||
|
curve:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 136
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0
|
||||||
|
outWeight: 0
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
attribute: m_Color.r
|
||||||
|
path:
|
||||||
|
classID: 114
|
||||||
|
script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||||
|
flags: 0
|
||||||
|
- serializedVersion: 2
|
||||||
|
curve:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 1
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 136
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0
|
||||||
|
outWeight: 0
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
attribute: m_Color.g
|
||||||
|
path:
|
||||||
|
classID: 114
|
||||||
|
script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||||
|
flags: 0
|
||||||
|
- serializedVersion: 2
|
||||||
|
curve:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 136
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0
|
||||||
|
outWeight: 0
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
attribute: m_Color.b
|
||||||
|
path:
|
||||||
|
classID: 114
|
||||||
|
script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||||
|
flags: 0
|
||||||
|
m_EulerEditorCurves: []
|
||||||
|
m_HasGenericRootTransform: 0
|
||||||
|
m_HasMotionFloatCurves: 0
|
||||||
|
m_Events: []
|
||||||
8
Assets/Test stuff/GreenTexture.anim.meta
Normal file
8
Assets/Test stuff/GreenTexture.anim.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 152a2df117ac1c948b25f28a386ac289
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 7400000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
206
Assets/Test stuff/RedTexture.anim
Normal file
206
Assets/Test stuff/RedTexture.anim
Normal file
@@ -0,0 +1,206 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!74 &7400000
|
||||||
|
AnimationClip:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_Name: RedTexture
|
||||||
|
serializedVersion: 7
|
||||||
|
m_Legacy: 0
|
||||||
|
m_Compressed: 0
|
||||||
|
m_UseHighQualityCurve: 1
|
||||||
|
m_RotationCurves: []
|
||||||
|
m_CompressedRotationCurves: []
|
||||||
|
m_EulerCurves: []
|
||||||
|
m_PositionCurves: []
|
||||||
|
m_ScaleCurves: []
|
||||||
|
m_FloatCurves:
|
||||||
|
- serializedVersion: 2
|
||||||
|
curve:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 1
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 136
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0
|
||||||
|
outWeight: 0
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
attribute: m_Color.r
|
||||||
|
path:
|
||||||
|
classID: 114
|
||||||
|
script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||||
|
flags: 0
|
||||||
|
- serializedVersion: 2
|
||||||
|
curve:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 136
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0
|
||||||
|
outWeight: 0
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
attribute: m_Color.g
|
||||||
|
path:
|
||||||
|
classID: 114
|
||||||
|
script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||||
|
flags: 0
|
||||||
|
- serializedVersion: 2
|
||||||
|
curve:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 136
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0
|
||||||
|
outWeight: 0
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
attribute: m_Color.b
|
||||||
|
path:
|
||||||
|
classID: 114
|
||||||
|
script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||||
|
flags: 0
|
||||||
|
m_PPtrCurves: []
|
||||||
|
m_SampleRate: 1
|
||||||
|
m_WrapMode: 0
|
||||||
|
m_Bounds:
|
||||||
|
m_Center: {x: 0, y: 0, z: 0}
|
||||||
|
m_Extent: {x: 0, y: 0, z: 0}
|
||||||
|
m_ClipBindingConstant:
|
||||||
|
genericBindings:
|
||||||
|
- serializedVersion: 2
|
||||||
|
path: 0
|
||||||
|
attribute: 2526845255
|
||||||
|
script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||||
|
typeID: 114
|
||||||
|
customType: 0
|
||||||
|
isPPtrCurve: 0
|
||||||
|
isIntCurve: 0
|
||||||
|
isSerializeReferenceCurve: 0
|
||||||
|
- serializedVersion: 2
|
||||||
|
path: 0
|
||||||
|
attribute: 4215373228
|
||||||
|
script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||||
|
typeID: 114
|
||||||
|
customType: 0
|
||||||
|
isPPtrCurve: 0
|
||||||
|
isIntCurve: 0
|
||||||
|
isSerializeReferenceCurve: 0
|
||||||
|
- serializedVersion: 2
|
||||||
|
path: 0
|
||||||
|
attribute: 2334886179
|
||||||
|
script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||||
|
typeID: 114
|
||||||
|
customType: 0
|
||||||
|
isPPtrCurve: 0
|
||||||
|
isIntCurve: 0
|
||||||
|
isSerializeReferenceCurve: 0
|
||||||
|
pptrCurveMapping: []
|
||||||
|
m_AnimationClipSettings:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_AdditiveReferencePoseClip: {fileID: 0}
|
||||||
|
m_AdditiveReferencePoseTime: 0
|
||||||
|
m_StartTime: 0
|
||||||
|
m_StopTime: 0
|
||||||
|
m_OrientationOffsetY: 0
|
||||||
|
m_Level: 0
|
||||||
|
m_CycleOffset: 0
|
||||||
|
m_HasAdditiveReferencePose: 0
|
||||||
|
m_LoopTime: 0
|
||||||
|
m_LoopBlend: 0
|
||||||
|
m_LoopBlendOrientation: 0
|
||||||
|
m_LoopBlendPositionY: 0
|
||||||
|
m_LoopBlendPositionXZ: 0
|
||||||
|
m_KeepOriginalOrientation: 0
|
||||||
|
m_KeepOriginalPositionY: 1
|
||||||
|
m_KeepOriginalPositionXZ: 0
|
||||||
|
m_HeightFromFeet: 0
|
||||||
|
m_Mirror: 0
|
||||||
|
m_EditorCurves:
|
||||||
|
- serializedVersion: 2
|
||||||
|
curve:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 1
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 136
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0
|
||||||
|
outWeight: 0
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
attribute: m_Color.r
|
||||||
|
path:
|
||||||
|
classID: 114
|
||||||
|
script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||||
|
flags: 0
|
||||||
|
- serializedVersion: 2
|
||||||
|
curve:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 136
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0
|
||||||
|
outWeight: 0
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
attribute: m_Color.g
|
||||||
|
path:
|
||||||
|
classID: 114
|
||||||
|
script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||||
|
flags: 0
|
||||||
|
- serializedVersion: 2
|
||||||
|
curve:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 136
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0
|
||||||
|
outWeight: 0
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
attribute: m_Color.b
|
||||||
|
path:
|
||||||
|
classID: 114
|
||||||
|
script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||||
|
flags: 0
|
||||||
|
m_EulerEditorCurves: []
|
||||||
|
m_HasGenericRootTransform: 0
|
||||||
|
m_HasMotionFloatCurves: 0
|
||||||
|
m_Events: []
|
||||||
8
Assets/Test stuff/RedTexture.anim.meta
Normal file
8
Assets/Test stuff/RedTexture.anim.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f06a4450a22bb184bb3881fbc7ddc36f
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 7400000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
394
Assets/Test stuff/TestBall.asset
Normal file
394
Assets/Test stuff/TestBall.asset
Normal file
@@ -0,0 +1,394 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!114 &11400000
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
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: 11500000, guid: c333ccfdd0cbdbc4ca30cef2dd6e6b9b, type: 3}
|
||||||
|
m_Name: TestBall
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
serializedUdonProgramAsset: {fileID: 11400000, guid: 8968388b0e4fe434fb8da62328c108a0, type: 2}
|
||||||
|
udonAssembly:
|
||||||
|
assemblyError:
|
||||||
|
sourceCsScript: {fileID: 11500000, guid: 0980d82a15346eb45b49fd33db0ffee9, type: 3}
|
||||||
|
scriptVersion: 2
|
||||||
|
compiledVersion: 2
|
||||||
|
behaviourSyncMode: 0
|
||||||
|
hasInteractEvent: 0
|
||||||
|
scriptID: -3035274785675086507
|
||||||
|
serializationData:
|
||||||
|
SerializedFormat: 2
|
||||||
|
SerializedBytes:
|
||||||
|
ReferencedUnityObjects: []
|
||||||
|
SerializedBytesString:
|
||||||
|
Prefab: {fileID: 0}
|
||||||
|
PrefabModificationsReferencedUnityObjects: []
|
||||||
|
PrefabModifications: []
|
||||||
|
SerializationNodes:
|
||||||
|
- Name: fieldDefinitions
|
||||||
|
Entry: 7
|
||||||
|
Data: 0|System.Collections.Generic.Dictionary`2[[System.String, mscorlib],[UdonSharp.Compiler.FieldDefinition,
|
||||||
|
UdonSharp.Editor]], mscorlib
|
||||||
|
- Name: comparer
|
||||||
|
Entry: 7
|
||||||
|
Data: 1|System.Collections.Generic.GenericEqualityComparer`1[[System.String,
|
||||||
|
mscorlib]], mscorlib
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 12
|
||||||
|
Data: 6
|
||||||
|
- Name:
|
||||||
|
Entry: 7
|
||||||
|
Data:
|
||||||
|
- Name: $k
|
||||||
|
Entry: 1
|
||||||
|
Data: networkManager
|
||||||
|
- Name: $v
|
||||||
|
Entry: 7
|
||||||
|
Data: 2|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
|
- Name: <Name>k__BackingField
|
||||||
|
Entry: 1
|
||||||
|
Data: networkManager
|
||||||
|
- Name: <UserType>k__BackingField
|
||||||
|
Entry: 7
|
||||||
|
Data: 3|System.RuntimeType, mscorlib
|
||||||
|
- Name:
|
||||||
|
Entry: 1
|
||||||
|
Data: Marro.PacManUdon.NetworkManager, Assembly-CSharp
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name: <SystemType>k__BackingField
|
||||||
|
Entry: 7
|
||||||
|
Data: 4|System.RuntimeType, mscorlib
|
||||||
|
- Name:
|
||||||
|
Entry: 1
|
||||||
|
Data: VRC.Udon.UdonBehaviour, VRC.Udon
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name: <SyncMode>k__BackingField
|
||||||
|
Entry: 7
|
||||||
|
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||||
|
- Name:
|
||||||
|
Entry: 6
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name: <IsSerialized>k__BackingField
|
||||||
|
Entry: 5
|
||||||
|
Data: true
|
||||||
|
- Name: _fieldAttributes
|
||||||
|
Entry: 7
|
||||||
|
Data: 5|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||||
|
- Name:
|
||||||
|
Entry: 12
|
||||||
|
Data: 1
|
||||||
|
- Name:
|
||||||
|
Entry: 7
|
||||||
|
Data: 6|UnityEngine.SerializeField, UnityEngine.CoreModule
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 13
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 7
|
||||||
|
Data:
|
||||||
|
- Name: $k
|
||||||
|
Entry: 1
|
||||||
|
Data: start
|
||||||
|
- Name: $v
|
||||||
|
Entry: 7
|
||||||
|
Data: 7|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
|
- Name: <Name>k__BackingField
|
||||||
|
Entry: 1
|
||||||
|
Data: start
|
||||||
|
- Name: <UserType>k__BackingField
|
||||||
|
Entry: 7
|
||||||
|
Data: 8|System.RuntimeType, mscorlib
|
||||||
|
- Name:
|
||||||
|
Entry: 1
|
||||||
|
Data: UnityEngine.Transform, UnityEngine.CoreModule
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name: <SystemType>k__BackingField
|
||||||
|
Entry: 9
|
||||||
|
Data: 8
|
||||||
|
- Name: <SyncMode>k__BackingField
|
||||||
|
Entry: 7
|
||||||
|
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||||
|
- Name:
|
||||||
|
Entry: 6
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name: <IsSerialized>k__BackingField
|
||||||
|
Entry: 5
|
||||||
|
Data: true
|
||||||
|
- Name: _fieldAttributes
|
||||||
|
Entry: 7
|
||||||
|
Data: 9|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||||
|
- Name:
|
||||||
|
Entry: 12
|
||||||
|
Data: 1
|
||||||
|
- Name:
|
||||||
|
Entry: 7
|
||||||
|
Data: 10|UnityEngine.SerializeField, UnityEngine.CoreModule
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 13
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 7
|
||||||
|
Data:
|
||||||
|
- Name: $k
|
||||||
|
Entry: 1
|
||||||
|
Data: end
|
||||||
|
- Name: $v
|
||||||
|
Entry: 7
|
||||||
|
Data: 11|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
|
- Name: <Name>k__BackingField
|
||||||
|
Entry: 1
|
||||||
|
Data: end
|
||||||
|
- Name: <UserType>k__BackingField
|
||||||
|
Entry: 9
|
||||||
|
Data: 8
|
||||||
|
- Name: <SystemType>k__BackingField
|
||||||
|
Entry: 9
|
||||||
|
Data: 8
|
||||||
|
- Name: <SyncMode>k__BackingField
|
||||||
|
Entry: 7
|
||||||
|
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||||
|
- Name:
|
||||||
|
Entry: 6
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name: <IsSerialized>k__BackingField
|
||||||
|
Entry: 5
|
||||||
|
Data: true
|
||||||
|
- Name: _fieldAttributes
|
||||||
|
Entry: 7
|
||||||
|
Data: 12|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||||
|
- Name:
|
||||||
|
Entry: 12
|
||||||
|
Data: 1
|
||||||
|
- Name:
|
||||||
|
Entry: 7
|
||||||
|
Data: 13|UnityEngine.SerializeField, UnityEngine.CoreModule
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 13
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 7
|
||||||
|
Data:
|
||||||
|
- Name: $k
|
||||||
|
Entry: 1
|
||||||
|
Data: amountUp
|
||||||
|
- Name: $v
|
||||||
|
Entry: 7
|
||||||
|
Data: 14|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
|
- Name: <Name>k__BackingField
|
||||||
|
Entry: 1
|
||||||
|
Data: amountUp
|
||||||
|
- Name: <UserType>k__BackingField
|
||||||
|
Entry: 7
|
||||||
|
Data: 15|System.RuntimeType, mscorlib
|
||||||
|
- Name:
|
||||||
|
Entry: 1
|
||||||
|
Data: System.Single, mscorlib
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name: <SystemType>k__BackingField
|
||||||
|
Entry: 9
|
||||||
|
Data: 15
|
||||||
|
- Name: <SyncMode>k__BackingField
|
||||||
|
Entry: 7
|
||||||
|
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||||
|
- Name:
|
||||||
|
Entry: 6
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name: <IsSerialized>k__BackingField
|
||||||
|
Entry: 5
|
||||||
|
Data: false
|
||||||
|
- Name: _fieldAttributes
|
||||||
|
Entry: 7
|
||||||
|
Data: 16|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||||
|
- Name:
|
||||||
|
Entry: 12
|
||||||
|
Data: 0
|
||||||
|
- Name:
|
||||||
|
Entry: 13
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 7
|
||||||
|
Data:
|
||||||
|
- Name: $k
|
||||||
|
Entry: 1
|
||||||
|
Data: loopOffset
|
||||||
|
- Name: $v
|
||||||
|
Entry: 7
|
||||||
|
Data: 17|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
|
- Name: <Name>k__BackingField
|
||||||
|
Entry: 1
|
||||||
|
Data: loopOffset
|
||||||
|
- Name: <UserType>k__BackingField
|
||||||
|
Entry: 7
|
||||||
|
Data: 18|System.RuntimeType, mscorlib
|
||||||
|
- Name:
|
||||||
|
Entry: 1
|
||||||
|
Data: System.Int32, mscorlib
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name: <SystemType>k__BackingField
|
||||||
|
Entry: 9
|
||||||
|
Data: 18
|
||||||
|
- Name: <SyncMode>k__BackingField
|
||||||
|
Entry: 7
|
||||||
|
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||||
|
- Name:
|
||||||
|
Entry: 6
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name: <IsSerialized>k__BackingField
|
||||||
|
Entry: 5
|
||||||
|
Data: false
|
||||||
|
- Name: _fieldAttributes
|
||||||
|
Entry: 7
|
||||||
|
Data: 19|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||||
|
- Name:
|
||||||
|
Entry: 12
|
||||||
|
Data: 0
|
||||||
|
- Name:
|
||||||
|
Entry: 13
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 7
|
||||||
|
Data:
|
||||||
|
- Name: $k
|
||||||
|
Entry: 1
|
||||||
|
Data: lastUpdate
|
||||||
|
- Name: $v
|
||||||
|
Entry: 7
|
||||||
|
Data: 20|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||||
|
- Name: <Name>k__BackingField
|
||||||
|
Entry: 1
|
||||||
|
Data: lastUpdate
|
||||||
|
- Name: <UserType>k__BackingField
|
||||||
|
Entry: 7
|
||||||
|
Data: 21|System.RuntimeType, mscorlib
|
||||||
|
- Name:
|
||||||
|
Entry: 1
|
||||||
|
Data: System.UInt32, mscorlib
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name: <SystemType>k__BackingField
|
||||||
|
Entry: 9
|
||||||
|
Data: 21
|
||||||
|
- Name: <SyncMode>k__BackingField
|
||||||
|
Entry: 7
|
||||||
|
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||||
|
- Name:
|
||||||
|
Entry: 6
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name: <IsSerialized>k__BackingField
|
||||||
|
Entry: 5
|
||||||
|
Data: false
|
||||||
|
- Name: _fieldAttributes
|
||||||
|
Entry: 7
|
||||||
|
Data: 22|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||||
|
- Name:
|
||||||
|
Entry: 12
|
||||||
|
Data: 0
|
||||||
|
- Name:
|
||||||
|
Entry: 13
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 13
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
8
Assets/Test stuff/TestBall.asset.meta
Normal file
8
Assets/Test stuff/TestBall.asset.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1845851c6c8f8254baa6b40646c66d59
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 11400000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
107
Assets/Test stuff/TestBall.cs
Normal file
107
Assets/Test stuff/TestBall.cs
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
using librsync.net;
|
||||||
|
using Marro.PacManUdon;
|
||||||
|
using System;
|
||||||
|
using System.Drawing.Text;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class TestBall : SyncedObject
|
||||||
|
{
|
||||||
|
[SerializeField] private NetworkManager networkManager;
|
||||||
|
[SerializeField] private Transform start;
|
||||||
|
[SerializeField] private Transform end;
|
||||||
|
|
||||||
|
private const int LoopTimeMs = 1000;
|
||||||
|
private const float MaxUp = 0.7f;
|
||||||
|
private const float UpPerPress = 0.4f;
|
||||||
|
private const float DownPerSecond = 1;
|
||||||
|
|
||||||
|
private float amountUp = 0;
|
||||||
|
private int loopOffset = 0;
|
||||||
|
private uint lastUpdate;
|
||||||
|
|
||||||
|
private void Start()
|
||||||
|
{
|
||||||
|
networkManager.Initialize();
|
||||||
|
lastUpdate = networkManager.CurrentTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void FixedUpdate()
|
||||||
|
{
|
||||||
|
var currentTime = networkManager.CurrentTime;
|
||||||
|
float dt = networkManager.GetDtInSeconds(currentTime, lastUpdate);
|
||||||
|
DeltaUp(-DownPerSecond * dt);
|
||||||
|
|
||||||
|
float progress = GetProgress(currentTime);
|
||||||
|
transform.position = Vector3.Lerp(start.position, end.position, progress) + amountUp * MaxUp * Vector3.up;
|
||||||
|
|
||||||
|
lastUpdate = currentTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DeltaUp(float delta)
|
||||||
|
{
|
||||||
|
amountUp = Mathf.Clamp(amountUp + delta, 0, 1);
|
||||||
|
//Debug.Log($"delta: {delta}, amountUp: {amountUp}");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetProgress(float progress, uint currentTime)
|
||||||
|
{
|
||||||
|
//loopOffset = (int)(progress * LoopTimeMs % (LoopTimeMs + currentTime));
|
||||||
|
loopOffset = (int)(currentTime - progress * LoopTimeMs);
|
||||||
|
//loopOffset = (int)currentTime % LoopTimeMs + (int)(progress * LoopTimeMs);
|
||||||
|
}
|
||||||
|
|
||||||
|
private float GetProgress(uint currentTime)
|
||||||
|
{
|
||||||
|
return ((int)currentTime - loopOffset) % LoopTimeMs / (float)LoopTimeMs; // "uint % int" is not exposed, I love working in Udon
|
||||||
|
//return loopOffset - ((int)currentTime % LoopTimeMs) / (float)LoopTimeMs; // "uint % int" is not exposed, I love working in Udon
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpButtonPressed()
|
||||||
|
{
|
||||||
|
DeltaUp(UpPerPress);
|
||||||
|
Debug.Log($"({nameof(TestBall)}) Up button pressed, jumped up at {GetProgress(networkManager.CurrentTime)} to {amountUp}.");
|
||||||
|
networkManager.SendEvent((NetworkEventType)1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SyncButtonPressed()
|
||||||
|
{
|
||||||
|
networkManager.SendEvent((NetworkEventType)0);
|
||||||
|
Debug.Log($"({nameof(TestBall)}) Sync button pressed, synced at progress {GetProgress(networkManager.CurrentTime)} and amountUp {amountUp}.");
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void AppendSyncedData(byte[][] data, ref int index, NetworkEventType eventType, uint eventTime)
|
||||||
|
{
|
||||||
|
var currentTime = networkManager.CurrentTime;
|
||||||
|
|
||||||
|
if (eventType == 0)
|
||||||
|
{
|
||||||
|
data[index++] = BitConverter.GetBytes(amountUp);
|
||||||
|
data[index++] = BitConverter.GetBytes(GetProgress(currentTime));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool SetSyncedData(byte[] data, ref int index, NetworkEventType eventType, uint eventTime)
|
||||||
|
{
|
||||||
|
var currentTime = networkManager.CurrentTime;
|
||||||
|
|
||||||
|
if (eventType == 0)
|
||||||
|
{
|
||||||
|
amountUp = BitConverter.ToSingle(data, index);
|
||||||
|
SetProgress(BitConverter.ToSingle(data, index + 4), currentTime);
|
||||||
|
Debug.Log($"({nameof(TestBall)}) Received sync event, synced to progress {GetProgress(currentTime)} and amountUp {amountUp}.");
|
||||||
|
index += 8;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DeltaUp(UpPerPress);
|
||||||
|
Debug.Log($"({nameof(TestBall)}) Received up event, jumped up at {GetProgress(networkManager.CurrentTime)} to {amountUp}.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void SyncedToNewTime(uint oldTime, uint newTime)
|
||||||
|
{
|
||||||
|
lastUpdate += newTime - oldTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/Test stuff/TestBall.cs.meta
Normal file
11
Assets/Test stuff/TestBall.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 0980d82a15346eb45b49fd33db0ffee9
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Reference in New Issue
Block a user