Runtime context menu og sidebar with buttons

Hi

We need to have either a context menu or a sidebar with buttons for our product.

As as quick’n’dirty solution for a unity-noobish dev, how would I do that when it has to work runtime?

Just to be completely clear: This is NOT for use in the Unity Editor, but “in game”.

Just script the usual unity ui. Detect context click then spawn or unhide the menu and move it to the right spot. You can animate sliding in/out by controlling UI position.

Thanks for your reply, but we need to go several steps back here. :smile:

I know how to handle clicks, but I have no knowledge on how to make any “windows” in unity…

With uGui.

You make a canvas.
Place a panel there, set its anchors and position.
Place buttons for it as childre.

That’s a window.
If you want it to support drag, you script it.
If you want it to support resizing, you script resizing, and design UI with Vertical/Horizontal layout groups.

Alternatively you can make UI out of sprites. Whichever is easier for you.

Hmm, well, I’ve made a canvas, but it’s HUUUUGE and I can’t change the size?

How do I do that?

You don’t, change its size you go into 2d mode and edit it.

I’m fairly sure that unity ui has manual and tutorials Have you checked the documentation?
https://docs.unity3d.com/Packages/com.unity.ugui@1.0/manual/index.html

2 Likes

Sorry, I was too fast. :stuck_out_tongue: Yeah, I checked the docs and found a way to resize it, yay. :slight_smile:

And I’ve added a button - and made that small as well.

However the text “button” is still huge, and I can’t find a place to change it? And yes, I’ve checked the docs you linked. :wink:

Because the text would be on a game object that’s a child of the button with a text component on it.

1 Like

So it is! :smile:

Thanks! :slight_smile:

Hmm, so I’ve got the button and it’s text looking ok.

But the colors of the different states (normal, highlighted, pressed) doesn’t apply. Why is that?

Rather than asking for help with literally every step of the way, why not try and actually learn how to use the UI system first before tackling this? You clearly need to go through some tutorials, instead of expecting to be handheld the entire way

https://learn.unity.com/tutorial/ui-components

https://www.raywenderlich.com/6570-introduction-to-unity-ui-part-1

Google “Unity UI tutorial” and that will give you tons of results.

Good luck :slight_smile:

4 Likes

While I agree that sounds best, sadly I don’t learn very well that way.

I need it to be specific for my project.

No one’s going to hold your hand every step of the way. That’s not the point of these forums. This is more or less basic stuff I learnt in month 1 of learning Unity.

There’s a million resources out there. Use them.

3 Likes

I’m not you.

I wasn’t aware the rules has changed?

Maybe you should read them again? Unity Community Code of Conduct - legacy

Im not sure what you are getting at by throwing the rules out randomly in this thread, but the fact that nobody is going to hand hold you also hasnt changed.

There is literally a rule about low effort in the link you provided - did you read the rules yourself before posting them?

2 Likes

Please read the code of conduct again, especially these:

You can find the proper topic here. Although the comment about you need to at least start to learn yourself still stands. If you need a tutor, hire one, the forum is not a tutor service. But if you put in the work and just stuck somewhere, you’re welcome to ask educated questions, we’re glad to help.

3 Likes

Closed, wrong forum and low effort.

4 Likes