-
-
Save ITEnot/aac78359c9c11180cfbe191eac5e0b82 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class GunsAnimSync : NetworkBehaviour | |
{ | |
public delegate void RemoteFuncDelegate(string funcName, string objName); | |
[SyncEvent] | |
public event RemoteFuncDelegate EventInvoke; | |
[SerializeField] | |
public GunsClass[] _gunsList; | |
public List<Guns> syncGuns = new List<Guns>(); | |
private void Start() | |
{ | |
if (isLocalPlayer) { | |
foreach (GunsClass gun in _gunsList) { | |
var gunStr = new Guns(gun.transform.name, gun); | |
syncGuns.Add(gunStr); | |
} | |
} | |
EventInvoke += NetworkSync_EventInvoke; | |
} | |
public struct Guns | |
{ | |
public string className; | |
public object gun; | |
public Guns(string _className, object _gun) | |
{ | |
className = _className; | |
gun = _gun; | |
} | |
} | |
public void NetworkSync_EventInvoke(string funcName, string objName) | |
{ | |
if (isLocalPlayer) | |
return; | |
var invObj = _gunsList.FirstOrDefault(t => t.name == objName); | |
invObj.Invoke(funcName, 0); | |
} | |
[Command] | |
public void CmdSendInvokeRequest(string funcName, string objName) | |
{ | |
EventInvoke(funcName, objName); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment