bug with gameobject.Setactive(true). it only runs if GameObject is active in Inpector

You can try this.
my question is that. Is it part of architecture of unity or a bug?
gameobject.SetActive(true); work only when the gameobject is active at start of game.

      void Start () {
	gameObject.SetActive (false);
}


public void GameEnded(){
	gameObject.SetActive (true); // runs only if gameobject is active in Inspector
        
}

Mavina is correct here. The problem stems from the fact that, when an object is inactive, the script to reactivate it is also inactive. Therefore it can’t call itself to make itself active again etc. The best way to do it would be to attach something like this on your end-game object(s):

public GameObject yourItem;

//On the item(s) that end the game/scene

yourItem.SetActive(true);