Skip to content

Commit eec6fae

Browse files
committed
fix: Fixed compilation errors in Usage Examples and applied a few minor fixes to them
1 parent bbc1af1 commit eec6fae

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

Editor/Drawers/TypeReferencePropertyDrawer.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ namespace TypeReferences.Editor.Drawers
1111
/// </summary>
1212
/// <remarks>The class is public because it is used in the Samples package.</remarks>
1313
[CustomPropertyDrawer(typeof(TypeReference))]
14-
[CustomPropertyDrawer(typeof(TypeOptionsAttribute), true)]
15-
internal class TypeReferencePropertyDrawer : PropertyDrawer
14+
public class TypeReferencePropertyDrawer : PropertyDrawer
1615
{
1716
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
1817
{

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/Editor/TypeReferenceField.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
namespace TypeReferences.Demo.Editor
22
{
3-
using System;
43
using System.Reflection;
5-
using SolidUtilities.Editor.Extensions;
4+
using SolidUtilities.UnityEditorInternals;
65
using TypeReferences.Editor.Drawers;
76
using UnityEditor;
87
using UnityEngine;
@@ -33,14 +32,14 @@ public void Draw()
3332

3433
private void SetInheritsAttributeIfFound(MemberInfo field)
3534
{
36-
var inheritsAttribute = (InheritsAttribute) Attribute.GetCustomAttribute(field, typeof(InheritsAttribute));
35+
var inheritsAttribute = field.GetCustomAttribute<InheritsAttribute>();
3736
if (inheritsAttribute != null)
3837
_fieldDrawer.SetAttribute(inheritsAttribute);
3938
}
4039

4140
private void SetTypeOptionsAttributeIfFound(MemberInfo field)
4241
{
43-
var typeOptionsAttribute = (TypeOptionsAttribute) Attribute.GetCustomAttribute(field, typeof(TypeOptionsAttribute));
42+
var typeOptionsAttribute = field.GetCustomAttribute<TypeOptionsAttribute>();
4443
if (typeOptionsAttribute != null)
4544
_fieldDrawer.SetAttribute(typeOptionsAttribute);
4645
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
namespace TypeReferences.Demo.Look_Customization
22
{
3+
using UnityEngine;
34
using Utils;
45

56
public class GroupingModes : TypeReferenceExample
@@ -15,6 +16,7 @@ public class GroupingModes : TypeReferenceExample
1516

1617
[InfoBox("Finally, types can be grouped in the same way as Unity does for its component menu. This " +
1718
"grouping method must only be used for MonoBehaviour types. Enable it with Grouping.ByAddComponentMenu.")]
18-
[TypeOptions(Grouping = Grouping.ByAddComponentMenu)] public TypeReference LikeAddComponent;
19+
[Inherits(typeof(MonoBehaviour), Grouping = Grouping.ByAddComponentMenu)]
20+
public TypeReference LikeAddComponent;
1921
}
2022
}

Samples~/Usage Examples/TypeOptions Examples/IncludeAdditionalAssemblies.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
public class IncludeAdditionalAssemblies : TypeReferenceExample
66
{
77
[InfoBox("By default, only the types the class can reference directly are included in the drop-down " +
8-
"list. In this example, CustomAssembly only has access to the TypeReferences assembly.")]
8+
"list. In this example, CustomAssembly only has access to the System and TypeReferences assemblies.")]
99
public NoAttributeStruct NoAttribute;
1010

1111
[InfoBox("But when we use [TypeOptions(IncludeAdditionalAssemblies = new []{ \"Assembly-CSharp\" })], " +

0 commit comments

Comments
 (0)