protected ComponentBase(VisualElement container) { _container = container; if (_path == null) { var path = new System.Diagnostics.StackTrace(true) .GetFrame(1) .GetFileName() ?.Replace("\\", "/"); if (path.Contains("/PackageCache/")) { var parts = path.Split(new string[] { "/Editor/" }, StringSplitOptions.None); _path = $"{AssetPath.BasePath}com.fluid.unique-id/Editor/{parts[1]}" .Replace(".cs", ".uxml"); } else { var strings = path.Split(new string[] { "/Assets/" }, StringSplitOptions.None); _path = $"{AssetPath.BasePath}/{strings[1]}" .Replace(".cs", ".uxml"); } } var markup = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>(_path); markup.CloneTree(container); }
public static string GetStackTrace(string indent) { #if SILVERLIGHT var trace = new System.Diagnostics.StackTrace().ToString(); #elif PORTABLE var trace = new StackTrace().ToString(); #else var skipCount = new System.Diagnostics.StackTrace().GetFrames().TakeWhile(frame => frame.GetMethod().DeclaringType.Assembly == typeof(DebugView).Assembly).Count(); var trace = new System.Diagnostics.StackTrace(skipCount, true).ToString(); #endif return("\n".Join(trace .Split('\n') .Select(p => indent + p.Trim()))); }
public static string GetStackTrace(string indent) { #if SILVERLIGHT var trace = new System.Diagnostics.StackTrace().ToString(); #elif PORTABLE var trace = new StackTrace().ToString(); #else var skipCount = new System.Diagnostics.StackTrace().GetFrames().TakeWhile(frame => frame.GetMethod().DeclaringType.Assembly == typeof(DebugView).Assembly).Count(); var trace = new System.Diagnostics.StackTrace(skipCount, true).ToString(); #endif return "\n".Join(trace .Split('\n') .Select(p => indent + p.Trim())); }