WindowRect









How do I use Window Rect
Below are practical examples compiled from projects for learning and reference purposes

Featured Snippets


File name: PhotonLagSimulationGui.cs Copy
35     public void OnGUI()
36     {
37         if (!this.Visible)
38         {
39             return;
40         }
41
42         if (this.Peer == null)
43         {
44             this.WindowRect = GUILayout.Window(this.WindowId, this.WindowRect, this.NetSimHasNoPeerWindow, "Netw. Sim.");
45         }
46         else
47         {
48             this.WindowRect = GUILayout.Window(this.WindowId, this.WindowRect, this.NetSimWindow, "Netw. Sim.");
49         }
50     }
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     }

WindowRect 155 lượt xem

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