MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / OnCopyValue

Method OnCopyValue

Source/Editor/Surface/Elements/InputBox.cs:1570–1610  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1568 }
1569
1570 private void OnCopyValue()
1571 {
1572 var value = Value;
1573 try
1574 {
1575 string text;
1576 if (value == null)
1577 {
1578 // Missing value
1579 var type = CurrentType;
1580 if (type.Type == typeof(bool))
1581 text = "false";
1582 else if (type.Type == typeof(byte) || type.Type == typeof(sbyte) || type.Type == typeof(char) || type.Type == typeof(short) || type.Type == typeof(ushort) || type.Type == typeof(int) || type.Type == typeof(uint) || type.Type == typeof(long) || type.Type == typeof(ulong))
1583 text = "0";
1584 else if (type.Type == typeof(float) || type.Type == typeof(double))
1585 text = "0.0";
1586 else if (type.Type == typeof(Vector2) || type.Type == typeof(Vector3) || type.Type == typeof(Vector4) || type.Type == typeof(Color))
1587 text = JsonSerializer.Serialize(TypeUtils.GetDefaultValue(type));
1588 else if (type.Type == typeof(string))
1589 text = "";
1590 else
1591 text = "null";
1592 }
1593 else if (value is FlaxEngine.Object asObject)
1594 {
1595 // Object reference
1596 text = JsonSerializer.GetStringID(asObject);
1597 }
1598 else
1599 {
1600 // Default
1601 text = JsonSerializer.Serialize(value);
1602 }
1603 Clipboard.Text = text;
1604 }
1605 catch (Exception ex)
1606 {
1607 Editor.LogWarning(ex);
1608 Editor.LogError("Cannot copy property. See log for more info.");
1609 }
1610 }
1611
1612 private void OnPasteValue()
1613 {

Callers

nothing calls this directly

Calls 5

GetStringIDMethod · 0.80
SerializeMethod · 0.45
GetDefaultValueMethod · 0.45
LogWarningMethod · 0.45
LogErrorMethod · 0.45

Tested by

no test coverage detected