Skip to content

Commit 5bc54d1

Browse files
committed
docs: Added AllowInternals to the usage example
1 parent cbaced4 commit 5bc54d1

File tree

5 files changed

+112
-38
lines changed

5 files changed

+112
-38
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: 73 additions & 37 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
namespace TypeReferences.Demo.TypeOptions_Examples
2+
{
3+
using System;
4+
using UnityEngine;
5+
using Utils;
6+
7+
public class AllowInternal : TypeReferenceExample
8+
{
9+
[InfoBox("AllowInternal makes internal types appear in the drop-down. By default only public types are shown.")]
10+
[Inherits(typeof(IGreetingLogger), AllowInternal = true)]
11+
public TypeReference GreetingLoggerType;
12+
13+
[Button]
14+
public void LogGreeting()
15+
{
16+
if (GreetingLoggerType.Type == null)
17+
{
18+
Debug.LogWarning("No greeting logger was specified.");
19+
}
20+
else
21+
{
22+
var greetingLogger = Activator.CreateInstance(GreetingLoggerType) as IGreetingLogger;
23+
greetingLogger.LogGreeting();
24+
}
25+
}
26+
}
27+
}

Samples~/Usage Examples/TypeOptions Examples/AllowInternal.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/GreetingLoggers.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ public void LogGreeting()
2323
}
2424
}
2525

26+
internal class InternalGreetingLogger : IGreetingLogger
27+
{
28+
public void LogGreeting()
29+
{
30+
Debug.Log("I am internal.");
31+
}
32+
}
33+
2634
public abstract class AbstractGreetingLogger : IGreetingLogger
2735
{
2836
public abstract void LogGreeting();

0 commit comments

Comments
 (0)