Coder Social home page Coder Social logo

tavurth / godot-radial-menu Goto Github PK

View Code? Open in Web Editor NEW
252.0 7.0 16.0 1.18 MB

A radial menu for Godot, supports Mobile & Desktop

Home Page: https://godotengine.org/asset-library/asset/1885

License: MIT License

GDScript 100.00%
godot radial menu ui-components

godot-radial-menu's Introduction

Table of Contents

  1. Godot Radial Menu
    1. Setup
    2. Supported signals
    3. Supported controls
      1. Center Node
      2. Width max
      3. Width min
      4. Cursor size
      5. Cursor deg
      6. Color BG
      7. Color FG
      8. Bevel Enabled
      9. Bevel Color
      10. Bevel Width
      11. Modulate Enabled
      12. Modulate Color
      13. Modulate Width

Godot Radial Menu

img img img img

I created this Radial Menu as an addon for a few of my projects.

The rendering of the menu is primarily done through shader code and so should be pretty performant.

radial-menu.mov

Setup

img

func _ready():
    $RadialMenu.connect("selected", self, "_on_selected")

func _input(event: InputEvent):
    if event is InputEventScreenTouch:
        $RadialMenu.set_visible(event.pressed)

func _on_selected(child: Node):
    prints("Child was selected:", child)

Supported signals

hovered(child) Emitted when a button or child is hovered

selected(child) Emitted when a button or child is selected

Supported controls

img

Snapped

set_snap_enabled(true | false)

Should the cursor snap to the individual buttons?

Center Node

set_center_node(Node)

Controls display in center of the spinner

Width max

set_width_max(Float)

  • Minimum: 0
  • Maximum: 1

The outside edge size of the spinner

Width min

set_width_min(Float)

  • Minimum: 0
  • Maximum: 1

The inside edge size of the spinner

Cursor size

set_cursor_size(Float)

  • Minimum: 0
  • Maximum: +ve PI

The size of the radial arc (blue portion)

Cursor deg

set_cursor_deg(Float)

  • Minimum: -ve PI
  • Maximum: +ve PI

The starting degree of the cursor (will update with mouse or touch events)

Color BG

set_color_bg(Color)

Background color of the radial (supports RGBA)

Color FG

set_color_fg(Color)

Foreground color of the radial (supports RGBA)

Bevel Enabled

set_bevel_enabled(bool)

Should a bevel be present on the edges of the modal

Bevel Color

set_bevel_color(Color)

What color should the bevel be (if present)

Bevel Width

set_bevel_width(float)

What should the width of the bevel be (if present)

Modulate enabled

set_modulate_enabled(bool)

If enabled, buttons will be automatically modulated to the colors selected when hovered and unhovered

Modulate hover

set_modulate_hover(Color)

Color modulation to be applied to each button (or control) when it's hovered. This is only applied i modulate_enabled is true

Modulate default

set_modulate_default(Color)

Color modulation to be applied to each button (or control) in it's default state. This is only applied i modulate_enabled is true

Support

Buy Me A Coffee

godot-radial-menu's People

Contributors

cridenour avatar iceflowre avatar tavurth avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

godot-radial-menu's Issues

Minimun items supported 6?

Hello, thank you a lot for this addon, I know this is no a continued addon, but can you please help me with this issue?

You can see this issue just deleting 4 buttoms in your ExampleScene; It don´t select/hover on the right buttoms.

Edit: Also when you start the script or unhide the node, it dont module the first item hovering unless you hover in another item.

Child Button Selection

Kinda difficult to put my issue into words, so I attached a gif. Basically, I want the RadialMenu's child button(s) pressed signal to only be emitted when the mouse is directly over the child button, rather than just based on the angle the mouse is at. I'm not sure if there's a way around that.
2022-11-15_11h52_49

Issues if I scale the TextureButtons and with small numbers of options

Hi, I've spent some time today playing around with your radial menu and I encountered a couple problems.

The first happened when I tried to make the menu much smaller. Instead of creating smaller sprites for the TextureButtons, I just modified the scale in their control->rect properties. This caused the circle of buttons to offset from the selection circle. I resolved this by changing line 119 in RadialMenu.gd to button.get_size() * button.rect_scale / 2. I also changed line 129 to var corner_pos = Vector2(x, -y) - size.

These two changes seemed to work without issue.

The second problem came when I tried to reduce the number of options down to three. The selection when moving the mouse completely breaks. One of the three options isn't selectable at all and the other two are selected at incorrect positions. Similar is also true for other smaller numbers of options. I'm not sure if I'm doing something wrong, or if there is a bug in the code and I haven't been able to resolve this one. Any ideas?

Thanks!

Snap to each segment

Hi I was looking at your code,

Do you know how to make it is snap to each section and provide a line from the center to the cursor?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.