I'm making a menu for a game in unity. I have created text and buttons which have functions that open panels with more options in the menu. For example, click on the options button and a new box will appear, which has been hidden by unticking the box in the top left of inspector of that object and using the setActive boolean, on click to activate it during run time.
The program works perfectly. However, if I want to edit the object that is hidden when editing the menu in unity, I have to tick the box top left in the inspector to therefore see it. This is only a minor problem however, if I want to run the program to check for errors I need to find each and every object that has to be unticked again.
Is there a way of seeing that object without me re-ticking the box in the editor of unity as I can see mistakes being made as I implement more boxes?
In the void Start() you should deactivate that UI:
void Start()
{
text1.setActive(false);
img2.setActive(false);
//and so on
}
In this way, you can have all objects activated in the scene when you are trying or modifying them it will not cause problems at the start of the program.
Related
I have watched a few tutorials on adding OnClick events to buttons in UI panels and they all have a panel in the button section where you can add a scrip to the on click event.
However, in my panel all I have is an expandable list that shows Persistent calls with no option to add any script (image for reference)
My Panel, with no option to add a script to OnClick Events
Your Inspector is in Debug mode which exposes all fields without applying any property drawers and editor scripts!
See Unity Manual - Inspector → Toggle Debug Mode (bottom section)
Toggling Debug Mode
Normally, the Inspector window is configured as an editor for the selection’s properties. But sometimes it’s useful to only see the properties and their values. When you activate Debug mode, the Inspector shows only the properties and their values. If the selection has script components, Debug mode also displays private variables, although you can’t edit their values
You can toggle Debug mode for each Inspector window individually.
To turn on Debug mode, click the More Items ⋮ button to open the context menu, and select Debug.
To return to Normal mode, click the More Items ⋮ button to open the context menu, and select Normal.
In theory you could still add elements to the Persistent Calls list by editing the size value ... but really just switch back to normal mode ;)
Usually you can click on an UI element (which is placed inside the canvas) in editor mode and the clicked element highlighted in the project hierarchy and you can see its properties in inspector. And it works this way if I create a new project.
But in my current project I can't click on any elemnt in canvas in editor mode because it's not responsive.
For example I have a button, I can click on it in Play mode, but it's not responsive in Editor mode. I mean if I click on it in editor mode nothing occurs (there is no highlighted object appears in hierarchy and I need to searching for this button in hierarchy by myself to open its properties in inspector)
This is incredibly annoying me.
Here is my button inside the canvas
Here is the button settings
Here is the canvas settings
Here is the event system settings:
Gizmos option need to be active
I want to make a prefab of UI Button with it's text. I created a prefabs folder and when I drag my button to the project's prefabs folder, I can't see the text as shown in the tutorial I'm following. I want to change the text of every button I created that is connected to that prefab.
I don't know what tutorial you are watching but it seems to be for an older Unity Version.
I can see you are using Unity 2019 and back in Unity 2018.3 they added Nested Prefabs. Also see the Prefab Manuals.
They work a bit differently now.
You don't directly edit Prefabs anymore but rather either double-click it in the ProjectView or in the Hierachy click on the little arrow > next to it in order to enter the Prefab Mode or since you already selected it in the ProjectView simply hit Open Prefab in the Inspector
This opens your prefab as if it would be a Scene in the hierachy and now you can edit everything in it.
Alternatively simply make your changes in one of the instances in the Hierachy (current Scene) and then apply them back to the prefab as explained in Editing a Prefab via its instances
either for each changed property via right-click
or for all proerties of the entire component via the Override dropdown ont he top-right
This is as its intended to work, in order to see insides of a prefab either open it in the editor or place on scene
I'm trying to open up a game demo from my class to see what it looks like, but after opening up the project in Unity, going to the "Game" tab on the upper part of the screen, and pressing "play", nothing shows up. I'm new to Unity so I have no idea why the screen is blank (there should be a title screen that says "Traffic Jam" and a play button). I'll attach a screenshot of my workspace below.
Note: I read somewhere about changing the "Layout" dropdown option in the upper right corner to "Default", but even if I do that, the title screen doesn't show up correctly.
Here is a link to the project if you want to try it out yourself:
https://drive.google.com/file/d/1ekXt948b612dmyT1AZReUOuzh2XbnSDG/view?usp=sharing
UPDATE: I've now opened the scene and have all the objects displayed, however some things still don't seem to be quite right. The title of the game is not shown when it should be and although the "play" button is shown, clicking on it doesn't get the game started as it should.
You should open the scene you are highlighting, by double clicking. You can also open the unity project by double clicking the scene directly from windows explorer.
When unity has opened that scene, this is what you will see.
And this will then be your game view:
This is what happens when I click play and die.
After opening a Unity project, ensure you are also opening the correct Unity Scene.
Most Unity project usually contains multiple Scene files which will have different contents.
I can see in your Project tab that you have a Unity scene file which is not currently open, if you double click this it should take you to your scene.
I can tell that this is not open as the Hierarchy would show the name of the currently open scene instead of 'Untitled'.
If this file does not contain the items you are looking for you should check other folder in your project for Unity scene files (did you save it as something else?)
I have a UI system I built for the game. In editor, it works perfectly. But when the game is compiled to an executable and ran, the initial menu text will be invisible unless I switch to a sub menu and switch back
Conversely, the text in a sub menu will disappear whenever I switch quality level using a button. It comes back if I switch menus. Any ideas as to why this is happening?
Menu before clicking Quality Level
Menu after clicking Quality Level