我一直在努力将BigInteger添加到我的MonoDevelop代码中,以支持非常大的数字,但是System.Numerics给我带来了很多麻烦。我已经添加了.dll引用,iv'e确保其他所有内容都被正确引用,但是我仍然得到这个错误:
Assets/Scripts/Click.cs(4,14): error CS0234: The type or namespace name `Numerics' does not exist in the namespace `System'. Are you missing an assembly reference?下面是我尝试使用Numerics的类:
using UnityEngine;
using System.Collections;
using System;
using System.Numerics;
public class Click : MonoBehaviour {
public UnityEngine.UI.Text PixelsDisplay;
public UnityEngine.UI.Text PPC;
public double pixels = 0.0;
public double ppc = 1.0;
void Update(){
PixelsDisplay.text = "Pixels: " + pixels.ToString ("#,#");
if (pixels >= 10000000) {
PixelsDisplay.text = "Pixels: " + Math.Round(pixels / 1000000, 2) + "M";
}
if (pixels >= 1000000000) {
PixelsDisplay.text = "Pixels: " + Math.Round(pixels / 1000000000, 2) + "B";
}
if (pixels >= 1000000000000) {
PixelsDisplay.text = "Pixels: " + Math.Round(pixels / 1000000000000, 2) + "T";
}
if (pixels >= 1000000000000000) {
PixelsDisplay.text = "Pixels: " + Math.Round(pixels / 1000000000000000, 2) + "Qd";
}
if (pixels >= 1000000000000000000) {
PixelsDisplay.text = "Pixels: " + Math.Round(pixels / 1000000000000000000, 2) + "Qt";
}
if (pixels >= BigInteger.Parse("1000000000000000000000")) {
PixelsDisplay.text = "Pixels: " + Math.Round(pixels / BigInteger.Parse("1000000000000000000000"), 2) + "Sx";
}
PPC.text = "PPC: " + ppc.ToString ("#,#");
//TODO
}
public void Clicked(){
pixels += ppc;
}
}下面这张图片展示了我所有的推荐人:

我搜索过类似的问题,但给出的答案并不直接涉及System.Numerics,而且通常也不使用MonoDevelop。谢谢你的帮助!
发布于 2015-06-30 15:24:05
System.Numerics没有在Unity使用的Mono版本中实现。
所以您不能使用该名称空间。请记住,Unity使用的Mono是自定义的,并且部分兼容.NET 2.0。
MonoDevelop或VisualStudio将允许您添加所需的动态链接库,并且不会抛出任何错误,但Unity将会。
兼容性列表here。
发布于 2016-12-08 20:52:26
你可以尝试从https://github.com/Microsoft/referencesource中复制你想要的类--它可能会转移到复制/修补越来越多的文件,或者它可能相当简单。我让Complex.cs只做了一两个改动。
https://stackoverflow.com/questions/31124758
复制相似问题