removed legacy avatar synchronization scripts and server implementation, transitioning to a new UDP-based system for improved performance and efficiency
This commit is contained in:
@ -8,10 +8,6 @@ using UnityEngine;
|
||||
public class UDPAvatarBroadcaster : MonoBehaviour
|
||||
{
|
||||
[Header("Network Configuration")]
|
||||
[SerializeField] private int broadcastPort = 8080;
|
||||
[SerializeField] private string broadcastAddress = "10.138.6.255"; // Local network broadcast
|
||||
[SerializeField] private bool useGlobalNetworkConfig = true;
|
||||
[SerializeField] private NetworkConfig networkConfigAsset;
|
||||
[SerializeField] private bool enableBroadcast = true;
|
||||
|
||||
[Header("Avatar Configuration")]
|
||||
@ -42,6 +38,8 @@ public class UDPAvatarBroadcaster : MonoBehaviour
|
||||
|
||||
private UdpClient udpClient;
|
||||
private IPEndPoint broadcastEndPoint;
|
||||
private string broadcastAddress;
|
||||
private int broadcastPort;
|
||||
private Dictionary<string, Transform> boneCache;
|
||||
private List<Transform> allBones; // For full data mode
|
||||
private List<SkinnedMeshRenderer> allMeshes; // For full blend shapes
|
||||
@ -51,6 +49,9 @@ public class UDPAvatarBroadcaster : MonoBehaviour
|
||||
private int currentBoneCount;
|
||||
private int currentBlendShapeCount;
|
||||
|
||||
// Magic number for packet identification
|
||||
private const uint AVATAR_MAGIC = 0xC0A0;
|
||||
|
||||
// Avatar data structure - supports both optimized and full data modes
|
||||
private struct CompactAvatarData
|
||||
{
|
||||
@ -85,16 +86,20 @@ public class UDPAvatarBroadcaster : MonoBehaviour
|
||||
|
||||
void Start()
|
||||
{
|
||||
// Apply global config if enabled
|
||||
if (useGlobalNetworkConfig)
|
||||
// Get network config from global instance
|
||||
var cfg = NetworkConfig.Instance;
|
||||
if (cfg != null)
|
||||
{
|
||||
var cfg = networkConfigAsset != null ? networkConfigAsset : NetworkConfig.Instance;
|
||||
if (cfg != null)
|
||||
{
|
||||
broadcastAddress = cfg.ipAddress;
|
||||
broadcastPort = cfg.port;
|
||||
}
|
||||
broadcastAddress = cfg.ipAddress;
|
||||
broadcastPort = cfg.port;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("NetworkConfig not found! Please ensure NetworkConfig.asset exists in Resources folder.");
|
||||
broadcastAddress = "255.255.255.255";
|
||||
broadcastPort = 1221;
|
||||
}
|
||||
|
||||
InitializeNetworking();
|
||||
CacheAvatarComponents();
|
||||
|
||||
@ -379,6 +384,9 @@ public class UDPAvatarBroadcaster : MonoBehaviour
|
||||
using (MemoryStream stream = new MemoryStream())
|
||||
using (BinaryWriter writer = new BinaryWriter(stream))
|
||||
{
|
||||
// Magic number for packet identification
|
||||
writer.Write(AVATAR_MAGIC);
|
||||
|
||||
// Header
|
||||
writer.Write(data.playerID);
|
||||
writer.Write(data.sequenceNumber);
|
||||
|
||||
Reference in New Issue
Block a user