Programmer Quick Start
This page is for game developers who want to call a finished Infinio tool from code rather than build one. You do not need to open the graph editor to follow the walkthrough.
By the end you will have watched a script change a graph’s parameter every frame, and you will know
the three calls that do it: Set, TryEvaluate, and reading OutputMesh.
What ships with the example
Everything lives in Assets/Infinio/Examples/ProgrammerQuickStart/:
| File | What it is |
|---|---|
Programmer Example.unity | The scene. A camera, a light, and one empty GameObject called Controller. |
Height Controlled Box.asset | A tiny graph that makes a box. It exposes one float parameter, Height. |
AnimatedParameterDemo.cs | The script on Controller. About 60 lines of code, heavily commented. |
1. Open the scene and press Play
Open Assets/Infinio/Examples/ProgrammerQuickStart/Programmer Example.unity and press Play.
You should see:
- A box appear in front of the camera, growing taller and shorter in a smooth loop.
- A line of text in the top-left corner of the Game view, updating every frame: the current
Height value, the evaluation status (
Ok), and the vertex count of the box.
That text is the script reporting what happened on each evaluation. Nothing is written to the console.
2. Look at the Controller
Select Controller in the Hierarchy. The Animated Parameter Demo component has five fields:
| Field | Set to | Meaning |
|---|---|---|
| Graph Asset | Height Controlled Box | The compiled graph to run. |
| Parameter Name | Height | Which exposed parameter to drive. |
| Base Value | 1 | The middle of the sweep. |
| Amplitude | 0.5 | How far above and below the middle it goes. |
| Frequency | 0.5 | Full cycles per second. |
While in Play mode, change Amplitude or Frequency and the box reacts immediately. Graph Asset and Parameter Name are only read when Play starts, so change those before pressing Play.
3. Read the script
Open AnimatedParameterDemo.cs. It does four things.
Once, in Start(): create an instance of the graph.
_instance = InfinioInstance.Spawn(graphAsset, transform.position, Quaternion.identity);This creates a new GameObject that holds the graph and renders its output. You can also place an
InfinioInstance in the scene by hand and reference it instead; Spawn just does it from code.
Once, in Start(): check the parameter exists.
_paramMissing = !_instance.TryGet(parameterName, out float _);If the name is wrong, Set does nothing and returns false. Checking once up front lets the
script show a clear message instead of failing quietly every frame.
Every frame, in Update(): set the value, then evaluate once.
_instance.Set(parameterName, value);
if (_instance.TryEvaluate(out InfinioEvalReport report))
{
var mesh = _instance.OutputMesh;
// ...
}Every frame: report the result. The status line you saw in step 1 is built from report.
The three rules
These are the parts that tend to surprise people.
Setdoes not rebuild anything. It only stores the new value. Nothing changes on screen until you callTryEvaluate(orEvaluate). If you change several parameters, callSetfor each one and then evaluate once. For a single one-off change,Set(name, value, reevaluate: true)does both in one call. (Changing a value in the Inspector does rebuild automatically; changing it from a script does not.)- Read the report, not the console.
TryEvaluatereturnsfalseif the evaluation failed, andreport.Statussays why. Checkreport.Warnings.Anyeven when it succeeds: warnings mean the result was produced but may be degraded. On failure,OutputMeshkeeps the last good result, so the object does not vanish. - Never destroy
OutputMesh. The instance owns it and reuses it. Read it, copy it if you need to keep it, but do not callDestroy()on it.
Try it with another graph
- Pick any example graph, for instance one from the Examples page.
- Open it in the graph editor and look at the Parameters sidebar on the left. Pick a float parameter and note its name exactly as shown.
- On Controller, drag that graph into Graph Asset, type the name into Parameter Name, and set Base Value and Amplitude to something sensible for that parameter.
- Press Play.
If the top-left text says Binary exposes no float parameter named '...', the name does not match.
Check spelling and capitalisation against the Parameters sidebar. Renaming a parameter in the
graph changes the name your code has to use.
What we would like you to try
- Drive a parameter from your own script, using this one as a template.
- Make a Windows player build of the scene and check it behaves the same as in the editor.
- Tell us where the API fought you: a name that was hard to guess, a call you expected to exist, an error that did not explain itself. The Reporting & Feedback page covers where to send it.
Going further
Calling Infinio from code covers the full code-side API: assembly setup, the
other value types Set accepts, hooks, spawn points, and platform notes.