Skip to content

Repository files navigation

⏺️ TArray - Ultimate Serializable Array [C# / Unity]

TArray Logo

TArray is incredibly fast, universal and serializable array solution for C# and Unity.

The main adventage of TArray in comparison to others is that this solution combines unbelievably simple and low amout of code [totally 180 lines] with nearly every expected feature, beacuse of fullness of well-written approaches.

Another is that the TArray is not a class like many other extended arrays, but still a structure like classic array - so it is really fast and memory safe and friendly, and also support enumerations and LINQ expressions natively.

📘 Installation

You can install it by:

  1. Using Unity Git packages support:
Toolabar->Window/PackageManager->->AddpackagefromGitURL->"https://github.com/ovsky/TArray.git#upm"
  1. Unity Git URL suppport, by adding this entry in your packages manifest.json:
"com.ovsky.tarray": "https://github.com/ovsky/TArray.git#upm"
  1. Using Unity tarball support and wget [Linux] or start [Windows] download:
Linux: "wget https://github.com/ovsky/TArray/tarball/upm -O ovsky.tarray-upm.tgz"
Windows: "start https://github.com/ovsky/TArray/tarball/upm"
Use: Toolabar->Window/PackageManager->->Addpackagefromtarball->Select: "ovsky.tarray-*.tgz"

The upm stands for Unity Package Manager - the default manager for Unity-ready external packages/extensions.

📖 QuickStart

Code:

So, let's see the most important TArray features:

Multiple declaration possibilities:

TArray<int>integerArray=newTArray<int>(5,5);// Classic declarationTArray<int>integerArray=newint[5,5];// Array attributed declarationTArray<int>integerArray=newArray[5,5];// Classic array declarationTArray<int>integerArray=new(5,5);// Modern .NET declaration

Easy conversion support:

TArray<int>integerArray=stringArray.Cast<int>();// Convert string to int arrayTArray<string>stringArray=customArray.Cast<string>();// Convert custom to string array

Different value get/set options:

intelement=integerArray[2,2];// Get value using attributesintelement=integerArray.Get(2,2);// Get value using methodintegerArray[2,2]=1;// Set value using attributesintegerArray.Set(2,2,1);// Set value using method

All LINQ operations support:

TArray<Pets>petsArray=petsArray.Array.OrderBy(pet =>pet.Age).ToArray();// Sort class array by class property valueTArray<Pets>dogsArray=petsArray.Array.Select(pet =>petisDog).ToArray();// Select Dogs from Pets arrayTArray<int>integerArray=integerArray.Array.OrderBy(i =>i).ToArray();// Sort int array values

Type-free array operations:

ITArrayvalueArray;valueArray=newTArray<int>(5,5);// Declare int array at the fieldvalueArray=valueArray.Cast<string>();// Cast the array to string values and apply to undefined fieldvalueArray=newTArray<bool>(5,5).Set(0,0,true);// Then change it to bool array with (0, 0) set to trueTArray<bool>boolArray=valueArray;// Apply the undefined value array to array with defined type

And more!

🗂️ Editor

TArray Editor (Property Drawer actually) - is an extendable, flexible, and the most important: it supports all serializable types (existing and user-defined) out of the box, without creating the new Unity Inspector or Editor!

Integer Preview:

TArray Integer Preview

GameObject Preview:

TArray GameObject Preview

Boolean Preview:

TArray Boolean Preview

📝 License:

Copyright (C) 2023 - Przemysław Orłowski
"THE SOFTWARE IS PROVIDED 'AS IT IS' (...)"
also known as:
**The MIT License**: https://choosealicense.com/licenses/mit/

About

Ultimate Serializable Array for Unity / C#

Topics

Resources

Stars

21 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages