RPG Character Profile Menu Toggle On and Off

I am building an RPG and for it I’ve made a set of character profile menus: Stats, Items, Equipment, Skills, etc. Currently, I have each menu gui in its own scene. I see a fault with this design because if my player hits a button to open up one of the menus, it would have to call Application.LoadLevel() in order to call up the menu. This will destroy all the objects in the game scene. Then when the player closes the menu to return to the game scene, all the objects in the game scene will have to be recreated and the enemy that was closing in on the player before the menu was opened will now be respawned back at its spawnpoint. A way around that problem could be to cause every single object to not be destroyed during scene transitions, but that would bog down the game’s performance (I would think). A better solution would be to bring up the menu from within the game scene without having to use Application.LoadLevel(). I have tried to do this, but I’m failing big time. The way I’ve built the gui menu is by creating a bunch of gui textures and gui text objects and grouped them together as children of empty objects in the hierarchy pane. I have added one of these menus to a game scene and disabled it so that it doesn’t appear overtop of the game while it’s playing. I have added code that pauses the game and in that code, I’d like to add a line that re-enables the gui menu, but calling gameObject.enable = true isn’t working for me. How can I make this work? Is this even the best approach?

you could use a GUI.window and make the window to fill the whole screen instead.

var position = Rect(10, 10, 10, 10); //your button position;

var toggle = false;

var windowRect = Rect(10, 10, 500, 300); //your stats window position

function OnGUI() {
if (GUI.Button(position, “ViewStats”) {
toggle = true;
}
if (toggle) {
windowRect = GUI.Window (0, windowRect, DoMyWindow, “My Window”);
}

// Make the contents of the window
function DoMyWindow (windowID : int) {
GUI.Label…
}

helpful link : Unity - Scripting API: GUI.Window

I understand your response, and I’ve thought about doing something like that, I’m wondering how to use that approach without hours of rework. In DoMyWindow() in your example, you show building all the guis dynamically. The problem with the way I’ve built my menu screens is that they are not created strictly by code. They are objects that already exist in the hierarchy pane and I just need to be able to enable and disable them from code. Problem is, I can’t just call Menu.enabled = false and Menu.enabled = true like I think I should be able to do. Is there a work around for that? Otherwise, I’ll have to redo all the menus from scratch. That will take about 8 to 12 hours to do since I had to spend gobs of time tweaking the positioning and layout of everything.

Thanks