using Fusion; using UnityEngine; public class PlantNetworkedScript : NetworkBehaviour { [Networked] public bool PlantVisibility { get; set; } private ChangeDetector _changeDetector; public GameObject plantModel; public GameObject plantMarker; public GameObject plantStatsDialog; public GameObject plantNotesDialog; // public Material material; // private void Awake() // { // material = GetComponentInChildren().material; // } public override void Spawned() { _changeDetector = GetChangeDetector(ChangeDetector.Source.SimulationState); } public override void Render() { foreach (var change in _changeDetector.DetectChanges(this)) { Debug.Log("[Prageeth] Change detected: " + change); switch (change) { case nameof(PlantVisibility): // show the plant model to the [supervisor] if (!Object.HasStateAuthority) plantModel.SetActive(true); // show the plant stats dialogs plantStatsDialog.SetActive(true); plantStatsDialog.GetComponentInChildren().gameObject.SetActive(true); plantNotesDialog.SetActive(true); plantNotesDialog.GetComponentInChildren().gameObject.SetActive(true); break; } } } public override void FixedUpdateNetwork() { // only [plant owner] can see the plant marker if (Object.HasStateAuthority) { plantMarker.SetActive(true); } } public void ConfirmMarkerPlace() { // Planting the plant marker // [supervisor] can only see once the marker is planted if (Object.HasStateAuthority) { Debug.Log("[Prageeth] Plant visibility set to: " + PlantVisibility); PlantVisibility = true; } } }