diff --git a/Runtime/MicroLibrary/MacroInching.cs b/Runtime/MicroLibrary/MacroInching.cs
new file mode 100644
index 0000000..df25836
--- /dev/null
+++ b/Runtime/MicroLibrary/MacroInching.cs
@@ -0,0 +1,31 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+namespace XericLibrary.Runtime.MacroLibrary
+{
+ ///
+ /// 缓动步进库
+ ///
+ public static class MacroInching
+ {
+ ///
+ /// 线性步进
+ ///
+ ///
+ public static double LinearTowards(double from, double to, double maxStepDelta)
+ {
+ return from + Math.Clamp(to - from, -maxStepDelta, maxStepDelta);
+ }
+
+ ///
+ /// 线性步进
+ ///
+ ///
+ public static float LinearTowards(float from, float to, float maxStepDelta)
+ {
+ return (float)LinearTowards((double)from, (double)to, (double)maxStepDelta);
+ }
+ }
+}
diff --git a/Runtime/MicroLibrary/MacroInching.cs.meta b/Runtime/MicroLibrary/MacroInching.cs.meta
new file mode 100644
index 0000000..eeef7e4
--- /dev/null
+++ b/Runtime/MicroLibrary/MacroInching.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: dde2a3b263805b34db3b546fd5922f43
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Runtime/MicroLibrary/MacroList.cs b/Runtime/MicroLibrary/MacroList.cs
index f77088a..7f79b47 100644
--- a/Runtime/MicroLibrary/MacroList.cs
+++ b/Runtime/MicroLibrary/MacroList.cs
@@ -1,3 +1,5 @@
+using Codice.CM.Triggers;
+
using System;
using System.Collections;
using System.Collections.Concurrent;
@@ -129,7 +131,7 @@ namespace XericLibrary.Runtime.MacroLibrary
#endregion
#region 应用算法
-
+
///
/// 获取列表中随机顺序的对象
///
@@ -144,6 +146,24 @@ namespace XericLibrary.Runtime.MacroLibrary
yield return list[index[i]];
}
+ ///
+ /// 对列表中的成员按组进行划分,并读取特定组中特定索引下的成员
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static IEnumerable GetListGroupMember(this List list, int group, int target)
+ {
+ if(list.Count % group != 0)
+ throw new Exception("在进行列组成员获取时,组不能刚好整除列表总数");
+
+ for(int i = 0; i < list.Count; i++)
+ if((i % group) == target)
+ yield return list[i];
+ }
+
#endregion
diff --git a/Runtime/MicroLibrary/MacroVector3.cs b/Runtime/MicroLibrary/MacroVector3.cs
deleted file mode 100644
index cac7718..0000000
--- a/Runtime/MicroLibrary/MacroVector3.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using UnityEngine;
-
-namespace XericLibrary.Runtime.MacroLibrary
-{
- ///
- /// 矢量宏库
- ///
- [Obsolete("与扩展库放在一起,不要单独出现")]
- public static class MacroVector3
- {
- ///
- /// 获取与世界正交轴最近的一条轴线
- ///
- ///
- ///
-
- public static Vector3 GetWorldNormalAxis(Vector3 vector)
- {
- Vector3[] axes = { Vector3.right, Vector3.up, Vector3.forward };
- float minAngle = float.MaxValue;
- Vector3 minAngleAxis = Vector3.zero;
-
- foreach(Vector3 axis in axes)
- {
- float dot = Vector3.Dot(vector, axis);
- float angle = Mathf.Abs(dot);
- if(angle < minAngle)
- {
- minAngle = angle;
- minAngleAxis = axis * Mathf.Sign(dot);
- }
- }
-
- return minAngleAxis;
- }
- }
-}
diff --git a/Runtime/MicroLibrary/Vector2Extend.cs b/Runtime/MicroLibrary/Vector2Extend.cs
index bb7f5d3..857f670 100644
--- a/Runtime/MicroLibrary/Vector2Extend.cs
+++ b/Runtime/MicroLibrary/Vector2Extend.cs
@@ -9,6 +9,10 @@ namespace XericLibrary.Runtime.MacroLibrary
{
public static class Vector2Extend
{
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static Vector2 OneMinus(this Vector2 a)
+ => new Vector2(1 - a.x, 1 - a.y);
+
[Obsolete("unfinished")]
public static Vector2 Projection(this Vector2 point, Vector3 start, Vector3 end)
{
diff --git a/Runtime/MicroLibrary/Vector3Extend.cs b/Runtime/MicroLibrary/Vector3Extend.cs
index c8effd6..4d9c97d 100644
--- a/Runtime/MicroLibrary/Vector3Extend.cs
+++ b/Runtime/MicroLibrary/Vector3Extend.cs
@@ -107,6 +107,10 @@ namespace XericLibrary.Runtime.MacroLibrary
a.z / b
);
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static Vector3 OneMinus(this Vector3 a)
+ => new Vector3(1 - a.x, 1 - a.y, 1 - a.z);
+
#endregion
#region 扩展运算
diff --git a/Runtime/Type/Enum.meta b/Runtime/Type/Enum.meta
new file mode 100644
index 0000000..2c6e0be
--- /dev/null
+++ b/Runtime/Type/Enum.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 332399c09755e3f41936f1931f08654f
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Runtime/Type/EasingMode.cs b/Runtime/Type/Enum/EasingMode.cs
similarity index 100%
rename from Runtime/Type/EasingMode.cs
rename to Runtime/Type/Enum/EasingMode.cs
diff --git a/Runtime/Type/EasingMode.cs.meta b/Runtime/Type/Enum/EasingMode.cs.meta
similarity index 100%
rename from Runtime/Type/EasingMode.cs.meta
rename to Runtime/Type/Enum/EasingMode.cs.meta
diff --git a/Runtime/Type/Enum/Orientation.cs b/Runtime/Type/Enum/Orientation.cs
new file mode 100644
index 0000000..b860982
--- /dev/null
+++ b/Runtime/Type/Enum/Orientation.cs
@@ -0,0 +1,30 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+namespace XericLibrary.Runtime.Type
+{
+ ///
+ /// 矢量方位
+ ///
+ public enum Vector3Orientation
+ {
+ Front,
+ Back,
+ Up,
+ Down,
+ Left,
+ Right,
+ }
+ ///
+ /// 矢量方位
+ ///
+ public enum Vector2Orientation
+ {
+ UpFront,
+ DownBack,
+ Left,
+ Right,
+ }
+}
diff --git a/Runtime/MicroLibrary/MacroVector3.cs.meta b/Runtime/Type/Enum/Orientation.cs.meta
similarity index 100%
rename from Runtime/MicroLibrary/MacroVector3.cs.meta
rename to Runtime/Type/Enum/Orientation.cs.meta
diff --git a/Runtime/Type/GradientWeight.cs b/Runtime/Type/GradientWeight.cs
index 8dbf73f..dfd1a21 100644
--- a/Runtime/Type/GradientWeight.cs
+++ b/Runtime/Type/GradientWeight.cs
@@ -21,6 +21,7 @@ namespace XericLibrary.Runtime.Type
///
/// 梯度列表,默认其中的元素都是从小到大的,且数量不小于1
///
+ [SerializeField]
private List> gradientList;
public int Count => gradientList.Count;
@@ -184,6 +185,25 @@ namespace XericLibrary.Runtime.Type
return gradientList.Count - 1;
}
+ ///
+ /// 获取一个可以随权重变化的调整率
+ ///
+ ///
+ ///
+ ///
+ ///
+ public float GetSmoothstep(float edge0, float edge1, float x, float k)
+ {
+ x = Mathf.Clamp01((x - edge0) / (edge1 - edge0));
+ //return x * x * (3f - 2f * x);
+ return Mathf.Pow(x, k);
+ }
+
+ public float GetSmoothstep(float x, float k)
+ {
+ return GetSmoothstep(0, 1, x, k);
+ }
+
#endregion
}
@@ -200,21 +220,25 @@ namespace XericLibrary.Runtime.Type
///
/// 横轴坐标
///
+ [SerializeField]
public float x;
///
/// 纵轴取值
///
+ [SerializeField]
public K y;
///
/// 与上一个项目的权重
///
+ [SerializeField]
public float WeightPrev;
///
/// 与下一个项目的权重
///
+ [SerializeField]
public float WeightNext;
#endregion
@@ -274,6 +298,11 @@ namespace XericLibrary.Runtime.Type
return thisWeight;
}
+ public float GetAdjacentRarioSimpleWeight(GradientPoint next, out float nextWeight)
+ {
+ nextWeight = next.WeightPrev / Mathf.Max(this.WeightNext + next.WeightPrev, float.MinValue);
+ return 1 - nextWeight;
+ }
#endregion
}
@@ -338,8 +367,8 @@ namespace XericLibrary.Runtime.Type
{
protected internal override Color GetAdjacentGradientMixWithWeight(GradientPoint point1, GradientPoint point2, float value)
{
- var weight1 = point1.GetAdjacentRatioWeight(point2, out var weight2);
- return Color.Lerp(point1.y * weight1, point2.y * weight2, value);
+ var weight1 = point1.GetAdjacentRarioSimpleWeight(point2, out var weight2);
+ return Color.Lerp(point1.y, point2.y, GetSmoothstep(value, weight1));
}
}
diff --git a/Runtime/Type/Named.meta b/Runtime/Type/Named.meta
new file mode 100644
index 0000000..5cc89fe
--- /dev/null
+++ b/Runtime/Type/Named.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: a2ba6a3dd88427d4e8ae8dc465957ffa
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Runtime/Type/Named/GreekLetteList.cs b/Runtime/Type/Named/GreekLetteList.cs
new file mode 100644
index 0000000..a0c466e
--- /dev/null
+++ b/Runtime/Type/Named/GreekLetteList.cs
@@ -0,0 +1,65 @@
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+
+using UnityEngine;
+
+using XericLibrary.Runtime.MacroLibrary;
+
+namespace XericLibrary.Runtime.Type
+{
+ public static class GreekLetteList
+ {
+ private readonly static List GreekLettes = new List()
+ {
+ "Α", "Alpha", "阿尔法",
+ "Β", "Beta", "贝塔",
+ "Γ", "Gamma", "伽玛",
+ "Δ", "Delta", "德尔塔",
+ "Ε", "Epsilon", "伊普西隆",
+ "Ζ", "Zeta", "戈塔",
+ "Η", "Eta", "伊塔",
+ "Θ", "Theta", "西塔",
+ "Ι", "Iota", "约塔",
+ "Κ", "Kappa", "卡帕",
+ "Λ", "Lambda", "兰布达",
+ "Μ", "Mu", "缪",
+ "Ν", "Nu", "纽",
+ "Ξ", "Xi", "克西",
+ "Ο", "Omicron", "奥米克戎",
+ "Π", "Pi", "派",
+ "Ρ", "Rho", "肉",
+ "Σ", "Sigma", "西格玛",
+ "Τ", "Tau", "陶",
+ "Υ", "Upsilon", "豫普西隆",
+ "Φ", "Phi", "斐",
+ "Χ", "Chi", "喜",
+ "Ψ", "Psi", "普赛",
+ "Ω", "Omega", "欧米伽",
+ };
+
+ private static int FeatureGroup = 3;
+
+ ///
+ /// 获取希腊字母
+ ///
+ ///
+ public static IEnumerable GreekLetteCharacters()
+ => GreekLettes.GetListGroupMember(FeatureGroup, 0);
+
+ ///
+ /// 获取希腊字母全拼
+ ///
+ ///
+ public static IEnumerable GreekLetteEnglishNames()
+ => GreekLettes.GetListGroupMember(FeatureGroup, 1);
+
+ ///
+ /// 获取希腊字母读音
+ ///
+ ///
+ public static IEnumerable GreekLetteChineseNames()
+ => GreekLettes.GetListGroupMember(FeatureGroup, 2);
+
+ }
+}
diff --git a/Runtime/Type/Named/GreekLetteList.cs.meta b/Runtime/Type/Named/GreekLetteList.cs.meta
new file mode 100644
index 0000000..408a65e
--- /dev/null
+++ b/Runtime/Type/Named/GreekLetteList.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: ad5f4cc8676b1ac42b5535a3e3ee0a9c
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Runtime/Type/Named/TalosLetteList.cs b/Runtime/Type/Named/TalosLetteList.cs
new file mode 100644
index 0000000..17d9b56
--- /dev/null
+++ b/Runtime/Type/Named/TalosLetteList.cs
@@ -0,0 +1,14 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+namespace XericLibrary.Runtime.Type
+{
+ public static class TalosLetteList
+ {
+ private readonly static List GreekLettes = new List()
+ {
+
+ };
+ }
+}
diff --git a/Runtime/Type/Named/TalosLetteList.cs.meta b/Runtime/Type/Named/TalosLetteList.cs.meta
new file mode 100644
index 0000000..efd96b1
--- /dev/null
+++ b/Runtime/Type/Named/TalosLetteList.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 1e256a1300ce9c4409524c457629262a
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/package.json b/package.json
index b9d20d5..e9fadb6 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "com.lrss3.xericlibrary",
"displayName": "Xeric Library",
- "version": "0.2.410",
+ "version": "0.2.412",
"unity": "2021.3",
"description": "\u901a\u7528\u5e93\u63d2\u4ef6\u3002"
}
\ No newline at end of file