UGTK / Toolkit / Utility Systems / Copy Paste System Completed
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:
- 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.
- Clear empties the field.
- Paste puts it back.
- 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
- CopyPasteAttribute: Marker
PropertyAttributeflagging a field for the Copy/Paste/Clear drawer. - ReadOnlyInInspectorAttribute: Marker attribute that makes the field non-editable while still showing the buttons.
- CopyPastePropertyDrawer: Editor
PropertyDrawerthat renders the field plus Copy/Paste/Clear buttons for string, int, float and array/list types, serializing lists as comma-separated strings viasystemCopyBuffer. - Mn_ClipboardVariableCopier: Runtime MonoBehaviour that resolves a (possibly nested) variable path on a target MonoBehaviour/ScriptableObject through reflection and copies its value to the OS clipboard in Play Mode.
- ClipboardVariableCopierEditor: Custom inspector providing the target/component/variable selection dropdowns for
Mn_ClipboardVariableCopier.
© 2026 Marcello De Bonis. All rights reserved
Depends on 0
- Standalone: no other module required.
Measured from the repository: code references (asmdef) plus prefab and asset GUIDs. Importing this module alone brings in 0 modules in total.
UGTKengine within an engine


