older velnet changes - seems to be mostly samples
parent
a77cfc8a19
commit
4896d802ac
|
|
@ -0,0 +1,19 @@
|
||||||
|
name: Publish to Verdaccio
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
publish-npm:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: 16
|
||||||
|
registry-url: http://npm.ugavel.com/
|
||||||
|
- run: npm publish
|
||||||
|
env:
|
||||||
|
NODE_AUTH_TOKEN: ${{secrets.VERDACCIO_TOKEN}}
|
||||||
|
|
@ -5,7 +5,7 @@ Custom networking package for Unity
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
See [VelNetServer](https://github.com/velaboratory/VelNetServer) for description of the server.
|
See [VelNetServerRust](https://github.com/velaboratory/VelNetServerRust) for description of the server.
|
||||||
|
|
||||||
By contrast to the server, the Unity side is pretty complex.
|
By contrast to the server, the Unity side is pretty complex.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ Transform:
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_ConstrainProportionsScale: 0
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 8565720275311462455}
|
m_Father: {fileID: 8565720275311462455}
|
||||||
m_RootOrder: 0
|
m_RootOrder: 0
|
||||||
|
|
@ -52,6 +53,7 @@ MeshRenderer:
|
||||||
m_CastShadows: 1
|
m_CastShadows: 1
|
||||||
m_ReceiveShadows: 1
|
m_ReceiveShadows: 1
|
||||||
m_DynamicOccludee: 1
|
m_DynamicOccludee: 1
|
||||||
|
m_StaticShadowCaster: 0
|
||||||
m_MotionVectors: 1
|
m_MotionVectors: 1
|
||||||
m_LightProbeUsage: 1
|
m_LightProbeUsage: 1
|
||||||
m_ReflectionProbeUsage: 1
|
m_ReflectionProbeUsage: 1
|
||||||
|
|
@ -123,6 +125,7 @@ Transform:
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_ConstrainProportionsScale: 0
|
||||||
m_Children:
|
m_Children:
|
||||||
- {fileID: 7099230484513283147}
|
- {fileID: 7099230484513283147}
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
|
|
@ -162,6 +165,9 @@ MonoBehaviour:
|
||||||
networkObject: {fileID: 3951900052977689805}
|
networkObject: {fileID: 3951900052977689805}
|
||||||
serializationRateHz: 60
|
serializationRateHz: 60
|
||||||
hybridOnChangeCompression: 1
|
hybridOnChangeCompression: 1
|
||||||
|
position: 1
|
||||||
|
rotation: 1
|
||||||
|
scale: 0
|
||||||
useLocalTransform: 0
|
useLocalTransform: 0
|
||||||
teleportDistance: 0
|
teleportDistance: 0
|
||||||
teleportAngle: 0
|
teleportAngle: 0
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using VelNet;
|
using VelNet;
|
||||||
|
|
||||||
|
namespace VelNetExample
|
||||||
|
{
|
||||||
public class CustomMessageTest : MonoBehaviour
|
public class CustomMessageTest : MonoBehaviour
|
||||||
{
|
{
|
||||||
private void Start()
|
private void Start()
|
||||||
|
|
@ -20,3 +22,4 @@ public class CustomMessageTest : MonoBehaviour
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using VelNet;
|
using VelNet;
|
||||||
|
|
||||||
|
namespace VelNetExample
|
||||||
|
{
|
||||||
public class MouseDragger : MonoBehaviour
|
public class MouseDragger : MonoBehaviour
|
||||||
{
|
{
|
||||||
private Camera cam;
|
private Camera cam;
|
||||||
|
|
@ -42,3 +44,4 @@ public class MouseDragger : MonoBehaviour
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
@ -3,8 +3,10 @@ using System.Collections.Generic;
|
||||||
using Dissonance;
|
using Dissonance;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
using VelNet;
|
||||||
|
|
||||||
namespace VelNet
|
|
||||||
|
namespace VelNetExample
|
||||||
{
|
{
|
||||||
public class NetworkGUI : MonoBehaviour
|
public class NetworkGUI : MonoBehaviour
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,10 @@ using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using VelNet;
|
||||||
using Random = UnityEngine.Random;
|
using Random = UnityEngine.Random;
|
||||||
|
|
||||||
namespace VelNet
|
namespace VelNetExample
|
||||||
{
|
{
|
||||||
public class PlayerController : NetworkSerializedObjectStream
|
public class PlayerController : NetworkSerializedObjectStream
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@ using System.IO;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using VelNet;
|
using VelNet;
|
||||||
|
|
||||||
|
namespace VelNetExample
|
||||||
|
{
|
||||||
public class RPCTest : NetworkComponent
|
public class RPCTest : NetworkComponent
|
||||||
{
|
{
|
||||||
private void Update()
|
private void Update()
|
||||||
|
|
@ -24,3 +26,4 @@ public class RPCTest : NetworkComponent
|
||||||
Debug.Log("WOW. BYTES");
|
Debug.Log("WOW. BYTES");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
@ -2,6 +2,8 @@ using System.IO;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using VelNet;
|
using VelNet;
|
||||||
|
|
||||||
|
namespace VelNetExample
|
||||||
|
{
|
||||||
public class SyncedTextbox : NetworkSerializedObjectStream
|
public class SyncedTextbox : NetworkSerializedObjectStream
|
||||||
{
|
{
|
||||||
public InputField text;
|
public InputField text;
|
||||||
|
|
@ -22,3 +24,4 @@ public class SyncedTextbox : NetworkSerializedObjectStream
|
||||||
networkObject.TakeOwnership();
|
networkObject.TakeOwnership();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using VelNet;
|
using VelNet;
|
||||||
|
|
||||||
|
namespace VelNetExample
|
||||||
|
{
|
||||||
public class VelNetMan : MonoBehaviour
|
public class VelNetMan : MonoBehaviour
|
||||||
{
|
{
|
||||||
public GameObject playerPrefab;
|
public GameObject playerPrefab;
|
||||||
|
|
@ -14,3 +16,4 @@ public class VelNetMan : MonoBehaviour
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
@ -9,12 +9,18 @@ namespace VelNet
|
||||||
[AddComponentMenu("VelNet/VelNet Sync Transform")]
|
[AddComponentMenu("VelNet/VelNet Sync Transform")]
|
||||||
public class SyncTransform : NetworkSerializedObjectStream
|
public class SyncTransform : NetworkSerializedObjectStream
|
||||||
{
|
{
|
||||||
public bool useLocalTransform;
|
[Space]
|
||||||
[Tooltip("0 to disable.")]
|
public bool position = true;
|
||||||
public float teleportDistance;
|
public bool rotation = true;
|
||||||
[Tooltip("0 to disable.")]
|
[Tooltip("Scale is always local")] public bool scale;
|
||||||
public float teleportAngle;
|
|
||||||
|
|
||||||
|
[Space]
|
||||||
|
public bool useLocalTransform;
|
||||||
|
|
||||||
|
[Tooltip("0 to disable.")] public float teleportDistance;
|
||||||
|
[Tooltip("0 to disable.")] public float teleportAngle;
|
||||||
|
|
||||||
|
private Vector3 targetScale;
|
||||||
private Vector3 targetPosition;
|
private Vector3 targetPosition;
|
||||||
private Quaternion targetRotation;
|
private Quaternion targetRotation;
|
||||||
private float distanceAtReceiveTime;
|
private float distanceAtReceiveTime;
|
||||||
|
|
@ -32,6 +38,8 @@ namespace VelNet
|
||||||
targetPosition = transform.position;
|
targetPosition = transform.position;
|
||||||
targetRotation = transform.rotation;
|
targetRotation = transform.rotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
targetScale = transform.localScale;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -39,8 +47,9 @@ namespace VelNet
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected override void SendState(BinaryWriter writer)
|
protected override void SendState(BinaryWriter writer)
|
||||||
{
|
{
|
||||||
writer.Write(transform.localPosition);
|
if (position) writer.Write(transform.localPosition);
|
||||||
writer.Write(transform.localRotation);
|
if (rotation) writer.Write(transform.localRotation);
|
||||||
|
if (scale) writer.Write(transform.localScale);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -49,8 +58,9 @@ namespace VelNet
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected override void ReceiveState(BinaryReader reader)
|
protected override void ReceiveState(BinaryReader reader)
|
||||||
{
|
{
|
||||||
targetPosition = reader.ReadVector3();
|
if (position) targetPosition = reader.ReadVector3();
|
||||||
targetRotation = reader.ReadQuaternion();
|
if (rotation) targetRotation = reader.ReadQuaternion();
|
||||||
|
if (scale) targetScale = reader.ReadVector3();
|
||||||
|
|
||||||
// record the distance from the target for interpolation
|
// record the distance from the target for interpolation
|
||||||
if (useLocalTransform)
|
if (useLocalTransform)
|
||||||
|
|
@ -61,6 +71,7 @@ namespace VelNet
|
||||||
{
|
{
|
||||||
transform.localPosition = targetPosition;
|
transform.localPosition = targetPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (teleportAngle != 0 && teleportAngle < angleAtReceiveTime)
|
if (teleportAngle != 0 && teleportAngle < angleAtReceiveTime)
|
||||||
{
|
{
|
||||||
transform.localRotation = targetRotation;
|
transform.localRotation = targetRotation;
|
||||||
|
|
@ -74,6 +85,7 @@ namespace VelNet
|
||||||
{
|
{
|
||||||
transform.position = targetPosition;
|
transform.position = targetPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (teleportAngle != 0 && teleportAngle < angleAtReceiveTime)
|
if (teleportAngle != 0 && teleportAngle < angleAtReceiveTime)
|
||||||
{
|
{
|
||||||
transform.rotation = targetRotation;
|
transform.rotation = targetRotation;
|
||||||
|
|
@ -86,25 +98,38 @@ namespace VelNet
|
||||||
if (IsMine) return;
|
if (IsMine) return;
|
||||||
|
|
||||||
if (useLocalTransform)
|
if (useLocalTransform)
|
||||||
|
{
|
||||||
|
if (position)
|
||||||
{
|
{
|
||||||
transform.localPosition = Vector3.MoveTowards(
|
transform.localPosition = Vector3.MoveTowards(
|
||||||
transform.localPosition,
|
transform.localPosition,
|
||||||
targetPosition,
|
targetPosition,
|
||||||
Time.deltaTime * distanceAtReceiveTime * serializationRateHz
|
Time.deltaTime * distanceAtReceiveTime * serializationRateHz
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rotation)
|
||||||
|
{
|
||||||
transform.localRotation = Quaternion.RotateTowards(
|
transform.localRotation = Quaternion.RotateTowards(
|
||||||
transform.localRotation,
|
transform.localRotation,
|
||||||
targetRotation,
|
targetRotation,
|
||||||
Time.deltaTime * angleAtReceiveTime * serializationRateHz
|
Time.deltaTime * angleAtReceiveTime * serializationRateHz
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
if (position)
|
||||||
{
|
{
|
||||||
transform.position = Vector3.MoveTowards(
|
transform.position = Vector3.MoveTowards(
|
||||||
transform.position,
|
transform.position,
|
||||||
targetPosition,
|
targetPosition,
|
||||||
Time.deltaTime * distanceAtReceiveTime * serializationRateHz
|
Time.deltaTime * distanceAtReceiveTime * serializationRateHz
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rotation)
|
||||||
|
{
|
||||||
transform.rotation = Quaternion.RotateTowards(
|
transform.rotation = Quaternion.RotateTowards(
|
||||||
transform.rotation,
|
transform.rotation,
|
||||||
targetRotation,
|
targetRotation,
|
||||||
|
|
@ -112,5 +137,16 @@ namespace VelNet
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (scale)
|
||||||
|
{
|
||||||
|
transform.localScale = Vector3.Lerp(
|
||||||
|
transform.localScale,
|
||||||
|
targetScale,
|
||||||
|
Time.deltaTime * serializationRateHz
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1206,7 +1206,7 @@ namespace VelNet
|
||||||
NetworkObject prefab = instance.prefabs.Find(p => p.name == prefabName);
|
NetworkObject prefab = instance.prefabs.Find(p => p.name == prefabName);
|
||||||
if (prefab == null)
|
if (prefab == null)
|
||||||
{
|
{
|
||||||
VelNetLogger.Error("Couldn't find a prefab with that name: " + prefabName);
|
VelNetLogger.Error("Couldn't find a prefab with that name: " + prefabName + "\nMake sure to add the prefab to list of prefabs in VelNetManager");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,4 +12,4 @@ MonoBehaviour:
|
||||||
m_Script: {fileID: 0}
|
m_Script: {fileID: 0}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier: Unity.Rider.Editor:Packages.Rider.Editor:RiderScriptEditorPersistedState
|
m_EditorClassIdentifier: Unity.Rider.Editor:Packages.Rider.Editor:RiderScriptEditorPersistedState
|
||||||
lastWriteTicks: -8585433455978485828
|
lastWriteTicks: -8585432596162049605
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue