VerifyCanUseNetwork









How do I use Verify Can Use Network
Below are practical examples compiled from projects for learning and reference purposes

Featured Snippets


File name: PhotonNetwork.cs Copy
302     public static bool SetMasterClient(PhotonPlayer masterClientPlayer)
303     {
304         if (!VerifyCanUseNetwork() || !isMasterClient)
305         {
306             return false;
307         }
308
309         return networkingPeer.SetMasterClient(masterClientPlayer.ID, true);
310     }
File name: PhotonNetwork.cs Copy
2231     public static void SendOutgoingCommands()
2232     {
2233         if (!VerifyCanUseNetwork())
2234         {
2235             return;
2236         }
2237
2238         while (networkingPeer.SendOutgoingCommands())
2239         {
2240         }
2241     }
File name: PhotonNetwork.cs Copy
2246     public static bool CloseConnection(PhotonPlayer kickPlayer)
2247     {
2248         if (!VerifyCanUseNetwork())
2249         {
2250             return false;
2251         }
2252
2253         if (!player.isMasterClient)
2254         {
2255             Debug.LogError("CloseConnection: Only the masterclient can kick another player.");
2256             return false;
2257         }
2258
2259         if (kickPlayer == null)
2260         {
2261             Debug.LogError("CloseConnection: No such player connected!");
2262             return false;
2263         }
2264
2265         RaiseEventOptions options = new RaiseEventOptions() { TargetActors = new int[] { kickPlayer.ID } };
2266         return networkingPeer.OpRaiseEvent(PunEvent.CloseConnection, null, true, options);
2267     }
File name: PhotonNetwork.cs Copy
2366     public static void DestroyPlayerObjects(int targetPlayerId)
2367     {
2368         if (!VerifyCanUseNetwork())
2369         {
2370             return;
2371         }
2372         if (player.isMasterClient || targetPlayerId == player.ID)
2373         {
2374             networkingPeer.DestroyPlayerObjects(targetPlayerId, false);
2375         }
2376         else
2377         {
2378             Debug.LogError("DestroyPlayerObjects() failed, cause players can only destroy their own GameObjects. A Master Client can destroy anyone's. This is master: " + PhotonNetwork.isMasterClient);
2379         }
2380     }
File name: PhotonNetwork.cs Copy
2422     public static void RemoveRPCs(PhotonPlayer targetPlayer)
2423     {
2424         if (!VerifyCanUseNetwork())
2425         {
2426             return;
2427         }
2428
2429         if (!targetPlayer.isLocal && !isMasterClient)
2430         {
2431             Debug.LogError("Error; Only the MasterClient can call RemoveRPCs for other players.");
2432             return;
2433         }
2434
2435         networkingPeer.OpCleanRpcBuffer(targetPlayer.ID);
2436     }
File name: PhotonNetwork.cs Copy
2447     public static void RemoveRPCs(PhotonView targetPhotonView)
2448     {
2449         if (!VerifyCanUseNetwork())
2450         {
2451             return;
2452         }
2453
2454         networkingPeer.CleanRpcBufferIfMine(targetPhotonView);
2455     }
File name: PhotonNetwork.cs Copy
2466     public static void RemoveRPCsInGroup(int targetGroup)
2467     {
2468         if (!VerifyCanUseNetwork())
2469         {
2470             return;
2471         }
2472
2473         networkingPeer.RemoveRPCsInGroup(targetGroup);
2474     }
File name: PhotonNetwork.cs Copy
2479     internal static void RPC(PhotonView view, string methodName, PhotonTargets target, bool encrypt, params object[] parameters)
2480     {
2481         if (!VerifyCanUseNetwork())
2482         {
2483             return;
2484         }
2485
2486         if (room == null)
2487         {
2488             Debug.LogWarning("Cannot send RPCs in Lobby! RPC dropped.");
2489             return;
2490         }
2491
2492         if (networkingPeer != null)
2493         {
2494             networkingPeer.RPC(view, methodName, target, encrypt, parameters);
2495         }
2496         else
2497         {
2498             Debug.LogWarning("Could not execute RPC " + methodName + ". Possible scene loading in progress?");
2499         }
2500     }
File name: PhotonNetwork.cs Copy
2505     internal static void RPC(PhotonView view, string methodName, PhotonPlayer targetPlayer, bool encrpyt, params object[] parameters)
2506     {
2507         if (!VerifyCanUseNetwork())
2508         {
2509             return;
2510         }
2511
2512         if (room == null)
2513         {
2514             Debug.LogWarning("Cannot send RPCs in Lobby, only processed locally");
2515             return;
2516         }
2517
2518         if (player == null)
2519         {
2520             Debug.LogError("Error; Sending RPC to player null! Aborted \"" + methodName + "\"");
2521         }
2522
2523         if (networkingPeer != null)
2524         {
2525             networkingPeer.RPC(view, methodName, targetPlayer, encrpyt, parameters);
2526         }
2527         else
2528         {
2529             Debug.LogWarning("Could not execute RPC " + methodName + ". Possible scene loading in progress?");
2530         }
2531     }
File name: PhotonNetwork.cs Copy
2534     /// Enable/disable receiving on given group (applied to PhotonViews)
2538     public static void SetReceivingEnabled(int group, bool enabled)
2539     {
2540         if (!VerifyCanUseNetwork())
2541         {
2542             return;
2543         }
2544         networkingPeer.SetReceivingEnabled(group, enabled);
2545     }

VerifyCanUseNetwork 144 lượt xem

Gõ tìm kiếm nhanh...