Skip to main content

Extension Methods

AchUtils.Extensions contains the Unity runtime extension methods and small utility classes migrated from AchEngine. All public APIs now use the AchUtils namespace, so add using AchUtils; in scripts that consume them.

Package Info

ItemValue
AssemblyAchUtils.Extensions
Root namespaceAchUtils
FolderRuntime/Extensions
Additional Unity packagescom.unity.ugui, com.unity.nuget.newtonsoft-json

Included Areas

Collections

ClassPurpose
ArrayExt, ListExtArray and list helpers
DictionaryExt, MultiDictionary<TKey,TValue>Dictionary helpers and multi-value keys
IEnumerableExt, IListExt, LinqELINQ helpers, shuffling, filtering, conversion

Unity Types

ClassPurpose
GameObjectExt, ComponentExtComponent lookup, add/remove helpers, hierarchy traversal
Vector2Ext, Vector3Ext, RectExtCoordinate, size, and bounds helpers
ColorExt, ColorUtilsColor conversion and hex helpers
SpriteRendererExt, SpriteAtlasExtSprite renderer and atlas helpers

UI

ClassPurpose
RectTransformExtUI layout coordinate and anchor helpers
ImageExt, RawImageExt, GraphicExt, TextExtuGUI component helpers
ButtonClickedEventExtButton click event wrappers

Primitive Types and Utilities

ClassPurpose
StringExt, StringParseExt, StringBuilderExtString checks, parsing, and composition
IntExt, UintExt, FloatExt, BoolExt, ByteExt, EnumExtPrimitive conversion and checks
ActionExt, FuncExt, DelegateExt, UnityEventExtCallback and event helpers
Selectable<T>, SelectableList<T>, SelectableBoolObservable value wrappers
SingleTask, MultiTask, StringAppenderRepeated task and string assembly helpers
PlayerPrefsExt, IJsonExt, IncomingWebhooksJSON persistence, serialization, and webhook sending

Usage

using AchUtils;
using UnityEngine;

public class ExtensionSample : MonoBehaviour
{
private void Awake()
{
var rb = gameObject.GetOrAddComponent<Rigidbody>();
gameObject.SetActiveIfNotNull(true);

var hp = new Selectable<int>(100);
hp.mChanged += () => Debug.Log($"HP changed: {hp.Value}");
hp.Value = 80;

var skills = new MultiDictionary<string, string>();
skills.Add("warrior", "Slash");
skills.Add("warrior", "Block");
}
}

Migration

Code that previously used AchEngine only needs a namespace update.

- using AchEngine;
+ using AchUtils;

The former AchEngine.Extensions.ReflectionE and AchEngine.Extensions.ZciencE namespaces are now AchUtils.Extensions.ReflectionE and AchUtils.Extensions.ZciencE.