Restrictions on Unity APIs

This page lists everything that is currently not supported in T#

While T# supports many of Unity’s APIs, certain methods, lifecycle hooks, and behaviors are restricted. These limitations exist due to the live-editing runtime and interpreted execution model of Terra Studio

🚫 LateUpdate

In Unity, LateUpdate() is often used to perform actions after all Update() calls β€” such as camera movement or following a character.LateUpdate() is not supported in T#.

πŸ” What you instead need to do in T#:

Use coroutines with WaitForEndOfFrame() to simulate end-of-frame logic.

IEnumerator DelayedLogic() {
    yield return new WaitForEndOfFrame();
    // Logic that would have gone in LateUpdate
}

Call the coroutine when needed, for example in Start() or Update():

void Start() {
    StartCoroutine(DelayedLogic());
}

πŸ§ͺ GetComponent after Instantiate

In Unity, it’s common to Instantiate a prefab and immediately call GetComponent<T>() to modify or configure a component. This pattern is popular for initializing scripts or physics behaviors right after spawning an object. In T#, this only works under a specific condition.

GameObject obj = Instantiate(prefab);
Rigidbody rb = obj.GetComponent<Rigidbody>(); // ❌ Not supported as-is

πŸ” What you instead need to do in T# to get a component after Instantiate: Use the non-generic version of GetComponent with typeof and an explicit cast.

GameObject obj = Instantiate(prefab);
Rigidbody rb = (Rigidbody)obj.GetComponent(typeof(Rigidbody)); // βœ… Works only if "Awake Init" is ON

⏳ Coroutines in Start

In Unity, you can define Start() as a coroutine (IEnumerator) to handle initialization steps with delays or wait conditions. This pattern is not supported in T#.

Enumerator Start() {
    yield return new WaitForSeconds(1); // Waits before continuing
}

πŸ” What you instead need to do in T# to use coroutines at startup: Use a regular void Start() method and trigger a coroutine from there.

void Start() {
    StartCoroutine(MyCoroutine());
}

IEnumerator MyCoroutine() {
    yield return new WaitForSeconds(1); // βœ… Works
    // Your code here
}

⚑ Unity Events as Coroutines

In Unity, developers sometimes write event callbacks (like OnCollisionEnter) as coroutines to introduce delays directly within the event flow. This technique is not supported in T#.

IEnumerator OnCollisionEnter(Collision collision) {
    yield return new WaitForSeconds(1);
    // Continue logic
}

πŸ” What you instead need to do in T# to delay event-based logic: Instead, use a normal event method and start a coroutine from it.

void OnCollisionEnter(Collision collision) {
    StartCoroutine(CollisionCoroutine(collision)); // βœ… Works
}

IEnumerator CollisionCoroutine(Collision collision) {
    yield return new WaitForSeconds(1);
    // Your delayed logic here
}

⏲️ Invoke Methods

Unity provides Invoke() and InvokeRepeating() to call methods after a delay or repeatedly without needing coroutines. These are not supported in T#.

Invoke("MethodName", 2.0f);
InvokeRepeating("MethodName", 0f, 1.0f);

πŸ” What you instead need to do in T#: Use coroutines to delay method calls.

StartCoroutine(InvokeWithDelay());

IEnumerator InvokeWithDelay() {
    yield return new WaitForSeconds(2.0f);
    MethodName();
}

Last updated