UGTK cat mascotUGTKengine within an engine Request access

UGTK / Toolkit / Utility Systems / Copy Paste System Completed

Utility Systems — UGTK

Copy Paste System

Summary

Two complementary tools: a [CopyPaste] inspector attribute that adds Copy / Paste / Clear buttons to string, int, float and list fields, and an Mn_ClipboardVariableCopier component that copies any selected runtime variable value to the OS clipboard in Play Mode.


Content


Modules Dependencies

This module has no hard UGTK dependencies.


Setup

There is no prefab to drop: the module is an inspector attribute plus one component, so there is nothing meaningful to record.

Inspector attribute: add [CopyPaste] before a string, int, float, or List<> field to get Copy / Paste / Clear buttons in the Inspector. Combine with [ReadOnlyInInspector] to keep the field visible but non-editable (Copy still works; Paste and Clear are disabled).

Runtime copier: add the Mn_ClipboardVariableCopier component, assign a Target Object (GameObject, MonoBehaviour, or ScriptableObject), then pick the component/variable via the custom editor dropdown (nested field.subField paths are supported).


How To Use

Attribute:

using System.Collections.Generic;
using UnityEngine;
using UGTK.UtilitySystems.CopyPasteSystem;

public class Example : MonoBehaviour
{
    [CopyPaste, ReadOnlyInInspector] public string readOnlyString;
    [CopyPaste] public int exampleInt;
    [CopyPaste] public List<float> floatList; // lists serialize as comma-separated values
}

Runtime copier: wire a UI Button's OnClick to Mn_ClipboardVariableCopier.CopySelectedVariableToClipboardButton() (or call CopySelectedVariableToClipboard(), which returns a bool). It reads the selected variable by reflection and writes its ToString() to GUIUtility.systemCopyBuffer. Copying only works in Play Mode; edit-mode calls log a warning.


Testing Scene

Open Debug/CopyPasteScene.unity. The object ExampleObject carries Mn_CopyPasteExample, a handful of fields marked with [CopyPaste], and Mn_ClipboardVariableCopier. Everything happens in the Inspector, with no play mode.

Each decorated field grows three buttons of its own:

  1. Type something into Another Example String and press Copy. Note what happens to the other fields' Paste buttons — they become enabled, because the clipboard now holds a value.
  2. Clear empties the field.
  3. Paste puts it back.
  4. The same three work on Example Int: copy 42, clear it to 0, paste it back.

Two details the scene makes visible. Example String is greyed out: it carries [ReadOnlyInInspector] alongside [CopyPaste], so it can be copied but not edited — which is the combination you want on a generated id or a resolved URL. And the clipboard is the system clipboard, not an internal buffer: what you copy here can be pasted into a browser, a terminal or a PHP file, which is the whole reason the attribute exists.

Mn_ClipboardVariableCopier below does the same at runtime rather than from the Inspector: point it at a target object, pick the field from Path, and a button in the game copies its live value. Rebuild Dropdown Cache refreshes that list after you add fields to the target.


Technical Info


© 2026 Marcello De Bonis. All rights reserved

Real dependenciesOpen in the map →

Measured from the repository: code references (asmdef) plus prefab and asset GUIDs. Importing this module alone brings in 0 modules in total.