mirror of
https://github.com/Kaveinator/NetickProForUnity.git
synced 2025-10-26 09:49:06 -07:00
auto
This commit is contained in:
25
Samples~/Bomberman/Scripts/Block.cs
Normal file
25
Samples~/Bomberman/Scripts/Block.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using UnityEngine;
|
||||
using Netick;
|
||||
using Netick.Unity;
|
||||
|
||||
namespace Netick.Samples.Bomberman
|
||||
{
|
||||
public class Block : NetworkBehaviour
|
||||
{
|
||||
// Networked properties
|
||||
[Networked]
|
||||
public bool Visible { get; set; } = true;
|
||||
|
||||
[OnChanged(nameof(Visible))]
|
||||
private void OnVisibleChanged(OnChangedData onChangedData)
|
||||
{
|
||||
// for visual components, don't use "enabled" property when you want to disable/enable it, instead use SetEnabled().
|
||||
// -- GetComponent<Renderer>().enabled = Visible; #### Not like this.
|
||||
|
||||
GetComponent<Renderer>().SetEnabled(Sandbox, Visible); // #### Like this.
|
||||
|
||||
GetComponent<BoxCollider>().enabled = Visible;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user