A lightweight, designer-friendly scripting system for Unity. Define game logic using a simple custom syntax with real-time syntax highlighting in the Inspector.
- π Simple Syntax - Easy-to-learn DSL designed for game designers
- π¨ Syntax Highlighting - Real-time colored preview in the Unity Inspector
- π’ Line Numbers - Visual Studio-like line number gutter
- π― Attribute-Based Binding - Connect scripts to your code with simple attributes
- π¦ Inline or Asset - Use scripts embedded in components or as reusable ScriptableObjects
- β Live Validation - Instant error detection as you type
- π§ Zero Dependencies - Pure C#, no external libraries required
- Open Package Manager in Unity (
Window > Package Manager) - Click the
+button and selectAdd package from git URL... - Enter the following URL:
https://github.com/xavierarpa/InScript.git- Download or clone this repository
- Copy the
InScriptfolder into yourAssets/Pluginsfolder
Add attributes to expose fields and methods to scripts:
using UnityEngine;
using InScript;
public class Character : MonoBehaviour
{
[SerializeField, InScript] private float hp = 100;
[SerializeField, InScript] private float maxHp = 100;
[SerializeField, InScript] private float attack = 10;
[SerializeField, InScript("Target")] private Character target;
[InScript]
private void Heal(float amount)
{
hp = Mathf.Min(hp + amount, maxHp);
}
[InScript]
private void Log(string message, float value)
{
Debug.Log($"{message}: {value}");
}
}Create a ScriptAsset or use an inline Script field:
@main
$damage = attack * 1.5
? hp < maxHp * 0.5
Log("Low HP!", hp)
Heal(20)
;
#Target.TakeDamage($damage)
;
[SerializeField] private Script script;
void Start()
{
script.ExecuteBlock("main", this);
}@blockName // Start a named block
// code here
; // End block
$localVar = 10 // Local variable (script scope)
$localVar += 5 // Compound assignment (+=, -=, *=, /=)
contextVar = value // Context variable (from your code)
#Target.hp // Access selector property
#Target.TakeDamage(10) // Call selector method
? condition // If
// code
:? otherCondition // Else if
// code
: // Else
// code
; // End if
| Function | Description | Example |
|---|---|---|
min(a, b) |
Returns the smaller of two values | min(hp, maxHp) β 50 if hp=50, maxHp=100 |
max(a, b) |
Returns the larger of two values | max(0, damage - armor) β prevents negative |
clamp(value, min, max) |
Constrains a value between min and max | clamp(hp, 0, maxHp) β keeps hp in valid range |
abs(x) |
Returns the absolute (positive) value | abs(-5) β 5 |
sign(x) |
Returns -1, 0, or 1 based on sign | sign(-10) β -1 |
| Function | Description | Example |
|---|---|---|
floor(x) |
Rounds down to nearest integer | floor(3.7) β 3 |
ceil(x) |
Rounds up to nearest integer | ceil(3.2) β 4 |
round(x) |
Rounds to nearest integer | round(3.5) β 4 |
| Function | Description | Example |
|---|---|---|
sqrt(x) |
Square root | sqrt(16) β 4 |
pow(base, exp) |
Power/exponent | pow(2, 3) β 8 |
lerp(a, b, t) |
Linear interpolation between a and b | lerp(0, 100, 0.5) β 50 |
random(min, max) |
Random float between min and max | random(1, 10) β 5.7 (varies) |
random() |
Random float between 0 and 1 | random() β 0.42 (varies) |
| Type | Operators |
|---|---|
| Arithmetic | + - * / |
| Comparison | == != < > <= >= |
InScript/
βββ Runtime/
β βββ Script.cs # Serializable script container
β βββ ScriptAsset.cs # ScriptableObject wrapper
β βββ ScriptRunner.cs # Script execution engine
β βββ IScriptContext.cs # Context interface
β βββ ReflectionContext.cs # Attribute-based context
β βββ Attributes/
β βββ InScriptAttribute.cs # Unified attribute for values/selectors/methods
βββ Editor/
βββ ScriptDrawer.cs # PropertyDrawer with syntax highlighting
βββ ScriptAssetEditor.cs # Custom editor for ScriptAsset
βββ ScriptDebugWindow.cs # Debug panel for testing scripts
βββ SyntaxReferenceWindow.cs # Dockable syntax documentation
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please read CONTRIBUTING.md for details.
Xavier Arpa - @xavierarpa