private void RpcFireGoingOnStageHook() { var comps = GetComponents <IOnStageClient>(); if (comps != null) { foreach (var comp in comps) { comp.GoingOnStageClient(OnStageInfo.Default()); } } }
/// <summary> /// Spawn the item locally without syncing it over the network. Only client-side lifecycle hooks will be called. /// </summary> /// <param name="prefab">Prefab to spawn an instance of. </param> /// <param name="position">world position to appear at. Defaults to HiddenPos (hidden / invisible)</param> /// <param name="rotation">rotation to spawn with, defaults to Quaternion.identity</param> /// <param name="parent">Parent to spawn under, defaults to no parent. Most things /// should always be spawned under the Objects transform in their matrix. Many objects (due to RegisterTile) /// usually take care of properly parenting themselves when spawned so in many cases you can leave it null.</param> /// <returns>the newly created GameObject</returns> public static GameObject PoolClientInstantiate(GameObject prefab, Vector3?position = null, Transform parent = null, Quaternion?rotation = null) { if (!IsInstanceInit()) { return(null); } bool isPooled; // not used for Client-only instantiation var go = Instance.PoolInstantiate(prefab, position ?? TransformState.HiddenPos, rotation ?? Quaternion.identity, parent, out isPooled); //fire client side lifecycle hooks var hooks = go.GetComponents <IOnStageClient>(); if (hooks != null) { foreach (var hook in hooks) { hook.GoingOnStageClient(OnStageInfo.Default()); } } return(go); }
public void FireGoingOnStageHooks() { var comps = GetComponents <IOnStageServer>(); if (comps != null) { foreach (var comp in comps) { comp.GoingOnStageServer(OnStageInfo.Default()); } } var clientComps = GetComponents <IOnStageClient>(); if (clientComps != null) { foreach (var comp in clientComps) { comp.GoingOnStageClient(OnStageInfo.Default()); } } RpcFireGoingOnStageHook(); }