-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
946b4cd
commit 48e0698
Showing
16 changed files
with
113 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
`Archive` 提供一个便捷的、基于字典的存档系统,使用相当简便的代码即可实现读写操作。 | ||
|
||
|
||
## 快速上手 | ||
## 快速使用 | ||
|
||
以下示例演示了如何使用 `Archive` 进行读写操作: | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ | |
::: | ||
|
||
|
||
## 快速上手 | ||
## 快速使用 | ||
|
||
以下示例演示了如何使用 `Tween` 实现淡出效果: | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
`IntRange` 表示一个整数范围。它可以方便地在 `Inspector` 中编辑,并用代码进行操作。 | ||
|
||
|
||
## 快速入门 | ||
## 快速使用 | ||
|
||
以下示例演示了 `IntRange` 的使用方法: | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
`FloatRange` 表示一个浮点数范围。它可以方便地在 `Inspector` 中编辑,并用代码进行操作。 | ||
|
||
|
||
## 快速入门 | ||
## 快速使用 | ||
|
||
以下示例演示了 `FloatRange` 的使用方法: | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
`Rectangle` 提供了在**场景**中选定矩形范围,并用代码进行交互的功能。 | ||
|
||
|
||
## 快速入门 | ||
## 快速使用 | ||
|
||
下方示例演示了 `Rectangle` 的基本使用方法: | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ | |
这有点类似于 `ParticleSystem` 中,可以调整模式的数值。 | ||
|
||
|
||
## 快速上手 | ||
## 快速使用 | ||
|
||
下方示例演示了 `FloatCurve` 的典型使用方法: | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ | |
::: | ||
|
||
|
||
## 快速上手 | ||
## 快速使用 | ||
|
||
以下例子演示了如何使用 `Flow` 进行简单的流程控制。 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ | |
在制作一些**经常被打断的动画**,如 UI 的动效时非常好用。 | ||
|
||
|
||
## 快速上手 | ||
## 快速使用 | ||
|
||
以下示例演示了如何使用 `FlexValue` 来实现一个简单的 UI 缩放功能: | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
`AudioUtils` 提供了一些与音量控制有关的工具方法。 | ||
|
||
|
||
## 快速上手 | ||
## 快速使用 | ||
```C# | ||
// 百分比转分贝 | ||
var db = AudioUtils.ValueToDb(0.5); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# `VectorUtils` - 向量工具 | ||
|
||
`Bingyan DevKit` 围绕向量提供了一组相当方便的工具。 | ||
|
||
## 快速使用 | ||
|
||
```C# | ||
Vector2 vec2 = new Vector2(1, 0); | ||
transform.position += vec2.Vec3(); // 等效于 (Vector3)movement,但写起来更方便 | ||
vec2 = transform.position.Vec2(); // 等效于 (Vector2)transform.position | ||
// 获得一个向量仅改变一个分量后的值 | ||
vec2 = vec2.SetX(1); | ||
vec2 = vec2.SetY(1); | ||
|
||
// Vector3 也有类似的方法,此处不再列举 | ||
// 翻转 x 或 y | ||
vec2 = vec2.FlipX(); | ||
vec2 = vec2.FlipY(); | ||
|
||
// 快捷运算 | ||
vec2 = vec2.SetLength(1); // 方向不变,长度设为 1 | ||
vec2 = vec2.LimitLength(1); // 方向不变,长度限制到 1 | ||
vec2 = vec2.Rotate(45); // 顺时针顺时针旋转 45 度 | ||
vec2 = vec2.Dot(Vector2.up); // 点积 | ||
var vec3 = Vector3.up.Cross(Vector3.left); // 叉积 | ||
// 工具方法 | ||
vec2 = VectorUtils.MinLength(vec2, Vector2.one); // 获得长度较小的向量 | ||
vec2 = VectorUtils.MaxLength(vec2, Vector2.one); // 获得长度较大的向量 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# `Component` - 组件工具 | ||
|
||
`Bingyan DevKit` 提供了一套利用层级关系获取组件的工具。 | ||
|
||
|
||
## 快速使用 | ||
|
||
```C# | ||
// 在 MonoBehaviour 中 | ||
// 按照 Hierarchy 中的路径获取组件 | ||
// 下方的代码将获取到当前物体的 Path 子物体 -> To 子物体 -> Collider 子物体上的 Collider2D 组件 | ||
var comp = this.GetComp<Collider2D>("Path/To/Collider"); | ||
|
||
// 尝试获得组件,如果不存在则返回 false 并 out null | ||
var hasComp = this.TryGetComp<Collider2D>("Path/To/Collider", out comp); | ||
|
||
// GetComponentInChildren 的 Try 版本 | ||
hasComp = this.TryGetComponentInChildren<Collider2D>(out comp); | ||
|
||
// GetComponentInParent 的 Try 版本 | ||
hasComp = this.TryGetComponentInParent<Collider2D>(out comp); | ||
|
||
// 直接获取位置,等效于 (Vector2) comp.transform.position | ||
var pos = comp.Pos2D(); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# `IEnumerate` - 迭代器工具 | ||
|
||
`Bingyan DevKit` 提供了一套更方便地遍历迭代器的工具。 | ||
|
||
|
||
## 快速使用 | ||
|
||
```C# | ||
// 有下标的 List | ||
var list = new List<string>() { "Hello", "World" }; | ||
|
||
// 无下标的 HashSet | ||
var set = new HashSet<string>() { "Hello", "World" }; | ||
|
||
// ForEach, 但现在非 List 的迭代器也能用了 | ||
set.ForEach(s => Debug.Log(s)); | ||
|
||
// 对于有下标的迭代器,可以带下标进行遍历了 | ||
list.ForEachIndex((index, s) => Debug.Log($"{index}: {s}")); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# `RandomUtils` - 随机工具 | ||
|
||
`RandomUtils` 提供了一些常用的取随机工具。 | ||
|
||
|
||
## 快速使用 | ||
|
||
```C# | ||
var array = new string[] { "Hello", "World", "!" }; | ||
|
||
// 随机取一个元素 | ||
var item = RandomUtils.Choose(array); | ||
|
||
// 对于 List<T>, 可以使用 GetRand() 拓展方法 | ||
var list = new List<string>() { "Hello", "World", "!" }; | ||
item = list.GetRand(); | ||
|
||
// 还可以获取随机元素的下标 | ||
item = list.GetRand(out var idx); | ||
|
||
``` |