# What is Core?

**Core** is a library of basic **extensions / classes / methods / systems / tools**. Some of them are being implemented again and again in every game. Some are something that (imho) just should be part of the Unity Engine. Others are something more specific but still often used in certain game genres.

In other words, **Core** is everything developers would implement at least once. With **Core**, you don't have to.

## Preview of some features

### Property Binding System

<figure><img src="/files/L7w597b2oV83NUCQC9wF" alt=""><figcaption></figcaption></figure>

* Binding game objects to script properties without any code,
* Scalable: changing UI design doesn't require creating or modfying any scripts. Whenever you want to add new widget, you just add it and bind it,
* Easy **MVVM**: Core's **Property Binding** can be used as binding mechanism in **MVVM** pattern, just like shown on GIF. Panel script acts as **ViewModel**, exposing properties to which we can bind and every object/widget (**View**) binds to any of it. This way, **Panel** script is completely separated from **objects displaying information** and vice versa.

### Core hierarchy view

![](/files/ZcrUTB2iUzi53vvPRRAT)

* **Icons** - automatic and customizable, with support for custom components,
* **Layers** - preview of the layer of the object,
* **Active toggle** - activating / deactivating objects. Toggle icon recognizes also whether object is self deactivated or its deactivated by its parent.

{% content-ref url="/pages/p49LGB14YxRwpGwuBR1J" %}
[Hierarchy window (TODO)](/core-lib-documentation/editor-extensions/hierarchy-window-todo.md)
{% endcontent-ref %}

### Singletons

```csharp
// Singleton game object with global access.
class MySingletonGO : SingletonMonoBehaviour<MySingletonGO> {}
// Singleton game object with global access, persisten between scenes.
class MyGlobalSingletonGO : SingletonGlobalMonoBehaviour<MyGlobalSingletonGO> {}
// Singleton scriptable object with global access.
class MyScriptableSingleton : SingletonScriptableObject<MyScriptableSingleton> {}

// All singletons share same API.
MyAnySingleton.Instance.DoSomething();
```

{% content-ref url="/pages/6BPHCx2PcLB3KCcwl3Q2" %}
[Singletons](/core-lib-documentation/code-extensions/singletons.md)
{% endcontent-ref %}

### Extension methods

<pre class="language-csharp" data-overflow="wrap"><code class="lang-csharp"><strong>// Core extension - cast ray from pointer (mouse) if pointer is not over any UI element.
</strong>RaycastHit2D[] hits = CoreFunctions.RaycastPointer2DAll();
if (hits != null)
{
    // Core extension - get random element from list.
    var randomHit = hits.Rand();
    var interactableInterface = hit.collider.GetComponent&#x3C;IInteractable>();
    
    // Core extension - safe null check for references not inheriting from Object.
    if(SelectedInteraction.IsValid())
        SelectedInteraction.Interact();
}
</code></pre>

{% content-ref url="/pages/ahiGFcSFFzmJ9U96iGuo" %}
[Extension methods reference](/core-lib-documentation/code-extensions/extension-methods-reference.md)
{% endcontent-ref %}

### Tools

<div data-full-width="true"><figure><img src="/files/TljmqOCQbbl6dxOHuh4g" alt=""><figcaption><p>One-click upload to Itch.io</p></figcaption></figure></div>

{% content-ref url="/pages/uIVZJ5W00f4eYNkikSaM" %}
[Itch.io Tools](/core-lib-documentation/editor-extensions/itch.io-tools.md)
{% endcontent-ref %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://pirates-game-studio.gitbook.io/core-lib-documentation/what-is-core.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
