Files
CartoonFPS/Library/PackageCache/com.unity.ugui@a0f5d16b3c82/Tests/Runtime/UGUI/Util/ExceptionUtils.cs
SHOUTING_PIRATE 4c8592d0ab initial commit
2025-08-05 09:30:40 +01:00

22 lines
673 B
C#

using System;
using System.Runtime.Serialization;
namespace UnityEngine.UI.Tests.Utils
{
class ExceptionUtils
{
public static void PreserveStackTrace(Exception e)
{
var ctx = new StreamingContext(StreamingContextStates.CrossAppDomain);
var mgr = new ObjectManager(null, ctx);
var si = new SerializationInfo(e.GetType(), new FormatterConverter());
e.GetObjectData(si, ctx);
mgr.RegisterObject(e, 1, si); // prepare for SetObjectData
mgr.DoFixups(); // ObjectManager calls SetObjectData
// voila, e is unmodified save for _remoteStackTraceString
}
}
}