[DragConverter]

Attribute used for declaring a drag-and-drop value converter.

Drag converters are used when you drag a value onto a field of a different type. If a converter exists for the pair of types, Apex can convert the dragged value and apply it to the target field.

Support Types

Type
Description

Method

Static conversion method.

Parameters

This attribute has no parameters.

Requirements

A method marked with [DragConverter] must follow these rules:

  • Must be static.

  • Must return bool.

  • Must have exactly two parameters:

    • The first parameter is the input value (TFrom).

    • The second parameter is an out parameter (out TTo) where the converted value is written.

  • TFrom and TTo must be different types.

Examples

using RenownedGames.ApexEditor;
using UnityEngine;

public static class MyDragConverters
{
    [DragConverter]
    public static bool Vector3ToVector2(Vector3 value, out Vector2 result)
    {
        result = new Vector2(value.x, value.y);
        return true;
    }
}

Last updated