Initial commit
This commit is contained in:
25
Assets/Scripts/Penghapus.cs
Normal file
25
Assets/Scripts/Penghapus.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
public class Penghapus : MonoBehaviour
|
||||
{
|
||||
void Start()
|
||||
{
|
||||
string currentScene = SceneManager.GetActiveScene().name;
|
||||
|
||||
// Hapus canvas & EventSystem yang BUKAN dari scene aktif
|
||||
foreach (GameObject go in Object.FindObjectsByType<GameObject>(FindObjectsSortMode.None))
|
||||
{
|
||||
if (!go.scene.name.Equals(currentScene))
|
||||
{
|
||||
if (go.GetComponent<Canvas>() || go.GetComponent<EventSystem>())
|
||||
{
|
||||
Debug.Log("Destroy leftover UI: " + go.name);
|
||||
Destroy(go);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user