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
using Cysharp.Threading.Tasks; | |
using System.Collections.Generic; | |
using UnityEngine.LowLevel; | |
using UnityEngine.Networking; | |
namespace UniHttpLib | |
{ | |
public class UniHttp | |
{ | |
private static UniHttp m_Inst; |
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
/// <summary> | |
/// - Round() 函数是四舍五入的实现,所以对于计算机来说,0.9995 可能实际上是0.999499999,从而导致四舍五入的结果是 0.999 而不是 1.0,所以这些的函数才都加上了 0.001 来保证四舍五入的结果符合预期 | |
/// - Int16 最大值有三万多,可以根据实际情况是否选用 int16, 可以减小网络传输? | |
/// - 不同的数据对精度要求不同,所以有的乘以100,有的乘以1000 | |
/// </summary> | |
public static class PackValueUtil | |
{ | |
private const int Float_Pack_Factor = 100; | |
private const float Float_Pack_Factor_Err = 1.0f / (Float_Pack_Factor * 10); // = 0.001f |
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
using System; | |
public class NormalDistribution | |
{ | |
private static Random random = new Random(); | |
/// <summary> | |
/// 理论上这个函数的返回值范围是 正无穷到负无穷,但 | |
/// 约99.7%的数据位于均值的三个标准差范围内 ( 即 mu ± 3sigma )。 | |
/// </summary> |
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
using UnityEngine; | |
/// <summary> | |
/// 单摆运动 | |
/// </summary> | |
public class Pendulum : MonoBehaviour | |
{ | |
public float length = 2f; // Pendulum Length | |
public float theta0 = Mathf.PI / 4; // Initial Angle | |
public float g = 9.81f; // Gravity |
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
using System; | |
using System.Collections; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
using Sirenix.OdinInspector; | |
using UnityEngine; | |
/// <summary> | |
/// Unity引用并且生成代码 |
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
using Cysharp.Threading.Tasks; | |
using System.Net.Http; | |
using UnityEngine; | |
public class TestUniTaskChannel : MonoBehaviour | |
{ | |
private Channel<bool> m_ChannelLock; | |
private string m_CachedResult; | |
private void Start() |
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
public static class Program | |
{ | |
public class SmallClass | |
{ | |
public int Value; | |
public void Add(SmallClass other) | |
{ | |
Value += other.Value; | |
} |
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
using System.Collections.Generic; | |
using UnityEngine; | |
public static class CatmullRomSpline | |
{ | |
public static void DrawCatmullRomSpline(LineRenderer lineRenderer, params Vector3[] targets) | |
{ | |
if (targets == null || targets.Length <= 0) return; | |
var pos = new List<Vector3>(); |
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
/// <summary> | |
/// 椭圆网格映射 | |
/// </summary> | |
/// <remarks> | |
/// 将二维矢量作为移动的输入时,输入的矢量范围是一个正方形,显然正方形的斜角比边要长 | |
/// 如果直接将这个二维矢量作为移动的输入的话,会导致斜角的移动速度更快 | |
/// 采用这个函数将矢量的值域从正方形限制为圆形 | |
/// 而圆的半径是固定的,斜方向的移动速度不会更快 | |
/// 论文地址: https://arxiv.org/ftp/arxiv/papers/1509/1509.06344.pdf 第5页 elliptical grid mapping | |
/// </remarks> |
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
/// <summary> | |
/// 2D胶囊体与2D圆是否相交 | |
/// </summary> | |
/// <param name="capsulePoint">胶囊体的圆心</param> | |
/// <param name="capsuleDir">胶囊体的向量</param> | |
/// <param name="capsuleRadius">胶囊体的半径</param> | |
/// <param name="circlePoint">圆心的位置</param> | |
/// <param name="circleRadius">圆的半径</param> | |
/// <returns></returns> | |
private static bool CapsuleAndCircleCheckHit(Vector2 capsulePoint, Vector2 capsuleDir, float capsuleRadius, Vector2 circlePoint, float circleRadius) |
NewerOlder