Add Example_Contravariance
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public interface IActor { }
|
||||
public interface IStandardActor : IActor { }
|
||||
public interface INetworkActor : IActor { }
|
||||
public interface IAction<in T> where T : IActor { }
|
||||
|
||||
public interface IActorAction : IAction<IActor> { }
|
||||
public interface IStandardActorAction : IAction<IStandardActor> { }
|
||||
public interface INetworkActorAction : IAction<INetworkActor> { }
|
||||
|
||||
[Serializable]
|
||||
public sealed class NetworkActorAction : INetworkActorAction { }
|
||||
|
||||
public class Example_Contravariance : MonoBehaviour
|
||||
{
|
||||
|
||||
[SerializeReference, SubclassSelector]
|
||||
public List<IAction<INetworkActor>> actions = new List<IAction<INetworkActor>>();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dff76005e1dfac84287448b12c4b160e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user