[Unity] Masamune framework

The Masamune framework is an extension asset for the Unity3D.

Masamune framework

The "Masamune framework" series provides strong support for development in Unity.

What is the Masamune framework?

The Masamune framework series will help you create games in Unity3D.

It supports a variety of Unity details, including UI creation, Task management, and Data management etc., and can dramatically speed up game creation.

Each product line in the series is linked but independent and does not compete or cause problems with any one or all assets. Deploying only the plug-ins you want to support will result in better cost and performance.

You can check the current lineup on the following page.

The "UIElements Expansions" series can also be used within "Masamune framework".

This section introduces the functions common to the "Masamune framework" series.

  • Object pool
  • Utility Functions
  • Extension Methods

Object pool

Pool and reuse large numbers of objects such as Lists and Dictionaries. You can reduce instantiation processing and save memory.

Utility Functions

You can use various utility functions that support coding. The main utilities introduced here are:

Class Name Summary
Json You can encode and decode Json.
Text Generate random code, generate IDs, etc.
Path You can edit paths and URLs.
AES AES encryption and decryption is possible

Extension Methods

It provides extension methods that support various built-in types. The extension methods introduced here are:

Method Name Summary
int.Limit( int min, int max ) Limits numbers to a range of numbers
string.ToSHA256( string key ) Hash a string with SHA 256
long.ToDateTime( ) Converts a UNIX time stamp to a DateTime type
DateTime.ToUnixTime( ) Converts a DateTime type to a UNIX time stamp

How to Use


Please purchase one of the following "Masamune Framework" series.

The features described in this article are available in the "Masamune Framework" and "UIElements Expansions" series.

You can import after purchase from "My Assets".

Object pool

This section describes how to use object pools with Lists and Dictionaries.

Using object pools requires the following steps: This can be repeated to minimize resources.

  1. Retrieving from an Object Pool (New if no objects in pool)
  2. Using Objects
  3. Return the object to the object pool when it is no longer available

In particular, the effect can be maximized by returning (3) properly.

The actual code is:

// Getting from object pool or creating new objects
List <string> stringList = List.Create <string> ();
Using Objects
// Return to the object pool
stringList.Release ();

For Dictionary:

// Getting from object pool or creating new objects
Dictionary<string, string> stringDictionary = Dictionary.Create<string, string>();
Using Objects
// Return to the object pool

Other collections, such as Queue and Stack, also provide object pools. See the documentation for details.

Utility Functions


The Json class can encode and decode Json.

var dictionary = new Dictionary<string, object>( ) {
    ["AA"] = "BB",
    ["CC"] = "DD",
    ["EE"] = "FF"
// Json Serialization
string json = Utils.Json.Serialize( dictionary );

// Json Deserialization
var desirialized = Utils.Json.Deserialize( json ) as Dictionary<string, object>;
// Get cast to Dictionary
var desirializedDictionary = Utils.Json.DeserializeAsDictionary( json );


It provides methods for creating random code.

// Creates a 12 character random code
string text1 = Utils.Text.GenerateCode( 12 );
// Create a random code that eliminates the confusing characters 1 and l, O and 0
string id = Utils.Text.GenerateCodeForID( 12 );


Provides methods for paths and URLs.

// Outputs the characters in the specified hierarchy.
string indexed = Utils.Path.Index( "/a/b/c/", 2 ); // b
// Gets the characters in the first hierarchy
Utils.Path.First( "a/b/c/" ); // a
// Gets the characters in the last hierarchy
Utils.Path.Last( "a/b/c" ); // c


AES encryption and decryption.

// Encryption
string encrypted = AES.Encrypt( "Any content", "Password" );
// Decryption
string decrypted = AES.Decrypt( encrypted, "Password" );

There are various other utility functions. See the documentation for details.

Extension Methods

Various extension methods are available.

// Limits numbers to a range of numbers
int n = 100;
n = n.Limit( 20, 50 ); // 50

// Hash a string with SHA 256
string text = "text";
string hashed = text.ToSHA256();

// Converts a UNIX time stamp to a DateTime type
long time = 1586353019;
DateTime date = time.ToDateTime(); // 2020/04/08 22:36:59

// Converts a DateTime type to a UNIX time stamp
time = date.ToUnixTime(); // 1586353019


The introduction of "Masamune framework" makes the development of Unity in C # easier and shorter.

Please enjoy a comfortable game production life by introducing "Masamune framework"!

If you are interested, please check out the asset store!

[Unity] UIElements Expansions: Form

Development Unity UIElements AssetStore CSharp

◀︎ Next
[Unity] IconFont - Masamune framework

Development Unity Masamune AssetStore CSharp

▶︎ Previous