I am trying to use something like this for my Hololens project
public struct FD
{
public FD(string name, IEnumerable<double> ce)
{
Name = name;
CE = new ReadOnlyCollection<double>(new List<double>(ce));
}
public readonly string Name;
public readonly IReadOnlyList<double> CE;
}
However Unity does not seem to use .NET 4.5 and therfore there is no IReadOnlyList
.
Something similar happened to me in the past with Unity not supporting some features I wanted. However once they pass out of the Unity Editor they can be compiled -or so I remember
So how about this?
public struct FD
{
public FD(string name, IEnumerable<double> ce)
{
Name = name;
CE = new ReadOnlyCollection<double>(new List<double>(ce));
}
public readonly string Name;
#if UNITY_EDITOR
public readonly IList<double> CE;
#else
public readonly IReadOnlyList<double> CE;
#endif
}
In this case when using the unity editor only a IList
is consider but once after that the IReadOnlyList
is used. What do you think about this? Or what is your approach to use IReadOnlyList
with a Hololens project?