Simulate
How do I use Simulate
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
Line | Code | Ex.. |
---|---|---|
62 | bool newSimEnabled = GUILayout.Toggle(simEnabled, "Simulate"); | 1 |
450 |
gameObject.GetComponent |
2 |
68 |
GetComponent |
3 |
File name: PhotonLagSimulationGui.cs
Copy
57 private void NetSimWindow(int windowId)
58 {
59 GUILayout.Label(string.Format("Rtt:{0,4} +/-{1,3}", this.Peer.RoundTripTime, this.Peer.RoundTripTimeVariance));
60
61 bool simEnabled = this.Peer.IsSimulationEnabled;
62 bool newSimEnabled = GUILayout.Toggle(simEnabled, "Simulate");
63 if (newSimEnabled != simEnabled)
64 {
65 this.Peer.IsSimulationEnabled = newSimEnabled;
66 }
67
68 float inOutLag = this.Peer.NetworkSimulationSettings.IncomingLag;
69 GUILayout.Label("Lag " + inOutLag);
70 inOutLag = GUILayout.HorizontalSlider(inOutLag, 0, 500);
71
72 this.Peer.NetworkSimulationSettings.IncomingLag = (int)inOutLag;
73 this.Peer.NetworkSimulationSettings.OutgoingLag = (int)inOutLag;
74
75 float inOutJitter = this.Peer.NetworkSimulationSettings.IncomingJitter;
76 GUILayout.Label("Jit " + inOutJitter);
77 inOutJitter = GUILayout.HorizontalSlider(inOutJitter, 0, 100);
78
79 this.Peer.NetworkSimulationSettings.IncomingJitter = (int)inOutJitter;
80 this.Peer.NetworkSimulationSettings.OutgoingJitter = (int)inOutJitter;
81
82 float loss = this.Peer.NetworkSimulationSettings.IncomingLossPercentage;
83 GUILayout.Label("Loss " + loss);
84 loss = GUILayout.HorizontalSlider(loss, 0, 10);
85
86 this.Peer.NetworkSimulationSettings.IncomingLossPercentage = (int)loss;
87 this.Peer.NetworkSimulationSettings.OutgoingLossPercentage = (int)loss;
88
89 // if anything was clicked, the height of this window is likely changed. reduce it to be layouted again next frame
90 if (GUI.changed)
91 {
92 this.WindowRect.height = 100;
93 }
94
95 GUI.DragWindow();
96 }
File name: Animal.cs
Copy
446 public void setRunning(bool isRunning)
447 {
448 this.isRunning = isRunning;
449 gameObject.GetComponent
450 gameObject.GetComponent
451 }
File name: Bullet.cs
Copy
64 public void setRunning(bool isRunning)
65 {
66 this.isRunning = isRunning;
67 //collider2D.enabled = isRunning;
68 GetComponent
69 }
Simulate 143 lượt xem
Gõ tìm kiếm nhanh...