npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

com.azathrix.game-kit

v1.0.5

Published

提供了许多有用的游戏开发妙妙工具包

Readme


特性

  • GameScript 增强基类,自动引用赋值
  • 高性能 GameObject 对象池
  • 丰富的扩展方法(Transform、Vector、Collection 等)
  • 常用工具类(随机、数学、时间、单例)

安装

方式一:Package Manager 添加 Scope(推荐)

  1. 打开 Edit > Project Settings > Package Manager
  2. Scoped Registries 中添加:
    • Name: Azathrix
    • URL: https://registry.npmjs.org
    • Scope(s): com.azathrix
  3. 点击 Save
  4. 打开 Window > Package Manager
  5. 切换到 My Registries
  6. 找到 Game Kit 并安装

方式二:Git URL

  1. 打开 Window > Package Manager
  2. 点击 + > Add package from git URL...
  3. 输入:https://github.com/Azathrix/GameKit.git#latest

⚠️ Git 方式无法自动解析依赖,需要先手动安装:

方式三:npm 命令

在项目的 Packages 目录下执行:

npm install com.azathrix.game-kit

功能

GameScript 基类

增强的 MonoBehaviour 基类,提供更清晰的生命周期和自动引用赋值。

public class Player : GameScript
{
    [SerializeField, FindRef("Weapon")] private Transform _weapon;      // 按路径查找
    [SerializeField, GetInChildren] private Animator _animator;         // 从子节点获取
    [SerializeField, GetInParent] private Canvas _canvas;               // 从父节点获取
    [SerializeField, Required] private Rigidbody _rb;                   // 必须存在的引用

    protected override void OnScriptInitialize()
    {
        // 替代 Awake
    }

    protected override void OnScriptStart()
    {
        // 替代 Start
    }

    protected override void OnEventRegister()
    {
        // 注册事件监听
    }

    protected override void OnEventUnRegister()
    {
        // 注销事件监听
    }
}

对象池

高性能 GameObject 对象池,支持预热和异步预热。

// 创建池
var bulletPool = new GameObjectPool(bulletPrefab, poolParent, maxSize: 100);

// 预热
bulletPool.Prewarm(20);
await bulletPool.PrewarmAsync(50, countPerFrame: 5);

// 生成
var bullet = bulletPool.Spawn(position, rotation);
var bulletComp = bulletPool.Spawn<Bullet>(position, rotation);

// 回收
bulletPool.Despawn(bullet);

// 实现 IPoolable 接口获取生命周期回调
public class Bullet : MonoBehaviour, IPoolable
{
    public void OnSpawn() { }
    public void OnDespawn() { }
}

扩展方法

丰富的扩展方法,简化常见操作:

// Transform
transform.SetX(10);
transform.SetLocalY(5);
transform.ResetLocal();

// Vector
var v = new Vector3(1, 2, 3);
v.WithX(10);           // (10, 2, 3)
v.Flat();              // (1, 0, 3)

// GameObject
gameObject.SetLayerRecursively(LayerMask.NameToLayer("Enemy"));
gameObject.GetOrAddComponent<Rigidbody>();

// Collection
var list = new List<int> { 1, 2, 3 };
list.Random();         // 随机元素
list.Shuffle();        // 打乱顺序

// Color
color.WithAlpha(0.5f);

// String
"hello_world".ToPascalCase();  // "HelloWorld"
"100".ToInt();                  // 100
"3.14".ToFloat();               // 3.14f

// Animator
animator.SetTriggerSafe("Attack");

// Async
await 0.5f;            // 等待 0.5 秒
await 3;               // 等待 3 帧

工具类

// 随机
RandomUtils.Range(1, 10);
RandomUtils.Bool();
RandomUtils.PointInCircle(radius);
RandomUtils.PointOnCircle(radius);

// 数学
MathUtils.Remap(value, 0, 100, 0, 1);
MathUtils.SmoothDamp(...);

// 时间
TimeUtils.UnixTimestamp;
TimeUtils.FormatDuration(seconds);

// 单例
public class GameManager : Singleton<GameManager> { }

依赖

License

MIT