O'Reilly logo

Extending Unity with Editor Scripting by Angelo Tadres

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Integrating the Palette with the Level Creator tool

In this section, we will create an event that will be triggered every time you select a piece in the Palette and captured by the Level inspector. This feature will be used in the next chapter.

Creating an event

An event in C# is a way for a class to provide notifications when something happens to an object.

In this case, we will add an event when the user selects one of the pieces from the Palette. To achieve this, we we will add the following lines of code to the PalleteWindow.cs script:

public delegate void itemSelectedDelegate (PaletteItem item,Texture2D preview);
public static event itemSelectedDelegate ItemSelectedEvent;

The delegate type defines the signature for the method that handles the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required