GUIContent
How do I use G U I Content
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
File name: PhotonRigidbody2DViewEditor.cs
Copy
7 public override void OnInspectorGUI()
8 {
9 PhotonGUI.ContainerHeader("Options");
10
11 Rect containerRect = PhotonGUI.ContainerBody(EditorGUIUtility.singleLineHeight*2 + 10);
12
13 Rect propertyRect = new Rect(containerRect.xMin + 5, containerRect.yMin + 5, containerRect.width, EditorGUIUtility.singleLineHeight);
14 EditorGUI.PropertyField(propertyRect, serializedObject.FindProperty("m_SynchronizeVelocity"), new GUIContent("Synchronize Velocity"));
15
16 propertyRect.y += EditorGUIUtility.singleLineHeight;
17 EditorGUI.PropertyField(propertyRect, serializedObject.FindProperty("m_SynchronizeAngularVelocity"), new GUIContent("Synchronize Angular Velocity"));
18 }
File name: PhotonRigidbodyViewEditor.cs
Copy
7 public override void OnInspectorGUI()
8 {
9 PhotonGUI.ContainerHeader("Options");
10
11 Rect containerRect = PhotonGUI.ContainerBody(EditorGUIUtility.singleLineHeight*2 + 10);
12
13 Rect propertyRect = new Rect(containerRect.xMin + 5, containerRect.yMin + 5, containerRect.width, EditorGUIUtility.singleLineHeight);
14 EditorGUI.PropertyField(propertyRect, serializedObject.FindProperty("m_SynchronizeVelocity"), new GUIContent("Synchronize Velocity"));
15
16 propertyRect.y += EditorGUIUtility.singleLineHeight;
17 EditorGUI.PropertyField(propertyRect, serializedObject.FindProperty("m_SynchronizeAngularVelocity"), new GUIContent("Synchronize Angular Velocity"));
18 }
File name: PhotonTransformViewEditor.cs
Copy
163 private float GetInterpolateHelpBoxHeight()
164 {
165 return PhotonGUI.RichLabel.CalcHeight(new GUIContent(INTERPOLATE_HELP), Screen.width - 54) + 35;
166 }
File name: PhotonTransformViewEditor.cs
Copy
168 private float GetExtrapolateHelpBoxHeight()
169 {
170 return PhotonGUI.RichLabel.CalcHeight(new GUIContent(EXTRAPOLATE_HELP), Screen.width - 54) + 35;
171 }
File name: PhotonTransformViewEditor.cs
Copy
181 private void DrawSynchronizePositionDataGizmos(ref Rect propertyRect)
182 {
183 GUI.enabled = true;
184 /*PhotonGUI.DrawGizmoOptions(propertyRect, "Synchronized Position Gizmo",
185 serializedObject.FindProperty("m_PositionModel.DrawNetworkGizmo"),
186 serializedObject.FindProperty("m_PositionModel.NetworkGizmoColor"),
187 serializedObject.FindProperty("m_PositionModel.NetworkGizmoType"),
188 serializedObject.FindProperty("m_PositionModel.NetworkGizmoSize"));
189 propertyRect.y += EDITOR_LINE_HEIGHT;
190
191 PhotonGUI.DrawGizmoOptions(propertyRect, "Extrapolated Position Gizmo",
192 serializedObject.FindProperty("m_PositionModel.DrawExtrapolatedGizmo"),
193 serializedObject.FindProperty("m_PositionModel.ExtrapolatedGizmoColor"),
194 serializedObject.FindProperty("m_PositionModel.ExtrapolatedGizmoType"),
195 serializedObject.FindProperty("m_PositionModel.ExtrapolatedGizmoSize"));
196 propertyRect.y += EDITOR_LINE_HEIGHT;*/
197
198 EditorGUI.PropertyField(propertyRect, serializedObject.FindProperty("m_PositionModel.DrawErrorGizmo"),
199 new GUIContent("Draw synchronized position error"));
200 propertyRect.y += EDITOR_LINE_HEIGHT;
201 }
File name: PhotonTransformViewEditor.cs
Copy
220 private void DrawPropertyWithHelpIcon(ref Rect propertyRect, ref bool isHelpOpen, SerializedProperty property, string tooltip)
221 {
222 Rect propertyFieldRect = new Rect(propertyRect.xMin, propertyRect.yMin, propertyRect.width - 20, propertyRect.height);
223 string propertyName = ObjectNames.NicifyVariableName(property.name);
224 EditorGUI.PropertyField(propertyFieldRect, property, new GUIContent(propertyName, tooltip));
225
226 Rect helpIconRect = new Rect(propertyFieldRect.xMax + 5, propertyFieldRect.yMin, 20, propertyFieldRect.height);
227 isHelpOpen = GUI.Toggle(helpIconRect, isHelpOpen, PhotonGUI.HelpIcon, GUIStyle.none);
228
229 propertyRect.y += EDITOR_LINE_HEIGHT;
230 }
File name: PhotonTransformViewEditor.cs
Copy
252 private void DrawTeleport(ref Rect propertyRect)
253 {
254 EditorGUI.PropertyField(propertyRect, serializedObject.FindProperty("m_PositionModel.TeleportEnabled"),
255 new GUIContent("Enable teleport for great distances"));
256 propertyRect.y += EDITOR_LINE_HEIGHT;
257
258 EditorGUI.PropertyField(propertyRect, serializedObject.FindProperty("m_PositionModel.TeleportIfDistanceGreaterThan"),
259 new GUIContent("Teleport if distance greater than"));
260 propertyRect.y += EDITOR_LINE_HEIGHT;
261 }
File name: PhotonTransformViewEditor.cs
Copy
264 PhotonTransformViewPositionModel.InterpolateOptions interpolateOption)
265 {
266 DrawPropertyWithHelpIcon(ref propertyRect, ref this.m_InterpolateHelpOpen, interpolatePositionProperty, INTERPOLATE_TOOLTIP);
267 DrawHelpBox(ref propertyRect, this.m_InterpolateHelpOpen, GetInterpolateHelpBoxHeight(), INTERPOLATE_HELP, INTERPOLATE_HELP_URL);
268
269 switch (interpolateOption)
270 {
271 case PhotonTransformViewPositionModel.InterpolateOptions.FixedSpeed:
272 EditorGUI.PropertyField(propertyRect, serializedObject.FindProperty("m_PositionModel.InterpolateMoveTowardsSpeed"),
273 new GUIContent("MoveTowards Speed"));
274 propertyRect.y += EDITOR_LINE_HEIGHT;
275 break;
276
277 case PhotonTransformViewPositionModel.InterpolateOptions.Lerp:
278 EditorGUI.PropertyField(propertyRect, serializedObject.FindProperty("m_PositionModel.InterpolateLerpSpeed"), new GUIContent("Lerp Speed"));
279 propertyRect.y += EDITOR_LINE_HEIGHT;
280 break;
281
282 /*case PhotonTransformViewPositionModel.InterpolateOptions.MoveTowardsComplex:
283 Rect curveRect = new Rect(propertyRect.xMin, propertyRect.yMin, propertyRect.width - 100, propertyRect.height);
284 EditorGUI.PropertyField(curveRect, serializedObject.FindProperty("m_PositionModel.InterpolateSpeedCurve"), new GUIContent("MoveTowards Speed Curve"));
285
286 Rect labelRect = new Rect(propertyRect.xMax - 95, propertyRect.yMin, 10, propertyRect.height);
287 GUI.Label(labelRect, "x");
288
289 Rect multiplierRect = new Rect(propertyRect.xMax - 80, propertyRect.yMin, 80, propertyRect.height);
290 EditorGUI.PropertyField(multiplierRect, serializedObject.FindProperty("m_PositionModel.InterpolateMoveTowardsSpeed"), GUIContent.none);
291 propertyRect.y += EDITOR_LINE_HEIGHT;
292
293 EditorGUI.PropertyField(propertyRect, serializedObject.FindProperty("m_PositionModel.InterpolateMoveTowardsAcceleration"),
294 new GUIContent("Acceleration"));
295 propertyRect.y += EDITOR_LINE_HEIGHT;
296
297 EditorGUI.PropertyField(propertyRect, serializedObject.FindProperty("m_PositionModel.InterpolateMoveTowardsDeceleration"),
298 new GUIContent("Deceleration"));
299 propertyRect.y += EDITOR_LINE_HEIGHT;
300 break;*/
301 }
302 }
File name: PhotonTransformViewEditor.cs
Copy
309 private void DrawSynchronizeRotationData()
310 {
311 if (this.m_SynchronizeRotationProperty == null || this.m_SynchronizeRotationProperty.boolValue == false)
312 {
313 return;
314 }
315
316 SerializedProperty interpolateRotationProperty = serializedObject.FindProperty("m_RotationModel.InterpolateOption");
317 PhotonTransformViewRotationModel.InterpolateOptions interpolateOption =
318 (PhotonTransformViewRotationModel.InterpolateOptions) interpolateRotationProperty.enumValueIndex;
319
320 float containerHeight = 20;
321
322 switch (interpolateOption)
323 {
324 case PhotonTransformViewRotationModel.InterpolateOptions.RotateTowards:
325 case PhotonTransformViewRotationModel.InterpolateOptions.Lerp:
326 containerHeight += EDITOR_LINE_HEIGHT;
327 break;
328 }
329
330 if (this.m_InterpolateRotationHelpOpen == true)
331 {
332 containerHeight += GetInterpolateHelpBoxHeight();
333 }
334
335 Rect rect = PhotonGUI.ContainerBody(containerHeight);
336 Rect propertyRect = new Rect(rect.xMin + 5, rect.yMin + 2, rect.width - 10, EditorGUIUtility.singleLineHeight);
337
338 DrawPropertyWithHelpIcon(ref propertyRect, ref this.m_InterpolateRotationHelpOpen, interpolateRotationProperty, INTERPOLATE_TOOLTIP);
339 DrawHelpBox(ref propertyRect, this.m_InterpolateRotationHelpOpen, GetInterpolateHelpBoxHeight(), INTERPOLATE_HELP, INTERPOLATE_HELP_URL);
340
341 switch (interpolateOption)
342 {
343 case PhotonTransformViewRotationModel.InterpolateOptions.RotateTowards:
344 EditorGUI.PropertyField(propertyRect, serializedObject.FindProperty("m_RotationModel.InterpolateRotateTowardsSpeed"),
345 new GUIContent("RotateTowards Speed"));
346 break;
347 case PhotonTransformViewRotationModel.InterpolateOptions.Lerp:
348 EditorGUI.PropertyField(propertyRect, serializedObject.FindProperty("m_RotationModel.InterpolateLerpSpeed"), new GUIContent("Lerp Speed"));
349 break;
350 }
351 }
File name: PhotonTransformViewEditor.cs
Copy
358 private void DrawSynchronizeScaleData()
359 {
360 if (this.m_SynchronizeScaleProperty == null || this.m_SynchronizeScaleProperty.boolValue == false)
361 {
362 return;
363 }
364
365 SerializedProperty interpolateScaleProperty = serializedObject.FindProperty("m_ScaleModel.InterpolateOption");
366 PhotonTransformViewScaleModel.InterpolateOptions interpolateOption = (PhotonTransformViewScaleModel.InterpolateOptions) interpolateScaleProperty.enumValueIndex;
367
368 float containerHeight = EDITOR_LINE_HEIGHT;
369
370 switch (interpolateOption)
371 {
372 case PhotonTransformViewScaleModel.InterpolateOptions.MoveTowards:
373 case PhotonTransformViewScaleModel.InterpolateOptions.Lerp:
374 containerHeight += EDITOR_LINE_HEIGHT;
375 break;
376 }
377
378 if (this.m_InterpolateScaleHelpOpen == true)
379 {
380 containerHeight += GetInterpolateHelpBoxHeight();
381 }
382
383 Rect rect = PhotonGUI.ContainerBody(containerHeight);
384 Rect propertyRect = new Rect(rect.xMin + 5, rect.yMin + 2, rect.width - 10, EditorGUIUtility.singleLineHeight);
385
386 DrawPropertyWithHelpIcon(ref propertyRect, ref this.m_InterpolateScaleHelpOpen, interpolateScaleProperty, INTERPOLATE_TOOLTIP);
387 DrawHelpBox(ref propertyRect, this.m_InterpolateScaleHelpOpen, GetInterpolateHelpBoxHeight(), INTERPOLATE_HELP, INTERPOLATE_HELP_URL);
388
389 switch (interpolateOption)
390 {
391 case PhotonTransformViewScaleModel.InterpolateOptions.MoveTowards:
392 EditorGUI.PropertyField(propertyRect, serializedObject.FindProperty("m_ScaleModel.InterpolateMoveTowardsSpeed"),
393 new GUIContent("MoveTowards Speed"));
394 break;
395 case PhotonTransformViewScaleModel.InterpolateOptions.Lerp:
396 EditorGUI.PropertyField(propertyRect, serializedObject.FindProperty("m_ScaleModel.InterpolateLerpSpeed"), new GUIContent("Lerp Speed"));
397 break;
398 }
399 }
GUIContent 132 lượt xem
Gõ tìm kiếm nhanh...