|
|
|
|
|
|
using UnityEngine; |
|
|
|
using Canvas = Unity.UIWidgets.ui.Canvas; |
|
|
|
using Color = Unity.UIWidgets.ui.Color; |
|
|
|
using Debug = System.Diagnostics.Debug; |
|
|
|
using Rect = Unity.UIWidgets.ui.Rect; |
|
|
|
using TextStyle = Unity.UIWidgets.painting.TextStyle; |
|
|
|
|
|
|
|
|
|
|
public static Color _kHighlightedRenderObjectBorderColor = Color.fromARGB(128, 64, 64, 128); |
|
|
|
|
|
|
|
bool _isDebugCreator(DiagnosticsNode node) => node is DiagnosticsDebugCreator; |
|
|
|
List<DiagnosticsNode> transformDebugCreator(IEnumerable<DiagnosticsNode> properties) { |
|
|
|
IEnumerable transformDebugCreator(IEnumerable<DiagnosticsNode> properties) { |
|
|
|
List<DiagnosticsNode> result = new List<DiagnosticsNode>(); |
|
|
|
List<DiagnosticsNode> pending = new List<DiagnosticsNode>(); |
|
|
|
bool foundStackTrace = false; |
|
|
|
|
|
|
_locationToId[location] = id; |
|
|
|
return id; |
|
|
|
} |
|
|
|
public List<DiagnosticsNode> _parseDiagnosticsNode(DiagnosticsNode node) { |
|
|
|
public IEnumerable _parseDiagnosticsNode(DiagnosticsNode node) { |
|
|
|
return _describeRelevantUserCode(element).ToList(); |
|
|
|
return _describeRelevantUserCode(element); |
|
|
|
} |
|
|
|
public IEnumerable<DiagnosticsNode> _describeRelevantUserCode(Element element) { |
|
|
|
if (!WidgetInspectorService.instance.isWidgetCreationTracked()) { |
|
|
|
|
|
|
), |
|
|
|
new ErrorSpacer() |
|
|
|
}; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
List<DiagnosticsNode> nodes = new List<DiagnosticsNode>(); |
|
|
|
|
|
|
layerOffset = layerOffset ?? Offset.zero; |
|
|
|
addChildrenToScene(builder, layerOffset); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class _SerializeConfig { |
|
|
|
public _SerializeConfig(string groupName, bool summaryTree = false, |
|
|
|
int subtreeDepth = 1, List<Diagnosticable> pathToInclude = null, |
|
|
|
bool includeProperties = false, bool expandPropertyValues = true) { |
|
|
|
this.groupName = groupName; |
|
|
|
this.summaryTree = summaryTree; |
|
|
|
this.subtreeDepth = subtreeDepth; |
|
|
|
this.pathToInclude = pathToInclude; |
|
|
|
this.includeProperties = includeProperties; |
|
|
|
this.expandPropertyValues = expandPropertyValues; |
|
|
|
} |
|
|
|
|
|
|
|
public static _SerializeConfig merge(_SerializeConfig from, int? subtreeDepth = null, |
|
|
|
List<Diagnosticable> pathToInclude = null) { |
|
|
|
return new _SerializeConfig(from.groupName, from.summaryTree, subtreeDepth ?? from.subtreeDepth, |
|
|
|
pathToInclude ?? from.pathToInclude, from.includeProperties, from.expandPropertyValues); |
|
|
|
} |
|
|
|
|
|
|
|
public readonly string groupName; |
|
|
|
public readonly bool summaryTree; |
|
|
|
public readonly int subtreeDepth; |
|
|
|
public readonly List<Diagnosticable> pathToInclude; |
|
|
|
public readonly bool includeProperties; |
|
|
|
public readonly bool expandPropertyValues; |
|
|
|
} |
|
|
|
|
|
|
|
public delegate void InspectorSelectionChangedCallback(); |
|
|
|
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
_InspectorReferenceData data; |
|
|
|
_idToReferenceData.TryGetValue(id, out data); |
|
|
|
_InspectorReferenceData data = _idToReferenceData.getOrDefault(id); |
|
|
|
throw new UIWidgetsError("Id does not exist."); |
|
|
|
throw new UIWidgetsError(new List<DiagnosticsNode>{new ErrorSummary("Id does not exist.")}); |
|
|
|
} |
|
|
|
|
|
|
|
return data.obj; |
|
|
|
|
|
|
if (ReferenceEquals(obj, selection.currentElement)) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
// [!!!] developer.inspect(selection.currentElement);
|
|
|
|
|
|
|
|
// [!!!] developer.inspect(selection.current);
|
|
|
|
} |
|
|
|
|
|
|
|
if (selectionChangedCallback != null) { |
|
|
|
|
|
|
else if (value is Element) |
|
|
|
path = _getElementParentChain((Element)value, groupName); |
|
|
|
else |
|
|
|
throw new UIWidgetsError($"Cannot get parent chain for node of type {value.GetType()}"); |
|
|
|
throw new UIWidgetsError(new List<DiagnosticsNode>{new ErrorSummary($"Cannot get parent chain for node of type {value.GetType()}")}); |
|
|
|
|
|
|
|
return path.Select( |
|
|
|
(_DiagnosticsPathNode node) => |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public List<DiagnosticsNode> _truncateNodes(IEnumerable<DiagnosticsNode>nodes, int maxDescendentsTruncatableNode) { |
|
|
|
int count = 0; |
|
|
|
foreach (var node in nodes) { |
|
|
|
if (node is DiagnosticsNode) { |
|
|
|
if (((DiagnosticsNode) node).value is Element) { |
|
|
|
count++; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
bool isElement = true; |
|
|
|
foreach (var node in nodes) { |
|
|
|
if (!(node.value is Element)) { |
|
|
|
isElement = false; |
|
|
|
break; |
|
|
|
} |
|
|
|
if (count == nodes.Count() && isWidgetCreationTracked()) { |
|
|
|
if (isElement && isWidgetCreationTracked()) { |
|
|
|
List<DiagnosticsNode> localNodes = nodes.Where((DiagnosticsNode node) => |
|
|
|
_isValueCreatedByLocalProject(node.value)).ToList(); |
|
|
|
if (localNodes.isNotEmpty()) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
results.Add(nodes.ToList()[i]); |
|
|
|
results.Add(nodes.ElementAt(i)); |
|
|
|
} |
|
|
|
return results; |
|
|
|
} |
|
|
|
|
|
|
public Dictionary<string, object> _getSelectedWidget(string previousSelectionId, string groupName) { |
|
|
|
DiagnosticsNode previousSelection = toObject(previousSelectionId) as DiagnosticsNode; |
|
|
|
Element current = selection?.currentElement; |
|
|
|
return _nodeToJson(current == previousSelection?.value ? previousSelection : current?.toDiagnosticsNode(), new InspectorSerializationDelegate(groupName: groupName, service: this)); |
|
|
|
return _nodeToJson(Equals(current, previousSelection?.value) ? previousSelection : current?.toDiagnosticsNode(), new InspectorSerializationDelegate(groupName: groupName, service: this)); |
|
|
|
} |
|
|
|
string getSelectedSummaryWidget(string previousSelectionId, string groupName) { |
|
|
|
return _safeJsonEncode(_getSelectedSummaryWidget(previousSelectionId, groupName)); |
|
|
|
|
|
|
} |
|
|
|
current = firstLocal; |
|
|
|
} |
|
|
|
return _nodeToJson(current == previousSelection?.value ? previousSelection : current?.toDiagnosticsNode(), new InspectorSerializationDelegate(groupName: groupName, service: this)); |
|
|
|
return _nodeToJson(Equals(current, previousSelection?.value) ? previousSelection : current?.toDiagnosticsNode(), new InspectorSerializationDelegate(groupName: groupName, service: this)); |
|
|
|
} |
|
|
|
|
|
|
|
public bool isWidgetCreationTracked() { |
|
|
|
|
|
|
D.assert(foundTarget); |
|
|
|
return containerLayer.offset; |
|
|
|
} |
|
|
|
} |
|
|
|
public void SetScreenshotOffset(Offset offset) { |
|
|
|
containerLayer.offset = offset; |
|
|
|
set { |
|
|
|
containerLayer.offset = value; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
public class _ScreenshotPaintingContext : PaintingContext { |
|
|
|
|
|
|
D.assert(!_data.includeInScreenshot); |
|
|
|
D.assert(!_data.foundTarget); |
|
|
|
_data.foundTarget = true; |
|
|
|
_data.SetScreenshotOffset(offset); |
|
|
|
_data.screenshotOffset = offset; |
|
|
|
_data.includeInScreenshot = true; |
|
|
|
} |
|
|
|
base.paintChild(child, offset); |
|
|
|
|
|
|
data.containerLayer.append(new _ProxyLayer(repaintBoundary.debugLayer)); |
|
|
|
data.foundTarget = true; |
|
|
|
OffsetLayer offsetLayer = repaintBoundary.debugLayer as OffsetLayer; |
|
|
|
data.SetScreenshotOffset( offsetLayer.offset); |
|
|
|
data.screenshotOffset = offsetLayer.offset; |
|
|
|
} else { |
|
|
|
PaintingContext.debugInstrumentRepaintCompositedChild( |
|
|
|
repaintBoundary, |
|
|
|
|
|
|
public InspectorSerializationDelegate( |
|
|
|
string groupName = null, |
|
|
|
bool? summaryTree = null, |
|
|
|
int? maxDescendentsTruncatableNode = null, |
|
|
|
int? maxDescendentsTruncatableNode = -1, |
|
|
|
int? subtreeDepth = null, |
|
|
|
int? subtreeDepth = 1, |
|
|
|
bool? includeProperties = null, |
|
|
|
WidgetInspectorService service = null, |
|
|
|
AddAdditionalPropertiesCallback addAdditionalPropertiesCallback = null |
|
|
|