techmania-docs

Documentations of TECHMANIA projects, hosted in a repo so they can be localized.


Project maintained by techmania-team Hosted on GitHub Pages — Theme by mattgraham

Themes How-to

This article aims to be a reverse index of the scripting reference. Instead of listing APIs and telling you what they do, we will list some things you may want to do and point you towards the APIs to do that.

Set aspect ratio / dynamic layout

Listen to UI events

Use VisualElementWrap.RegisterCallback.

Change styles of elements

Change styles on a VisualElementWrap via style field, though a few common ones have a shortcut on the VisualElementWrap itself. style is of type UnityEngine.UIElements.IStyle.

If changing some value inside style has no effect, you may need to instantiate new objects. The documentation on style provides an example.

Animate elements

Most animations can be achieved by continuously changing some style on an element over multiple frames. If you are familiar with Unity coroutines, you can implement this in a similar style with tm.StartCoroutine.

Load audio, texture and video

Use tm.io, of type ThemeApi.IO. Audio can be played with tm.audio, textures can be set to backgroundImage of VisualElementWraps, and videos can be played with members in VideoElement.

Retrieve track list

See tm.resource, of type GlobalResource.

Options, modifiers and ruleset

These are available at tm.options, tm.options.modifiers, tm.ruleset respectively.

Read the documentation of Options carefully to understand which options need to be applied with a separate call.

Per-theme options

Each theme gets its own dictionary to store any option it needs. Access it via tm.options.GetPerTrackOptions.

Starting, stopping, controlling the game

Get and set records

To get the record on a pattern / setlist, call tm.records.GetRecord / tm.records.setlist.GetRecord and pass in the full pattern / setlist. Tracks from tm.resources are minimized and do not contain full patterns; you will need to manually load them with tm.io.LoadFullTrack.

When the game is in Complete state, you can call tm.game.ScoreIsNewRecord() to check if the player made a new record, and tm.game.UpdateRecord() to update the in-memory record. For setlists, call tm.game.setlist.ScoreIsNewRecord() and tm.game.setlist.UpdateRecord().

Localization

See ThemeApi.ThemeL10n.

Enter the editor

See ThemeApi.EditorInterface.

Display previews for skins / timing calibration

See ThemeApi.CalibrationPreview and ThemeApi.SkinPreview.

Managing memory

The following resources need to be manually released after you are done with them in order to conserve memory:

See ThemeApi.IO.