Я хочу обновить полосу работоспособности на сервере и клиентах, потому что значение работоспособности обновляется на сервере, но не панель. Все перепробовал, но исправить не удалось.
ОШИБКА:
AlRecibirDaño should have signature:
public void AlRecibirDaño(System.Int32 oldValue, System.Int32 newValue) { }
(at System.Void Health::AlRecibirDaño(System.Int32)) UnityEngine.Debug:LogError(Object) Mirror.Weaver.CompilationFinishedHook:HandleError(String)
(at Assets/Mirror/Editor/Weaver/CompilationFinishedHook.cs:43) Mirror.Weaver.Log:Error(String) (at Assets/Mirror/Editor/Weaver/Program.cs:19) Mirror.Weaver.Weaver:Error(String, MemberReference)
(at Assets/Mirror/Editor/Weaver/Weaver.cs:155) Mirror.Weaver.SyncVarProcessor:GetHookMethod(TypeDefinition, FieldDefinition, String)
(at Assets/Mirror/Editor/Weaver/Processors/SyncVarProcessor.cs:44) Mirror.Weaver.SyncVarProcessor:GetHookMethod(TypeDefinition, FieldDefinition)
(at Assets/Mirror/Editor/Weaver/Processors/SyncVarProcessor.cs:26) Mirror.Weaver.SyncVarProcessor:ProcessSyncVarSet(TypeDefinition, FieldDefinition, String, Int64, FieldDefinition)
(at Assets/Mirror/Editor/Weaver/Processors/SyncVarProcessor.cs:199) Mirror.Weaver.SyncVarProcessor:ProcessSyncVar(TypeDefinition, FieldDefinition, Dictionary`2, Int64)
(at Assets/Mirror/Editor/Weaver/Processors/SyncVarProcessor.cs:265) Mirror.Weaver.SyncVarProcessor:ProcessSyncVars(TypeDefinition, List`1, List`1, Dictionary`2) (at Assets/Mirror/Editor/Weaver/Processors/SyncVarProcessor.cs:327) Mirror.Weaver.NetworkBehaviourProcessor:Process()
(at Assets/Mirror/Editor/Weaver/Processors/NetworkBehaviourProcessor.cs:40) Mirror.Weaver.Weaver:ProcessNetworkBehaviourType(TypeDefinition)
(at Assets/Mirror/Editor/Weaver/Weaver.cs:201) Mirror.Weaver.Weaver:WeaveNetworkBehavior(TypeDefinition)
(at Assets/Mirror/Editor/Weaver/Weaver.cs:391) Mirror.Weaver.Weaver:WeaveModule(ModuleDefinition)
(at Assets/Mirror/Editor/Weaver/Weaver.cs:552) Mirror.Weaver.Weaver:Weave(String, IEnumerable`1, String, String, String)
(at Assets/Mirror/Editor/Weaver/Weaver.cs:488) Mirror.Weaver.Weaver:WeaveAssemblies(IEnumerable`1, IEnumerable`1, String, String, String)
(at Assets/Mirror/Editor/Weaver/Weaver.cs:582) Mirror.Weaver.Program:Process(String, String, String, String[], String[], Action`1, Action`1)
(at Assets/Mirror/Editor/Weaver/Program.cs:33) Mirror.Weaver.CompilationFinishedHook:OnCompilationFinished(String, CompilerMessage[])
(at Assets/Mirror/Editor/Weaver/CompilationFinishedHook.cs:147) UnityEditor.EditorApplication:Internal_CallGlobalEventHandler()
КОД:
using UnityEngine; using Mirror;
public class Health : NetworkBehaviour {
public RectTransform BarraVida;
public const int VidaMax = 100;
[SyncVar (hook = "AlRecibirDaño")] public int VidaActual = VidaMax;
public void RecibirDaño(int Daño)
{
if (!isServer)
{
return;
}
VidaActual -= Daño;
if (VidaActual <= 0)
{
VidaActual = 0;
Debug.Log("Muerto");
}
}
public void AlRecibirDaño(int vida)
{
BarraVida.sizeDelta = new Vector2(vida * 2, BarraVida.sizeDelta.y);
}
}