DrawHelpBox
How do I use Draw Help Box
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
File name: PhotonTransformViewEditor.cs
Copy
203 private void DrawHelpBox(ref Rect propertyRect, bool isOpen, float height, string helpText, string url)
204 {
205 if (isOpen == true)
206 {
207 Rect helpRect = new Rect(propertyRect.xMin, propertyRect.yMin, propertyRect.width, height - 5);
208 GUI.BeginGroup(helpRect, GUI.skin.box);
209 GUI.Label(new Rect(5, 5, propertyRect.width - 10, height - 30), helpText, PhotonGUI.RichLabel);
210 if (GUI.Button(new Rect(5, height - 30, propertyRect.width - 10, 20), "Read more in our documentation"))
211 {
212 Application.OpenURL(url);
213 }
214 GUI.EndGroup();
215
216 propertyRect.y += height;
217 }
218 }
File name: PhotonTransformViewEditor.cs
Copy
232 private void DrawSynchronizePositionDataExtrapolation(ref Rect propertyRect, SerializedProperty extrapolatePositionProperty, PhotonTransformViewPositionModel.ExtrapolateOptions extrapolateOption)
233 {
234 DrawPropertyWithHelpIcon(ref propertyRect, ref this.m_ExtrapolateHelpOpen, extrapolatePositionProperty, EXTRAPOLATE_TOOLTIP);
235 DrawHelpBox(ref propertyRect, this.m_ExtrapolateHelpOpen, GetExtrapolateHelpBoxHeight(), EXTRAPOLATE_HELP, EXTRAPOLATE_HELP_URL);
236
237 if (extrapolateOption != PhotonTransformViewPositionModel.ExtrapolateOptions.Disabled)
238 {
239 EditorGUI.PropertyField(propertyRect, serializedObject.FindProperty("m_PositionModel.ExtrapolateIncludingRoundTripTime"));
240 propertyRect.y += EDITOR_LINE_HEIGHT;
241 }
242
243 switch (extrapolateOption)
244 {
245 case PhotonTransformViewPositionModel.ExtrapolateOptions.FixedSpeed:
246 EditorGUI.PropertyField(propertyRect, serializedObject.FindProperty("m_PositionModel.ExtrapolateSpeed"));
247 propertyRect.y += EDITOR_LINE_HEIGHT;
248 break;
249 }
250 }
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 }
DrawHelpBox 112 lượt xem
Gõ tìm kiếm nhanh...