I’m getting this exception in Build
Internal compiler error. See the console log for more information. output was:Stacktrace:
at (wrapper managed-to-native) System.Type.MakeGenericType (System.Type,System.Type[]) <0x00004>
at (wrapper managed-to-native) System.Type.MakeGenericType (System.Type,System.Type[]) <0x00004>
at System.Type.MakeGenericType (System.Type[]) <0x00144>
Any wisdom on common causes would be really helpful.
Addl: The problem is likely in this class somewhere. I had to bend over backwards to make Unity like it in th editor thanks to Unity mono not supporting dynamic…
public struct Vector2<T> where T: struct {
internal double x;
internal double y;
public Vector2(T x, T y):this(){
X = x;
Y = y;
}
private static T ConvertFrom(double v){
return (T)Convert.ChangeType (v,typeof(T));
}
private static double ConvertTo(T v){
return (double)Convert.ChangeType(v,typeof(double));
}
public T X {
get {return ConvertFrom(x);}
set {x=ConvertTo(value);}
}
public T Y {
get {return ConvertFrom(y);}
set {y=ConvertTo(value);}
}
public static Vector2<T> operator +(Vector2<T> lhs, Vector2<T> rhs)
{
return new Vector2<T>(ConvertFrom(lhs.x+rhs.x),
ConvertFrom(lhs.y+rhs.y));
}
public static Vector2<T> operator -(Vector2<T> lhs, Vector2<T> rhs)
{
return new Vector2<T>(ConvertFrom(lhs.x-rhs.x),
ConvertFrom(lhs.y-rhs.y));
}
public static Vector2<T> operator *(Vector2<T> lhs, T scaler)
{
return new Vector2<T>(ConvertFrom(lhs.x*ConvertTo(scaler)),
ConvertFrom(lhs.y*ConvertTo(scaler)));
}
public static Vector2<T> operator /(Vector2<T> lhs, T scaler)
{
return new Vector2<T>(ConvertFrom(lhs.x/ConvertTo(scaler)),
ConvertFrom(lhs.y/ConvertTo(scaler)));
}
/// <summary>>
/// Dot product
/// </summary>
/// <param name="lhs">Lhs.</param>
/// <param name="rhs">Rhs.</param>
public T Dot(Vector2<T> rhs){
return ConvertFrom((x * rhs.x) + (y * rhs.y));
}
public Vector2<T> Rotate(float deg){
float rad = (float)(deg * System.Math.PI / 180);
float s = (float)System.Math.Sin(rad);
float c = (float)System.Math.Cos(rad);
return new Vector2<T>(ConvertFrom((x * c) - (y * s)),
ConvertFrom((x * s) + (y * c)));
}
public override string ToString ()
{
return string.Format ("[Vector2("+X+","+Y+")]");
}
public static implicit operator Vector2<T>(Vector3<T> someValue)
{
return new Vector2<T>(someValue.X,someValue.Y);
}
}
public struct Vector3<T> where T: struct {
double x;
double y;
double z;
public Vector3(T x, T y, T z):this(){
X = x;
Y = y;
Z = z;
}
private static T ConvertFrom(double v){
return (T)Convert.ChangeType(v,typeof(T));
}
private static double ConvertTo(T v){
return (double)Convert.ChangeType(v,typeof(double));
}
public T X {
get {return ConvertFrom(x);}
set {x=ConvertTo(value);}
}
public T Y {
get {return ConvertFrom(y);}
set {y=ConvertTo(value);}
}
public T Z {
get {return ConvertFrom(z);}
set {z=ConvertTo(value);}
}
public static Vector3<T> operator +(Vector3<T> lhs, Vector3<T> rhs)
{
return new Vector3<T>(ConvertFrom(lhs.x+rhs.x),
ConvertFrom(lhs.y+rhs.y),
ConvertFrom(lhs.z+rhs.z));
}
public static Vector3<T> operator -(Vector3<T> lhs, Vector3<T> rhs)
{
return new Vector3<T>(ConvertFrom(lhs.x-rhs.x),
ConvertFrom(lhs.y-rhs.y),
ConvertFrom(lhs.z-rhs.z));
}
public static Vector3<T> operator *(Vector3<T> lhs, T scaler)
{
return new Vector3<T>(ConvertFrom(lhs.x*ConvertTo(scaler)),
ConvertFrom(lhs.y*ConvertTo(scaler)),
ConvertFrom(lhs.z*ConvertTo(scaler)));
}
public static Vector3<T> operator /(Vector3<T> lhs, T scaler)
{
return new Vector3<T>(ConvertFrom(lhs.x/ConvertTo(scaler)),
ConvertFrom(lhs.y/ConvertTo(scaler)),
ConvertFrom(lhs.z/ConvertTo(scaler)));
}
///<summary>
/// The cross product
/// cx = aybz - azby
/// cy = azbx - axbz
/// cz = axby - aybx
/// </summary>
/// <param name="lhs">Lhs.</param>
/// <param name="rhs">Rhs.</param>
public static Vector3<T> operator *(Vector3<T> lhs, Vector3<T> rhs)
{
T cx = ConvertFrom((lhs.y * rhs.z) - (lhs.z * rhs.y));
T cy = ConvertFrom((lhs.z * rhs.x) - (lhs.x * rhs.z));
T cz = ConvertFrom((lhs.x * rhs.y) - (lhs.y * rhs.x));
return new Vector3<T> (cx, cy, cz);
}
/// <summary>>
/// Dot product
/// </summary>
/// <param name="lhs">Lhs.</param>
/// <param name="rhs">Rhs.</param>
public T Dot(Vector3<T> rhs){
return ConvertFrom((x * rhs.x) + (y * rhs.y)+ (z * rhs.z));
}
public override string ToString ()
{
return string.Format ("[Vector3("+X+","+Y+","+Z+")]");
}
public static implicit operator Vector3<T>(Vector2<T> someValue)
{
return new Vector3<T>(someValue.X,someValue.Y,default(T));
}
}