AderKonstantin a9c05d570c many bullshit updates
models:
1) BuilderBlockout
2) TrooperModel
UI
3) ArmorBar
4) Healthbar
5) Fonts (RobotoMono)
6) Icons
7) Build Profiles
8) Tags for Camera
2024-12-09 13:54:52 +03:00

47 lines
1.1 KiB
C#

using System;
using Unity.Netcode;
using UnityEngine;
public class PlayerModel : NetworkBehaviour
{
public override void OnNetworkSpawn()
{
base.OnNetworkSpawn();
// Исключаем слой ModelLocal из рендеринга для mainCamera
if (IsLocalPlayer)
{
SetLayerRecursively(gameObject, LayerMask.NameToLayer("ModelLocal"));
}
else
{
SetLayerRecursively(gameObject, LayerMask.NameToLayer("ModelRemote"));
}
Debug.Log($"NetworkObject ID: {NetworkObjectId} RobotModel's LayerMask: " + gameObject.layer);
}
public override void OnNetworkDespawn()
{
base.OnNetworkDespawn();
}
void SetLayerRecursively(GameObject obj, int newLayer)
{
if (obj == null)
{
return;
}
obj.layer = newLayer;
foreach (Transform child in obj.transform)
{
if (child == null)
{
continue;
}
SetLayerRecursively(child.gameObject, newLayer);
}
}
}