Coder Social home page Coder Social logo

godot_extra_property_hints's Introduction

Extra Export Hints

Description

Add your own custom export editors using _get_property_info(property_name : String) -> Dictionary inside of custom_editors.gd.

@export var my_int : int
@export var my_float2 : float

func _get_property_info(prop : String):
	match prop:
		"my_int":
			return {
				"update_inspector": true
			}
		"my_float2":
			return {
				"visible": my_int > 0
			}
	pass

It's quicker than _get_property_list for simple cases, but both can be combined;

And it even has the ability to edit builtin properties. Try this:

func _get_property_info(prop : String):
	match prop:
		"rotation":
			return {
				"editor": "direction"
			}

Features

  • Use some of the builtin custom editors.
  • Add your own editors.
  • Make properties conditionally visible.
  • Make properties update the inspector when edited.

Builtin Hints

  • visible: If false, the property won't show in the inspector.

  • update_inspector: If present, the property will update the inspector when edited.
    Useful if this property updates the visibility status of another.

  • buttons: An array of Dictionarys that will be added as buttons.
    You must specify a property 'callback' for the button to work.
    This callback must take a single argument, which is the button you pressed.

    You can optionally specify 'label', 'visible' and 'color.'

  • warnings: An array of Dictionarys that will be added as labels.
    You must specify a property 'label' for the warning to work.

    You can optionally specify 'visible' and 'color.'

    An alternative to "warnings" is "rich_warnings", which will add a BBCode-enabled RichTextLabel.

Custom Editors

To make a property be handled by a custom editor.

return {
	"editor": <editor_name>
}
  • check_button This editor will make so booleans display a check button instead of a checkbox.

  • direction Will add a spinny slider you can use to edit angles.

    Under this editor, you can also specify:

      - return_type = TYPE_VECTOR2 or TYPE_FLOAT;
      
      - maximum_value = The length of your vector, or the maximum value of your float value;
      
      - segments = If bigger than 0, the editor will snaps to <segments> fractions of a whole turn;
    
  • fuzzy_search Will add a button and a new Window for searching entries to a large enum. It's much better than a gigantic option menu popup.

    • If specified, "items" is an optional property it'll read from to determine the contents of the enum;

    • If specified, "editor_icon" will allow setting an icon to the picker's button;

Tips

To change an editor for every property of an object, you can use the default case of the match statement.

Additionally, you can do some type checking.

# Display all boolean properties as check buttons.
func _get_property_info(prop : String):
	match prop:
		_:
			var plist := get_property_list()
			for i in plist:
				if i.name == prop and i.type == TYPE_BOOL:
					return {
						"editor": "check_button"
					}

godot_extra_property_hints's People

Contributors

mrpedrobraga avatar

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.