Skip to content

Commit fb751c9

Browse files
committed
docs: Updated usage examples with project settings
1 parent 361e691 commit fb751c9

File tree

8 files changed

+67
-36
lines changed

8 files changed

+67
-36
lines changed

Samples~/Usage Examples.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Samples~/Usage Examples/Demo.unity

Lines changed: 41 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Samples~/Usage Examples/Editor/TypeReferenceExampleEditor.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ private void SaveChanges(Action drawFields)
5757

5858
private static void DrawInfoBoxIfAttributeFound(MemberInfo field)
5959
{
60-
var infoBoxAttribute = (InfoBoxAttribute) Attribute.GetCustomAttribute(field, typeof(InfoBoxAttribute));
60+
var infoBoxAttribute = field.GetCustomAttribute<InfoBoxAttribute>();
6161
if (infoBoxAttribute != null)
6262
InfoBox.Draw(infoBoxAttribute.Text);
6363
}
@@ -71,8 +71,9 @@ private void DrawButtonsIfRequested()
7171

7272
foreach (var method in methods)
7373
{
74-
// Get the ButtonAttribute on the method (if any)
75-
var ba = (ButtonAttribute) Attribute.GetCustomAttribute(method, typeof(ButtonAttribute));
74+
DrawInfoBoxIfAttributeFound(method);
75+
76+
var ba = method.GetCustomAttribute<ButtonAttribute>();
7677

7778
if (ba == null)
7879
continue;

Samples~/Usage Examples/Look Customization/Searchbar.cs

Lines changed: 0 additions & 12 deletions
This file was deleted.

Samples~/Usage Examples/Look Customization/Searchbar.cs.meta

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
namespace TypeReferences.Demo
2+
{
3+
using UnityEditor;
4+
using Utils;
5+
6+
public class ProjectSettings : TypeReferenceExample
7+
{
8+
[InfoBox("You can customize the look of the drop-down further in Project Settings. Hover over the setting label to find out what it means.")]
9+
[Button]
10+
public void GoToSettings()
11+
{
12+
#if UNITY_EDITOR
13+
SettingsService.OpenProjectSettings("Project/Type References");
14+
#endif
15+
}
16+
}
17+
}

Samples~/Usage Examples/ProjectSettings.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Samples~/Usage Examples/Utils/InfoBoxAttribute.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{
33
using System;
44

5-
[AttributeUsage(AttributeTargets.Field)]
5+
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Method)]
66
public class InfoBoxAttribute : Attribute
77
{
88
public string Text { get; }

0 commit comments

Comments
 (0)