I cannot activate the scripts attached to an empty gameobject.
I wanted to check a simple Canvases flow in my maingamemanager.cs. I thus commented out the cardmanagar and playermanager snippets from the script.
Doing so, the activate box of the scripts components for cardmanager and playermanger disappeared.
After testing, I uncommented the related references but the script components remain hidden. I closed and open unity hub, I deleted the library to remove all cache, I reimported all. The activate boxes are still missing.
If I create a new project, I can overcome this issue. Yet, this isn’t the first time it happens to me. It would be nice the know how to handle it, besides activating the nuclear option.
Any advice would be highly appreciated.
PS - in case it’s relevant, here’s the script.
The cardmanager and playermanager were executed as expected. All references are properly assigned.
using System.Collections;
using UnityEngine;
public class MainGameManager : MonoBehaviour
{
public Canvas setupCanvas;
public Canvas gameUICanvas;
public Canvas endgameCanvas;
//I commented and uncommented these references
public PlayerManager playerManager; // Reference to the PlayerManager script
public CardManager cardManager; // Reference to the CardManager script
private bool isPlayersGenerated = false;
private bool isCardsGenerated = false;
private void Start()
{
StartCoroutine(GameFlow());
}
private IEnumerator GameFlow()
{
Debug.Log("GameFlow started");
// Start PlayerManager and CardManager through their wrapper methods
playerManager.StartGeneratePlayers();
cardManager.StartGenerateCards();
// Wait until both managers have completed their tasks
yield return new WaitUntil(() => isPlayersGenerated && isCardsGenerated);
Debug.Log("Players and Cards generated");
// Distribute cards to players after cards are generated
//cardManager.DistributeCards();
// Show canvases
yield return StartCoroutine(ShowCanvasForDuration(setupCanvas, 4f));
yield return StartCoroutine(ShowCanvasForDuration(gameUICanvas, 4f));
yield return StartCoroutine(ShowCanvasForDuration(endgameCanvas, 4f));
// Automatically transition to the next scene or perform other actions here.
}
// Set this method to be called by the PlayerManager when players are generated
public void OnPlayersGenerated()
{
Debug.Log("Players generated!");
isPlayersGenerated = true;
}
// Set this method to be called by the CardManager when cards are generated
public void OnCardsGenerated()
{
Debug.Log("Cards generated!");
isCardsGenerated = true;
}
private IEnumerator ShowCanvasForDuration(Canvas canvas, float duration)
{
// Deactivate other canvases
setupCanvas.gameObject.SetActive(false);
gameUICanvas.gameObject.SetActive(false);
endgameCanvas.gameObject.SetActive(false);
// Activate the current canvas
canvas.gameObject.SetActive(true);
// Wait for the specified duration
yield return new WaitForSeconds(duration);
// Deactivate the current canvas
canvas.gameObject.SetActive(false);
}
}