A set of code useful for developing Unity based games. It is independent of any architecture, so you can use it together with your favorite framework.
These are the foundations on which Game:Work Core is built.
- Architecture agnostic, use it in any code.
- Many attributes to make your classes more usable in the editor. Custom Inspector to help you create your own inspectors.
- Multiple utilities to improve your developments: checkers, debug draw, profiling and a console with custom commands.
- A lot of .Net and Unity types extensions (System, Unity, functional, enum, collider, texture, animator, MonoBehaviour, and more).
- The most used design patterns (15 patterns), in generic versions so that they are easy to adapt to your needs.
- Data Holders system with typed ScriptableObject holders and generic Option class for local/global value configuration.
- Utilities to speed up prototyping time.
- Commented code with test units.
- Unity 6000.0 or higher.
- Universal RP 14.0.11 or higher.
- Test Framework 1.1.31 or higher.
- Open the manifest.json file of your Unity project.
- In the section "dependencies" add:
{
...
"dependencies":
{
...
"FronkonGames.GameWork.Foundation": "git+https://github.com/FronkonGames/GameWork-Foundation.git"
}
...
}Just clone the repository into your Assets folder:
git clone https://github.com/FronkonGames/GameWork-Foundation.git Download the latest release and unzip it into the Assets directory.
The functionality is divided into folders, this is its structure:
|
|\_Runtime......................... Utilities for the game.
| |\_Algorithms.................. Algorithms.
| | \_Structures.............. Data structures.
| |\_Attributes.................. Attributes for fields and class properties.
| |\_Components.................. Components.
| |\_Data......................... Data utilities.
| | |\_Holders.................. ScriptableObject value holders.
| | \_Serialization............ Serializable types for Unity (DateTime, Time, Dictionary).
| |\_Development................. Developer utilities.
| | |\_Check................... Assert extension.
| | |\_Console................. Development console.
| | |\_Draw.................... Utilities for drawing gameplay information.
| | |\_Profiling............... To find bottlenecks.
| | \_Prototype............... Useful components for prototypes.
| |\_Extensions.................. Utility extensions.
| | |\_System.................. C# extensions.
| | \_Unity................... Unity extensions.
| |\_Math........................ Mathematical utilities.
| |\_Patterns.................... Design patterns.
| | |\_Behavioral.............. Behavioural patterns.
| | |\_Creational.............. Creation patterns.
| | |\_Structural.............. Structure patterns.
| | \_Optimization............ Optimization patterns.
| \_Utils....................... Utilities.
|
|\_Editor.......................... Editor utilities.
| |\_Drawers..................... Custom attribute viewers.
| |\_Fonts....................... Font for debug.
| \_Inspector................... Editor appearance utilities.
|
|\_Settings........................ Project settings.
|\_Demos........................... Demo scenes.
|\_Media........................... Misc resources.
\_Test............................ Unit tests code.
Check the comments for each file for more information.
A simple way to create your own inspectors by quickly accessing all the private fields of your components.
Checks the values of the variables that a function receives. If the condition is not met, an exception is thrown. Only active when 'UNITY_ASSERTIONS' is defined (default only in the Editor).
public void GetImpact(GameObject gameObject, float damage, Vector3 impact)
{
Check.IsNotNull(gameObject);
Check.IsWithin(damage, 0.0f, 100.0f);
Check.Greater(impact, Vector3.zero);
...
}Take a look at the Check class folder.
Visualize in the Editor Scene window useful information of your game, in a simple way and without affecting the final performance of the game.
// Displays an array of points.
points.Draw();
// Displays the player's direction.
player.transform.Draw();
// Displays the name of the GameObject.
player.DrawName();
// Displays RaycastHits.
int hits = Physics.RaycastNonAlloc(playerRay, playerHits, 100.0f);
if (hits > 0)
playerHits.Draw(playerRay);Useful components to support the development of prototypes:
- First person, third person and free cameras.
- Screenshooter: asynchronous screen capture.
- Hardware monitor: shows various performance data.
- Collision Test: triggers events when collisions are detected.
- Trigger Test: triggers events.
- Face To: orients the object so that it faces a target.
- Follower: follow a target.
- Mover: moves object linearly.
- Rotator: rotates an object.
- Material scroller: moves a texture at a linear speed.
A developer console for executing commands.
Simply add a GameObject with the DevelopmentConsole component and assign the commands you want to use to it.
Commands are ScriptableObjects that you can create from DevelopmentCommand. See the commands included in this folder.
/// <summary>
/// Quit application.
/// </summary>
[CreateAssetMenu(fileName = "Quit", menuName = "Game:Work/Development/Command/Quit")]
public class QuitCommand : DevelopmentCommand
{
public QuitCommand()
{
Id = "quit";
Usage = "quit";
Description = "Quit application.";
}
public override bool Execute(string[] args)
{
Application.Quit();
return true;
}
}It measures in a simple way the time it takes for a block of code to execute, or the memory it consumes.
using (Profiling.Time("Some slow code"))
{
...
}Output the message: "Task 'Some slow code' took 27.66ms (0 frames)"
using (Profiling.Memory("Some hungry code"))
{
...
}Output the message: "Task 'Some hungry code' consume 4.00 kb".
Algorithms and data structures.
The most used design patterns, all using generics:
- Behavioral: Chain of Responsibility, Command, Mediator, Memento, Observer, State, Strategy, Visitor.
- Creational: Builder, Factory, Service Locator, Singleton.
- Structural: Composite, Decorator.
- Optimization: Object Pool.
Typed ScriptableObject holders for decoupled data configuration:
// Create a holder asset: Create > GameWork > Data Holders > Float Holder
[CreateAssetMenu(menuName = "GameWork/Data Holders/Float Holder")]
public class FloatHolder : ScriptableObject, IValueHolder<float>
{
[SerializeField] private float value = 0f;
public float GetValue() => value;
public void SetValue(float newValue) => value = newValue;
}
// Use Option for flexible local/global configuration
[System.Serializable]
public class Option<TValue, THolder> where THolder : ScriptableObject, IValueHolder<TValue>
{
// Mode: Disabled, LocalValue, GlobalValue
// Value returns local or global based on mode
}Available holders: Bool, Int, Float, String, Color, Vector2/3/4, Quaternion, GameObject, Transform, AudioClip, Material, Sprite, Texture, LayerMask, Collider, Collider2D, Rigidbody, Rigidbody2D, RectTransform.
Serializable wrappers for .NET types that Unity cannot serialize directly:
- SerializableDateTime: Wraps
System.DateTimeinto serializable int fields. Supports implicit conversion to/fromDateTime. - SerializableTime: Wraps
TimeSpanas a serializable struct with days/hours/minutes/seconds/milliseconds. Factory methods:FromSeconds,FromTicks,FromTimeSpan,FromDateTime. - SerializableDictionary: A serializable
Dictionary<TKey, TValue>usingISerializationCallbackReceiver. Factory methods:FromDictionary,FromKeyPairValueList. - SerializableKeyValuePair: A serializable
KeyValuePair<TKey, TValue>with implicit conversions.
More than 400 tests.
Code released under MIT License.
'Prototype Asset Pack' by AssetHunts.
'Prototype Textures' and 'Mannequin Character Pack' by AssetHunts.




















