private void OnEnable() { if (PlayerManager.GetAllPlayers() != null) { Player[] allPlayers = PlayerManager.GetAllPlayers(); GlobalDynamicBones.dynamicBones = new List <DynamicBoneSync>(allPlayers.Length); foreach (Player player in allPlayers) { DynamicBoneSync component = player.GetComponent <DynamicBoneSync>(); if (component != null) { Debug.Log("DynamicBoneSync toggle on: " + player.name); component.enabled = true; component.OnUpdateDynamics(); if (player != PlayerManager.GetCurrentPlayer()) { GlobalDynamicBones.dynamicBones.Add(component); } } else { GlobalDynamicBones.OnPlayerAdd(player); } } } }
internal static void OnPlayerDelete(DynamicBoneSync dynamic) { if (dynamic == null) { Debug.Log("DynamicBoneSync is null !!!"); return; } Player component = dynamic.GetComponent <Player>(); if (component == null) { Debug.Log("DynamicBoneSync: player is null !!!"); } if (!(component != PlayerManager.GetCurrentPlayer())) { GlobalDynamicBones.myBones = new DynamicBone[0]; GlobalDynamicBones.myColliders = new DynamicBoneCollider[0]; return; } GlobalDynamicBones.dynamicBones.Remove(dynamic); }