I coded a script, that loads the “Death” scene, after I collide with the enemy, but when I switch to the “Death”
Scene after colliding, i cant do anything in that scene and i have no cursor. Has anyone got a solution?
This is my script to load the next scene:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class FinishScript : MonoBehaviour {
void OnTriggerEnter(Collider col)
{
if (col.gameObject.name == "Enemy")
{
SceneManager.LoadScene("Death");
}
}
}
There is tons of ways how you can do it you can for example set game object scale to 0,0,0 and then on trigger enter set it to 1,1,1 Just paste this into oyur script and call , FYI you can do this with any game component you want if you will edit it in same way, that is what are methods for
I would not do this… if you have any UI objects that implement Layout objects, they may suddenly get divide by zero values as they try to reposition and they may not restore themselves properly with scale (1,1,1).
In particular, a zero-Z scale will cause TextMeshPRO objects to completely lose their minds.
Just turn it off with .SetActive() on the root object already.
And how you do if inside ui will be constantly updating value but you want see it only sometimes?Local scale is working good for me, what otner option then set active you recomand?? Only check != null for that go help?
Why constantly update it when its invisible? Just unsubscribe from listeners in OnDisable() and resubscribe in OnEnable()… that’s how my entire Datasacks module works and it is extremely performant and slick. The instant something is re-enabled, it resubscribes and updates itself.
Either way, due to the inherited nature of scale and cascading transforms, as well as the TextMeshPRO calculations and Layout object reorganization calculations, changing the scale to zero is not a generally viable solution. It might work for a while but you use it at your peril, as it is subject to well-defined future malfunctions.
My entire UI was in Update methid then i changed to Courutine and looks like i will go for OnDisable thing now i had no idea something like this exists.