<commit_before># Editor Scripts

Sometimes you want to have an script running only in your editor to help you with some tasks.
You can use the Plugin system, and create Tools, but if you want to create something fast and simple the best way is to use the same scripting system from the LiteScene engine, the Script component.

You can create a regular component script but use some of the special editor events:

- ```onEditorRender```: to render gizmos
- ```onEditorRenderGUI```: to render 2D stuff
- ```onEditorEvent```: to catch events on the interface

## Example

```js
//@Line Editor
//defined: component, node, scene, transform, globals


private var points = [];

var active = false;
var selected = -1;

this.onEditorRenderGUI = function()
{
	var ctx = gl;
  active = LS.GUI.Toggle([30,60,260,40], active, "Edit Points: " + (active ? "On": "Off") );
  if( LS.GUI.Button([30,100,260,40], "Clear" ) )
    this.points.length = 0;
}

this.onRender = function()
{<commit_msg>Update editor_scripts.md<commit_after># Editor Scripts

Sometimes you want to have an script running only in your editor to help you with some tasks.
You can use the Plugin system, and create Tools, but if you want to create something fast and simple the best way is to use the same scripting system from the LiteScene engine, the Script component.

You can create a regular component script but use some of the special editor events:

- ```onEditorRender```: to render gizmos
- ```onEditorRenderGUI```: to render 2D stuff
- ```onEditorEvent```: to catch events on the interface

## Interface

Probably your script will require some widgets, to add widgets to your component script that display in the inspector you must use the method ```onInspector```.

```js
this.onInspector = function(inspector)
{
	inspector.addInfo(null, "Num. Points: " + this.points.length );
	inspector.addButton("Clear points", "Clear", { callback: this.clearPoints.bind(this) } );
}
```

For more info about the ```LiteGUI.Inspector``` [check the guide in LiteGUI](https://github.com/jagenjo/litegui.js/blob/master/guides/inspector.md).

## Example

```js
//@Line Editor
//defined: component, node, scene, transform, globals


private var points = [];

var active = false;
var selected = -1;

this.onInspector = function(inspector)
{
	inspector.addInfo(null, "Num. Points: " + this.points.length );
	inspector.addButton("Clear points", "Clear", { callback: this.clearPoints.bind(this) } );
}

this.onEditorRenderGUI = function()
{
	var ctx = gl;
  active = LS.GUI.Toggle([30,60,260,40], active, "Edit Points: " + (active ? "On": "Off") );
  if( LS.GUI.Button([30,100,260,40], "Clear" ) )
    this.points.length = 0;
}

this.onRender = function()
{
{'fraction_non_alphanumeric': 0.12541620421753608, 'fraction_numerical': 0.016278209396966333, 'mean_word_length': 4.495934959349594, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1426672', 'n_tokens_mistral': 868, 'n_tokens_neox': 818, 'n_words': 315}