IsVisible
How do I use Is Visible
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
File name: ChatGui.cs
Copy
103 public void OnGUI()
104 {
105 if (!this.IsVisible)
106 {
107 return;
108 }
109
110 GUI.skin.label.wordWrap = true;
111 //GUI.skin.button.richText = true; // this allows toolbar buttons to have bold/colored text. nice to indicate new msgs
112 //GUILayout.Button("lala"); // as richText, html tags could be in text
113
114
115 if (Event.current.type == EventType.KeyDown && (Event.current.keyCode == KeyCode.KeypadEnter || Event.current.keyCode == KeyCode.Return))
116 {
117 if ("ChatInput".Equals(GUI.GetNameOfFocusedControl()))
118 {
119 // focus on input -> submit it
120 GuiSendsMsg();
121 return; // showing the now modified list would result in an error. to avoid this, we just skip this single frame
122 }
123 else
124 {
125 // assign focus to input
126 GUI.FocusControl("ChatInput");
127 }
128 }
129
130 GUI.SetNextControlName("");
131 GUILayout.BeginArea(this.GuiRect);
132
133 GUILayout.FlexibleSpace();
134
135 if (this.chatClient.State != ChatState.ConnectedToFrontEnd)
136 {
137 GUILayout.Label("Not in chat yet.");
138 }
139 else
140 {
141 List
142 int countOfPublicChannels = channels.Count;
143 channels.AddRange(this.chatClient.PrivateChannels.Keys);
144
145 if (channels.Count > 0)
146 {
147 int previouslySelectedChannelIndex = this.selectedChannelIndex;
148 int channelIndex = channels.IndexOf(this.selectedChannelName);
149 this.selectedChannelIndex = (channelIndex >= 0) ? channelIndex : 0;
150
151 this.selectedChannelIndex = GUILayout.Toolbar(this.selectedChannelIndex, channels.ToArray(), GUILayout.ExpandWidth(false));
152 this.scrollPos = GUILayout.BeginScrollView(this.scrollPos);
153
154 this.doingPrivateChat = (this.selectedChannelIndex >= countOfPublicChannels);
155 this.selectedChannelName = channels[this.selectedChannelIndex];
156
157 if (this.selectedChannelIndex != previouslySelectedChannelIndex)
158 {
159 // changed channel -> scroll down, if private: pre-fill "to" field with target user's name
160 this.scrollPos.y = float.MaxValue;
161 if (this.doingPrivateChat)
162 {
163 string[] pieces = this.selectedChannelName.Split(new char[] {':'}, 3);
164 this.userIdInput = pieces[1];
165 }
166 }
167
168 GUILayout.Label(ChatGui.WelcomeText);
169
170 if (this.chatClient.TryGetChannel(selectedChannelName, this.doingPrivateChat, out this.selectedChannel))
171 {
172 for (int i = 0; i < this.selectedChannel.Messages.Count; i++)
173 {
174 string sender = this.selectedChannel.Senders[i];
175 object message = this.selectedChannel.Messages[i];
176 GUILayout.Label(string.Format("{0}: {1}", sender, message));
177 }
178 }
179
180 GUILayout.EndScrollView();
181 }
182 }
183
184
185 GUILayout.BeginHorizontal();
186 if (doingPrivateChat)
187 {
188 GUILayout.Label("to:", GUILayout.ExpandWidth(false));
189 GUI.SetNextControlName("WhisperTo");
190 this.userIdInput = GUILayout.TextField(this.userIdInput, GUILayout.MinWidth(100), GUILayout.ExpandWidth(false));
191 string focussed = GUI.GetNameOfFocusedControl();
192 if (focussed.Equals("WhisperTo"))
193 {
194 if (this.userIdInput.Equals("username"))
195 {
196 this.userIdInput = "";
197 }
198 }
199 else if (string.IsNullOrEmpty(this.userIdInput))
200 {
201 this.userIdInput = "username";
202 }
203
204 }
205 GUI.SetNextControlName("ChatInput");
206 inputLine = GUILayout.TextField(inputLine);
207 if (GUILayout.Button("Send", GUILayout.ExpandWidth(false)))
208 {
209 GuiSendsMsg();
210 }
211 GUILayout.EndHorizontal();
212 GUILayout.EndArea();
213 }
File name: LoadbalancingPeer.cs
Copy
86 public virtual bool OpCreateRoom(string roomName, RoomOptions roomOptions, TypedLobby lobby, Hashtable playerProperties, bool onGameServer)
87 {
88 if (this.DebugOut >= DebugLevel.INFO)
89 {
90 this.Listener.DebugReturn(DebugLevel.INFO, "OpCreateRoom()");
91 }
92
93 Dictionary
94
95 if (!string.IsNullOrEmpty(roomName))
96 {
97 op[ParameterCode.RoomName] = roomName;
98 }
99 if (lobby != null)
100 {
101 op[ParameterCode.LobbyName] = lobby.Name;
102 op[ParameterCode.LobbyType] = (byte)lobby.Type;
103 }
104
105 if (onGameServer)
106 {
107 if (playerProperties != null && playerProperties.Count > 0)
108 {
109 op[ParameterCode.PlayerProperties] = playerProperties;
110 op[ParameterCode.Broadcast] = true; // TODO: check if this also makes sense when creating a room?! // broadcast actor properties
111 }
112
113
114 if (roomOptions == null)
115 {
116 roomOptions = new RoomOptions();
117 }
118
119 Hashtable gameProperties = new Hashtable();
120 op[ParameterCode.GameProperties] = gameProperties;
121 gameProperties.MergeStringKeys(roomOptions.customRoomProperties);
122
123 gameProperties[GameProperties.IsOpen] = roomOptions.isOpen; // TODO: check default value. dont send this then
124 gameProperties[GameProperties.IsVisible] = roomOptions.isVisible; // TODO: check default value. dont send this then
125 gameProperties[GameProperties.PropsListedInLobby] = roomOptions.customRoomPropertiesForLobby;
126 if (roomOptions.maxPlayers > 0)
127 {
128 gameProperties[GameProperties.MaxPlayers] = roomOptions.maxPlayers;
129 }
130 if (roomOptions.cleanupCacheOnLeave)
131 {
132 op[ParameterCode.CleanupCacheOnLeave] = true; // this is actually setting the room's config
133 gameProperties[GameProperties.CleanupCacheOnLeave] = true; // this is only informational for the clients which join
134 }
135 }
136
137 // UnityEngine.Debug.Log("CreateGame: " + SupportClass.DictionaryToString(op));
138 return this.OpCustom(OperationCode.CreateGame, op, true);
139 }
File name: LoadbalancingPeer.cs
Copy
143 public virtual bool OpJoinRoom(string roomName, RoomOptions roomOptions, TypedLobby lobby, bool createIfNotExists, Hashtable playerProperties, bool onGameServer)
144 {
145 Dictionary
146
147 if (!string.IsNullOrEmpty(roomName))
148 {
149 op[ParameterCode.RoomName] = roomName;
150 }
151 if (createIfNotExists)
152 {
153 op[ParameterCode.CreateIfNotExists] = true;
154 if (lobby != null)
155 {
156 op[ParameterCode.LobbyName] = lobby.Name;
157 op[ParameterCode.LobbyType] = (byte)lobby.Type;
158 }
159 }
160
161 if (onGameServer)
162 {
163 if (playerProperties != null && playerProperties.Count > 0)
164 {
165 op[ParameterCode.PlayerProperties] = playerProperties;
166 op[ParameterCode.Broadcast] = true; // broadcast actor properties
167 }
168
169
170 if (createIfNotExists)
171 {
172 if (roomOptions == null)
173 {
174 roomOptions = new RoomOptions();
175 }
176
177 Hashtable gameProperties = new Hashtable();
178 op[ParameterCode.GameProperties] = gameProperties;
179 gameProperties.MergeStringKeys(roomOptions.customRoomProperties);
180
181 gameProperties[GameProperties.IsOpen] = roomOptions.isOpen;
182 gameProperties[GameProperties.IsVisible] = roomOptions.isVisible;
183 gameProperties[GameProperties.PropsListedInLobby] = roomOptions.customRoomPropertiesForLobby;
184 if (roomOptions.maxPlayers > 0)
185 {
186 gameProperties[GameProperties.MaxPlayers] = roomOptions.maxPlayers;
187 }
188 if (roomOptions.cleanupCacheOnLeave)
189 {
190 op[ParameterCode.CleanupCacheOnLeave] = true; // this is actually setting the room's config
191 gameProperties[GameProperties.CleanupCacheOnLeave] = true; // this is only informational for the clients which join
192 }
193 }
194 }
195
196 // UnityEngine.Debug.Log("JoinGame: " + SupportClass.DictionaryToString(op));
197 return this.OpCustom(OperationCode.JoinGame, op, true);
198 }
File name: PhotonNetwork.cs
Copy
1368 public static bool CreateRoom(string roomName, bool isVisible, bool isOpen, int maxPlayers)
1369 {
1370 RoomOptions roomOptions = new RoomOptions();
1371 roomOptions.isVisible = isVisible;
1372 roomOptions.isOpen = isOpen;
1373 roomOptions.maxPlayers = maxPlayers;
1374
1375 return CreateRoom(roomName, roomOptions, null);
1376 }
File name: PhotonNetwork.cs
Copy
1399 public static bool CreateRoom(string roomName, bool isVisible, bool isOpen, int maxPlayers, Hashtable customRoomProperties, string[] propsToListInLobby)
1400 {
1401 RoomOptions roomOptions = new RoomOptions();
1402 roomOptions.isVisible = isVisible;
1403 roomOptions.isOpen = isOpen;
1404 roomOptions.maxPlayers = maxPlayers;
1405 roomOptions.customRoomProperties = customRoomProperties;
1406 roomOptions.customRoomPropertiesForLobby = propsToListInLobby;
1407
1408 return CreateRoom(roomName, roomOptions, null);
1409 }
File name: Room.cs
Copy
124 {
125 get
126 {
127 return this.visibleField;
128 }
129
130 set
131 {
132 if (!this.Equals(PhotonNetwork.room))
133 {
134 UnityEngine.Debug.LogWarning("Can't set visible when not in that room.");
135 }
136
137 if (value != this.visibleField && !PhotonNetwork.offlineMode)
138 {
139 PhotonNetwork.networkingPeer.OpSetPropertiesOfRoom(new Hashtable() { { GameProperties.IsVisible, value } }, true, (byte)0);
140 }
141
142 this.visibleField = value;
143 }
144 }
File name: Room.cs
Copy
162 internal Room(string roomName, RoomOptions options) : base(roomName, null)
163 {
164 if (options == null)
165 {
166 options = new RoomOptions();
167 }
168
169 this.visibleField = options.isVisible;
170 this.openField = options.isOpen;
171 this.maxPlayersField = (byte)options.maxPlayers;
172 this.autoCleanUpField = false; // defaults to false, unless set to true when room gets created.
173
174 this.CacheProperties(options.customRoomProperties);
175 this.propertiesListedInLobby = options.customRoomPropertiesForLobby;
176 }
File name: RoomInfo.cs
Copy
176 protected internal void CacheProperties(Hashtable propertiesToCache)
177 {
178 if (propertiesToCache == null || propertiesToCache.Count == 0 || this.customPropertiesField.Equals(propertiesToCache))
179 {
180 return;
181 }
182
183 // check of this game was removed from the list. in that case, we don't
184 // need to read any further properties
185 // list updates will remove this game from the game listing
186 if (propertiesToCache.ContainsKey(GameProperties.Removed))
187 {
188 this.removedFromList = (Boolean)propertiesToCache[GameProperties.Removed];
189 if (this.removedFromList)
190 {
191 return;
192 }
193 }
194
195 // fetch the "well known" properties of the room, if available
196 if (propertiesToCache.ContainsKey(GameProperties.MaxPlayers))
197 {
198 this.maxPlayersField = (byte)propertiesToCache[GameProperties.MaxPlayers];
199 }
200
201 if (propertiesToCache.ContainsKey(GameProperties.IsOpen))
202 {
203 this.openField = (bool)propertiesToCache[GameProperties.IsOpen];
204 }
205
206 if (propertiesToCache.ContainsKey(GameProperties.IsVisible))
207 {
208 this.visibleField = (bool)propertiesToCache[GameProperties.IsVisible];
209 }
210
211 if (propertiesToCache.ContainsKey(GameProperties.PlayerCount))
212 {
213 this.playerCount = (int)((byte)propertiesToCache[GameProperties.PlayerCount]);
214 }
215
216 if (propertiesToCache.ContainsKey(GameProperties.CleanupCacheOnLeave))
217 {
218 this.autoCleanUpField = (bool)propertiesToCache[GameProperties.CleanupCacheOnLeave];
219 }
220
221 //if (propertiesToCache.ContainsKey(GameProperties.PropsListedInLobby))
222 //{
223 // // could be cached but isn't useful
224 //}
225
226 // merge the custom properties (from your application) to the cache (only string-typed keys will be kept)
227 this.customPropertiesField.MergeStringKeys(propertiesToCache);
228 }
File name: InRoomChat.cs
Copy
25 public void OnGUI()
26 {
27 if (!this.IsVisible || PhotonNetwork.connectionStateDetailed != PeerState.Joined)
28 {
29 return;
30 }
31
32 if (Event.current.type == EventType.KeyDown && (Event.current.keyCode == KeyCode.KeypadEnter || Event.current.keyCode == KeyCode.Return))
33 {
34 if (!string.IsNullOrEmpty(this.inputLine))
35 {
36 this.photonView.RPC("Chat", PhotonTargets.All, this.inputLine);
37 this.inputLine = "";
38 GUI.FocusControl("");
39 return; // printing the now modified list would result in an error. to avoid this, we just skip this single frame
40 }
41 else
42 {
43 GUI.FocusControl("ChatInput");
44 }
45 }
46
47 GUI.SetNextControlName("");
48 GUILayout.BeginArea(this.GuiRect);
49
50 scrollPos = GUILayout.BeginScrollView(scrollPos);
51 GUILayout.FlexibleSpace();
52 for (int i = messages.Count - 1; i >= 0; i--)
53 {
54 GUILayout.Label(messages[i]);
55 }
56 GUILayout.EndScrollView();
57
58 GUILayout.BeginHorizontal();
59 GUI.SetNextControlName("ChatInput");
60 inputLine = GUILayout.TextField(inputLine);
61 if (GUILayout.Button("Send", GUILayout.ExpandWidth(false)))
62 {
63 this.photonView.RPC("Chat", PhotonTargets.All, this.inputLine);
64 this.inputLine = "";
65 GUI.FocusControl("");
66 }
67 GUILayout.EndHorizontal();
68 GUILayout.EndArea();
69 }
File name: Combo.cs
Copy
78 private void SetVisible(bool isVisibled)
79 {
80 this.isVisibled = isVisibled;
81 if (isVisibled)
82 {
83 gameObject.SetActive(true);
84 stateTime = totalTime;
85 task.transform.localScale = new Vector3(1, 1, task.transform.localScale.z);
86 fontCombo.setText(texts[comboIndex] + "x" + numberCombo + " COMBO", -2, 18, "GUI", "GUI");
87 /*
88 label.GetComponent
89 new ActionMoveTo(pl.x, pl.y + 0.1f, 0.2f, Interpolation.sine),
90 new ActionMoveTo(pl.x, pl.y, 0.2f, Interpolation.sine))));
91 * */
92 }
93 else
94 {
95 if (label.GetComponent
96 {
97 Actor[] acts = label.GetComponents
98 for (int i = 0; i < acts.Length; i++)
99 Destroy(acts[i]);
100 }
101 //numberCombo = 0;
102 gameObject.SetActive(false);
103 }
104 }
IsVisible 153 lượt xem
Gõ tìm kiếm nhanh...