public static GraphInfo GetGraphInfo(this UIGraphData graph, BlobAssetReference <CompiledUISchema> schema, out NativeArray <NodeInfo> configLayout, Allocator allocator) { var offset = sizeof(ulong) + sizeof(int); configLayout = new NativeArray <NodeInfo>(graph.GetNodeCount(), allocator); var graphInfo = new GraphInfo(); for (int currentIndex = 0; currentIndex < graph.GetNodeCount(); currentIndex++) { //var size = UnsafeUtility.AsRef<int>((((IntPtr)graph.Value.initialConfiguration.GetUnsafePtr()) + offset).ToPointer()); var size = *(int *)(graph.value + offset).ToPointer(); var header = (HeaderConfig *)(graph.value + offset + sizeof(int)).ToPointer(); //var size = graph.GetNodeLength(currentIndex); if (header->IsDedicatedNode) { graphInfo.subMeshCount++; } offset += UnsafeUtility.SizeOf <int>(); NodeInfo info = new NodeInfo { configurationMask = header->configurationMask, nodeOffset = offset, childrenOffset = offset + UnsafeUtility.SizeOf <HeaderConfig>(), configOffset = offset + UnsafeUtility.SizeOf <HeaderConfig>() + (sizeof(int) * header->childCount), length = size, index = currentIndex }; var call = header->schemaIndex >= 0 ? schema.Value.elements[header->schemaIndex].renderBoxCounter : default; info.renderBoxCount = call.IsCreated ? call.Invoke(graph.value, (NodeInfo *)UnsafeUtility.AddressOf(ref info)) : 1; configLayout[currentIndex] = info; graphInfo.renderBoxCount += info.renderBoxCount; offset += size; } return(graphInfo); }
public void Execute(UIGraphData graph, MeshData meshData, int index) { if (graph.GetNodeCount() > 0) { var states = new NativeArray <UIPassState>(graph.GetNodeCount(), Allocator.Temp); var initial = UIPassState.Null; UnsafeUtility.MemCpyReplicate(states.GetUnsafePtr(), UnsafeUtility.AddressOf(ref initial), UnsafeUtility.SizeOf <UIPassState>(), states.Length); var graphInfo = graph.GetGraphInfo(schema, out NativeArray <NodeInfo> layout, Allocator.Temp); InitMeshData(ref meshData, graphInfo); NativeArray <UIVertexData> vertices = meshData.GetVertexData <UIVertexData>(); var contextPtr = (UIContextData *)((IntPtr)contexts.GetUnsafePtr() + (UnsafeUtility.SizeOf <UIContextData>() * index)).ToPointer(); Layout(0, graph, layout, states, contextPtr); Render(vertices, contextPtr, ref meshData, graph, layout, graphInfo, states); states.Dispose(); layout.Dispose(); } }
public static int GetFirstSelectableIndex(this UIGraphData graph) { if (!graph.IsCreated) { return(-1); } //Index, priority ValueTuple <int, int> selectableIndex = (-1, int.MinValue); for (int currentIndex = 0; currentIndex < graph.GetNodeCount(); currentIndex++) { if (graph.TryGetConfigBlock(currentIndex, UIConfigLayoutTable.SelectableConfig, out IntPtr block)) { SelectableConfig *selectableConfig = (SelectableConfig *)block; if (selectableConfig->onSelect.IsCreated && selectableIndex.Item2.CompareTo(selectableConfig->priority) < 0) { selectableIndex = (currentIndex, selectableConfig->priority); } } } return(selectableIndex.Item1); }