> For AI agents: the complete documentation index is available at /infinity-value/zh/llms.txt, the full documentation bundle is available at /infinity-value/zh/llms-full.txt.

# 快速开始

## 安装

通过 Unity Package Manager 添加包：

```text
https://github.com/achieveonepark/infinity-value.git
```

或直接添加到 `Packages/manifest.json`：

```json
{
  "dependencies": {
    "com.achieve.infinity-value": "https://github.com/achieveonepark/infinity-value.git"
  }
}
```

## 创建值

```csharp
using Achieve.InfinityValue;

InfinityValue a = 1000;
InfinityValue b = new InfinityValue(1_500_000L);
InfinityValue c = new InfinityValue(1.5e12);
InfinityValue d = new InfinityValue("300B 200A");
```

## 使用按内容定制的单位名称

当不同系统需要不同后缀时，使用 `InfinityValueUnitNames`。

```csharp
var currencyUnits = new InfinityValueUnitNames(new[]
{
    "", "K", "M", "B", "T", "Qa", "Qi"
});

var damageUnits = new InfinityValueUnitNames(new[]
{
    "", "a", "b", "c", "d", "e", "f"
});

InfinityValue gold = new InfinityValue("12K", currencyUnits);
InfinityValue damage = new InfinityValue("12a", damageUnits);
```

每个 `InfinityValue` 内部持有传入的单位名称实例。算术运算保留左操作数的单位名称：

```csharp
InfinityValue totalGold = gold + new InfinityValue(5000, currencyUnits);
Debug.Log(totalGold); // 17.00K
```

## 安全解析

```csharp
if (!InfinityValue.TryParse("5B", currencyUnits, out var parsed))
    parsed = InfinityValue.Zero.WithUnitNames(currencyUnits);
```

## 保存与加载

最简单的持久化方式是保存显示字符串，加载时使用相同的单位名称集：

```csharp
PlayerPrefs.SetString("gold", gold.ToString());

string raw = PlayerPrefs.GetString("gold", "0");
InfinityValue.TryParse(raw, currencyUnits, out gold);
```
