Rotorz Tile System Icon
Rotorz Tile System for Unity
API Reference
Available on the Unity Asset Store
TOC

WillEraseTile Event

Occurs when a tile will be erased. This event should not be used to paint new tiles.
public static event WillEraseTileEventHandler WillEraseTile
public static event WillEraseTile : WillEraseTileEventHandler

Value

Remarks

This event can be consumed by both editor and runtime scripts to take action immediately before a tile is erased.

Do not forget to remove event handlers when they are no longer required to avoid memory related issues.

Examples

using Rotorz.Tile;
using UnityEngine;

public class ExampleBehaviour : MonoBehaviour {

    private void Awake() {
        PaintingUtility.WillEraseTile += OnWillEraseTile;
    }

    private void OnDestroy() {
        PaintingUtility.WillEraseTile -= OnWillEraseTile;
    }

    private void OnWillEraseTile(WillEraseTileEventArgs args) {
        Debug.Log("Will erase tile at index: " + args.TileIndex);
    }

}
// Assets/ExampleBehaviour.js
#pragma strict
import Rotorz.Tile;

function Awake() {
    PaintingUtility.WillEraseTile += OnWillEraseTile;
}

function OnDestroy() {
    PaintingUtility.WillEraseTile -= OnWillEraseTile;
}

function OnWillEraseTile(args:WillEraseTileEventArgs) {
    Debug.Log("Will erase tile at index: " + args.TileIndex);
}

This event can also be utilised by custom editor scripts:

using Rotorz.Tile;
using UnityEditor;
using UnityEngine;

[InitializeOnLoad]
static class MyCustomEditor {

    static MyCustomEditor() {
        PaintingUtility.WillEraseTile += OnWillEraseTile;
    }

    private static void OnWillEraseTile(WillEraseTileEventArgs args) {
        Debug.Log("Will erase tile at index: " + args.TileIndex);
    }

}
#pragma strict
import Rotorz.Tile;

@InitializeOnLoad
class MyCustomEditor {

    static function MyCustomEditor() {
        PaintingUtility.WillEraseTile += OnWillEraseTile;
    }

    static function OnWillEraseTile(args:WillEraseTileEventArgs) {
        Debug.Log("Will erase tile at index " + args.TileIndex);
    }

}

See Also

Reference