Skip to content

Commit 7ae59bf

Browse files
committed
Add Example_Contravariance
1 parent 522393c commit 7ae59bf

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
5+
public interface IActor { }
6+
public interface IStandardActor : IActor { }
7+
public interface INetworkActor : IActor { }
8+
public interface IAction<in T> where T : IActor { }
9+
10+
public interface IActorAction : IAction<IActor> { }
11+
public interface IStandardActorAction : IAction<IStandardActor> { }
12+
public interface INetworkActorAction : IAction<INetworkActor> { }
13+
14+
[Serializable]
15+
public sealed class NetworkActorAction : INetworkActorAction { }
16+
17+
public class Example_Contravariance : MonoBehaviour
18+
{
19+
20+
[SerializeReference, SubclassSelector]
21+
public List<IAction<INetworkActor>> actions = new List<IAction<INetworkActor>>();
22+
23+
}

Assets/Example/Example_Contravariance.cs.meta

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

0 commit comments

Comments
 (0)