Add Example_Contravariance
This commit is contained in:
parent
522393cd91
commit
7ae59bfab7
23
Assets/Example/Example_Contravariance.cs
Normal file
23
Assets/Example/Example_Contravariance.cs
Normal file
@ -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>>();
|
||||
|
||||
}
|
||||
11
Assets/Example/Example_Contravariance.cs.meta
Normal file
11
Assets/Example/Example_Contravariance.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dff76005e1dfac84287448b12c4b160e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Loading…
x
Reference in New Issue
Block a user