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

TilePainted Event

Occurs when a tile is painted using a brush.
public static event TilePaintedEventHandler TilePainted
public static event TilePainted : TilePaintedEventHandler

Value

Remarks

This event can be consumed by both editor and runtime scripts to post process tiles as they are painted. This event occurs for each tile that is painted, cycled or refreshed.

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

Examples

The following example demonstrates how the game objects of painted tiles can be rotated towards a particular point in world space.

using Rotorz.Tile;
using UnityEngine;

public class ExampleBehaviour : MonoBehaviour {

    private void Awake() {
        PaintingUtility.TilePainted += OnTilePainted;
    }

    private void OnDestroy() {
        PaintingUtility.TilePainted -= OnTilePainted;
    }

    private void OnTilePainted(TilePaintedEventArgs args) {
        // Tile might not have a game object attached!
        if (args.GameObject != null)
            args.GameObject.transform.LookAt(Vector3.zero);
    }

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

function Awake() {
    PaintingUtility.TilePainted += OnTilePainted;
}

function OnDestroy() {
    PaintingUtility.TilePainted -= OnTilePainted;
}

function OnTilePainted(args:TilePaintedEventArgs) {
    // Tile might not have a game object attached!
    if (args.GameObject != null)
        args.GameObject.transform.LookAt(Vector3.zero);
}

This event can also be utilised by custom editor scripts:

using Rotorz.Tile;
using UnityEditor;
using UnityEngine;

[InitializeOnLoad]
static class MyCustomEditor {

    static MyCustomEditor() {
        PaintingUtility.TilePainted += OnTilePainted;
    }

    private static void OnTilePainted(TilePaintedEventArgs args) {
        // Tile might not have a game object attached!
        if (args.GameObject != null)
            args.GameObject.transform.LookAt(Vector3.zero);
    }

}
#pragma strict
import Rotorz.Tile;

@InitializeOnLoad
class MyCustomEditor {

    static function MyCustomEditor() {
        PaintingUtility.TilePainted += OnTilePainted;
    }

    static function OnTilePainted(args:TilePaintedEventArgs) {
        // Tile might not have a game object attached!
        if (args.GameObject != null)
            args.GameObject.transform.LookAt(Vector3.zero);
    }

}

See Also

Reference