From 6c1cb44d18e6629bcb7742f54aaae4c70e27a549 Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 8 Sep 2025 17:17:12 -0400 Subject: [PATCH] maint: updated aline --- .../com.arongranberg.aline/ALINE.asmdef.meta | 4 +- .../AlineHDRPCustomPass.cs.meta | 4 +- .../AlineURPRenderPassFeature.cs | 13 +- .../AlineURPRenderPassFeature.cs.meta | 4 +- Packages/com.arongranberg.aline/CHANGELOG.md | 16 +- .../com.arongranberg.aline/CHANGELOG.md.meta | 4 +- .../com.arongranberg.aline/CommandBuilder.cs | 172 ++++++--- .../CommandBuilder.cs.meta | 4 +- .../CommandBuilder2D.cs | 4 +- .../CommandBuilder2D.cs.meta | 4 +- .../CommandBuilder2DExtensions.cs.meta | 4 +- .../CommandBuilderExtensions.cs.meta | 4 +- .../Compatibility.cs.meta | 4 +- .../Documentation/documentation.html | 325 ++++++++---------- .../Documentation/documentation.html.meta | 6 +- .../Documentation/documentation.pdf | Bin 289399 -> 1213 bytes .../Documentation/documentation.pdf.meta | 6 +- .../Documentation/index.md.meta | 4 +- Packages/com.arongranberg.aline/Draw.cs.meta | 4 +- .../com.arongranberg.aline/DrawingData.cs | 194 +++++------ .../DrawingData.cs.meta | 4 +- .../com.arongranberg.aline/DrawingManager.cs | 101 +++++- .../DrawingManager.cs.meta | 4 +- .../DrawingSettings.cs.meta | 4 +- .../DrawingUtilities.cs.meta | 4 +- .../Editor/DrawingEditor.asmdef.meta | 4 +- .../Editor/DrawingManagerEditor.cs.meta | 4 +- .../Editor/DrawingSettingsEditor.cs.meta | 4 +- .../GizmoCharacterExample.cs.meta | 4 +- .../GizmoSphereExample.cs.meta | 4 +- .../Example1_Gizmos/Gizmos.unity.meta | 4 +- .../Example1_Gizmos/Sphere.prefab.meta | 4 +- .../Example1_Gizmos/TimedSpawner.cs.meta | 4 +- .../Example1_Gizmos/aline_dark_blue.mat.meta | 4 +- .../aline_transparent_sphere.mat.meta | 4 +- .../Example2_CurveEditor/CurveEditor.cs.meta | 4 +- .../CurveEditor.unity.meta | 4 +- .../Example3_Burst/Burst.unity.meta | 4 +- .../Example3_Burst/BurstExample.cs.meta | 4 +- .../Example4_Styling/AlineStyling.cs.meta | 4 +- .../Example4_Styling/Styling.unity.meta | 4 +- .../GeometryBuilder.cs.meta | 4 +- .../MonoBehaviourGizmos.cs.meta | 4 +- .../Editor/DependencyCheck.cs.meta | 4 +- .../Editor/PackageToolsEditor.asmdef.meta | 4 +- .../com.arongranberg.aline/Palette.cs.meta | 4 +- .../PersistentFilter.cs.meta | 4 +- .../Resources/aline_common.cginc.meta | 4 +- .../Resources/aline_common_line.cginc.meta | 4 +- .../Resources/aline_common_surface.cginc.meta | 4 +- .../Resources/aline_common_text.cginc.meta | 4 +- .../Resources/aline_fallback_font.png.meta | 4 +- .../Resources/aline_font.png.meta | 4 +- .../Resources/aline_font.ttf.meta | 4 +- .../Resources/aline_outline_mat.mat.meta | 4 +- .../Resources/aline_outline_mat.shader.meta | 4 +- .../Resources/aline_surface_mat.mat.meta | 4 +- .../Resources/aline_surface_mat.shader.meta | 4 +- .../Resources/aline_text.shader.meta | 4 +- .../Resources/aline_text_mat.mat.meta | 4 +- .../com.arongranberg.aline/SDFFont.cs.meta | 4 +- .../StreamSplitter.cs.meta | 4 +- Packages/com.arongranberg.aline/package.json | 2 +- .../com.arongranberg.aline/package.json.meta | 4 +- 64 files changed, 591 insertions(+), 460 deletions(-) diff --git a/Packages/com.arongranberg.aline/ALINE.asmdef.meta b/Packages/com.arongranberg.aline/ALINE.asmdef.meta index fa4f79d..50e2598 100644 --- a/Packages/com.arongranberg.aline/ALINE.asmdef.meta +++ b/Packages/com.arongranberg.aline/ALINE.asmdef.meta @@ -9,6 +9,6 @@ AssetOrigin: serializedVersion: 1 productId: 162772 packageName: ALINE - packageVersion: 1.7.6 + packageVersion: 1.7.8 assetPath: Packages/com.arongranberg.aline/ALINE.asmdef - uploadId: 700292 + uploadId: 754628 diff --git a/Packages/com.arongranberg.aline/AlineHDRPCustomPass.cs.meta b/Packages/com.arongranberg.aline/AlineHDRPCustomPass.cs.meta index 4cdd4f3..aaf1df4 100644 --- a/Packages/com.arongranberg.aline/AlineHDRPCustomPass.cs.meta +++ b/Packages/com.arongranberg.aline/AlineHDRPCustomPass.cs.meta @@ -13,6 +13,6 @@ AssetOrigin: serializedVersion: 1 productId: 162772 packageName: ALINE - packageVersion: 1.7.6 + packageVersion: 1.7.8 assetPath: Packages/com.arongranberg.aline/AlineHDRPCustomPass.cs - uploadId: 700292 + uploadId: 754628 diff --git a/Packages/com.arongranberg.aline/AlineURPRenderPassFeature.cs b/Packages/com.arongranberg.aline/AlineURPRenderPassFeature.cs index ba960dd..30217b5 100644 --- a/Packages/com.arongranberg.aline/AlineURPRenderPassFeature.cs +++ b/Packages/com.arongranberg.aline/AlineURPRenderPassFeature.cs @@ -32,19 +32,26 @@ namespace Drawing { #if MODULE_RENDER_PIPELINES_UNIVERSAL_17_0_0_OR_NEWER private class PassData { public Camera camera; + public bool allowDisablingWireframe; } public override void RecordRenderGraph (RenderGraph renderGraph, ContextContainer frameData) { var cameraData = frameData.Get(); var resourceData = frameData.Get(); + // This could happen if the camera does not have a color target or depth target set. + // In that case we are probably rendering some kind of special effect. Skip ALINE rendering in that case. + if (!resourceData.activeColorTexture.IsValid() || !resourceData.activeDepthTexture.IsValid()) { + return; + } + using (IRasterRenderGraphBuilder builder = renderGraph.AddRasterRenderPass("ALINE", out PassData passData, profilingSampler)) { - bool allowDisablingWireframe = false; + passData.allowDisablingWireframe = false; if (Application.isEditor && (cameraData.cameraType & (CameraType.SceneView | CameraType.Preview)) != 0) { // We need this to be able to disable wireframe rendering in the scene view builder.AllowGlobalStateModification(true); - allowDisablingWireframe = true; + passData.allowDisablingWireframe = true; } builder.SetRenderAttachment(resourceData.activeColorTexture, 0); @@ -53,7 +60,7 @@ namespace Drawing { builder.SetRenderFunc( (PassData data, RasterGraphContext context) => { - DrawingManager.instance.ExecuteCustomRenderGraphPass(new DrawingData.CommandBufferWrapper { cmd2 = context.cmd, allowDisablingWireframe = allowDisablingWireframe }, data.camera); + DrawingManager.instance.ExecuteCustomRenderGraphPass(new DrawingData.CommandBufferWrapper { cmd2 = context.cmd, allowDisablingWireframe = data.allowDisablingWireframe }, data.camera); } ); } diff --git a/Packages/com.arongranberg.aline/AlineURPRenderPassFeature.cs.meta b/Packages/com.arongranberg.aline/AlineURPRenderPassFeature.cs.meta index 0a73b59..e82a4e0 100644 --- a/Packages/com.arongranberg.aline/AlineURPRenderPassFeature.cs.meta +++ b/Packages/com.arongranberg.aline/AlineURPRenderPassFeature.cs.meta @@ -13,6 +13,6 @@ AssetOrigin: serializedVersion: 1 productId: 162772 packageName: ALINE - packageVersion: 1.7.6 + packageVersion: 1.7.8 assetPath: Packages/com.arongranberg.aline/AlineURPRenderPassFeature.cs - uploadId: 700292 + uploadId: 754628 diff --git a/Packages/com.arongranberg.aline/CHANGELOG.md b/Packages/com.arongranberg.aline/CHANGELOG.md index 6f9b511..e6bfa0a 100644 --- a/Packages/com.arongranberg.aline/CHANGELOG.md +++ b/Packages/com.arongranberg.aline/CHANGELOG.md @@ -1,8 +1,22 @@ +## 1.7.8 (2025-05-06) + - Fixed a minor GC allocation happening every frame when using URP. + - Improved performance in standalone builds when nothing is being rendered. + - Fixed a significant memory leak when starting unity in batch mode. + +## 1.7.7 (2025-03-20) + - Added a new tutorial on using caching to improve performance: \ref caching. + + - Fixed \reflink{Draw.xz.SolidRectangle} would render the rectangle in the XY plane, instead of the XZ plane. + - Fixed an exception could be thrown when cameras were rendered without a color target. + - Added \reflink{PolylineWithSymbol.up}, to allow you to configure the orientation of the symbols. Previously it was hardcoded to Vector3.up. + - Added an offset parameter to \reflink{PolylineWithSymbol}, to allow shifting all symbols along the polyline. This is useful for animations. + - Fixed various minor glitches that could happen when using \reflink{PolylineWithSymbol}. + ## 1.7.6 (2024-10-14) - Fixed a compatibility issue with the high definition render pipeline, accidentally introduced in 1.7.5. - Fixed gizmos were not rendered when opening prefab assets in isolation mode and the high definition render pipeline was used. -## 1.7.5 (2024-10-07) +## 1.7.5 (2024-08-06) - Fixed a memory leak causing references to destroyed cameras to be kept around. - Fixed \reflink{Draw.xy.SolidCircle(float3,float,float,float)} and \reflink{Draw.xz.SolidCircle(float3,float,float,float)} would render the circles in the wrong location. - Reduced overhead when rendering gizmos. diff --git a/Packages/com.arongranberg.aline/CHANGELOG.md.meta b/Packages/com.arongranberg.aline/CHANGELOG.md.meta index 2ff1429..3e2c5d3 100644 --- a/Packages/com.arongranberg.aline/CHANGELOG.md.meta +++ b/Packages/com.arongranberg.aline/CHANGELOG.md.meta @@ -13,6 +13,6 @@ AssetOrigin: serializedVersion: 1 productId: 162772 packageName: ALINE - packageVersion: 1.7.6 + packageVersion: 1.7.8 assetPath: Packages/com.arongranberg.aline/CHANGELOG.md - uploadId: 700292 + uploadId: 754628 diff --git a/Packages/com.arongranberg.aline/CommandBuilder.cs b/Packages/com.arongranberg.aline/CommandBuilder.cs index f026f9f..6b23369 100644 --- a/Packages/com.arongranberg.aline/CommandBuilder.cs +++ b/Packages/com.arongranberg.aline/CommandBuilder.cs @@ -769,8 +769,12 @@ namespace Drawing { } /// - /// Multiply all coordinates until the next PopMatrix with the given matrix. - /// This differs from in that this stacks with all previously pushed matrices while does not. + /// Multiply all coordinates until the next with the given matrix. + /// + /// PushMatrix and PushSetMatrix are slightly different: + /// + /// - PushMatrix stacks with all previously pushed matrices. The active matrix becomes the product of the given matrix and the previously active one. + /// - PushSetMatrix sets the current matrix directly. The active matrix becomes the last pushed matrix. /// public void PushMatrix (Matrix4x4 matrix) { Reserve(); @@ -779,8 +783,12 @@ namespace Drawing { } /// - /// Multiply all coordinates until the next PopMatrix with the given matrix. - /// This differs from in that this stacks with all previously pushed matrices while does not. + /// Multiply all coordinates until the next with the given matrix. + /// + /// PushMatrix and PushSetMatrix are slightly different: + /// + /// - PushMatrix stacks with all previously pushed matrices. The active matrix becomes the product of the given matrix and the previously active one. + /// - PushSetMatrix sets the current matrix directly. The active matrix becomes the last pushed matrix. /// public void PushMatrix (float4x4 matrix) { Reserve(); @@ -789,8 +797,12 @@ namespace Drawing { } /// - /// Multiply all coordinates until the next PopMatrix with the given matrix. - /// This differs from in that this sets the current matrix directly while stacks with all previously pushed matrices. + /// Multiply all coordinates until the next with the given matrix. + /// + /// PushMatrix and PushSetMatrix are slightly different: + /// + /// - PushMatrix stacks with all previously pushed matrices. The active matrix becomes the product of the given matrix and the previously active one. + /// - PushSetMatrix sets the current matrix directly. The active matrix becomes the last pushed matrix. /// public void PushSetMatrix (Matrix4x4 matrix) { Reserve(); @@ -800,7 +812,11 @@ namespace Drawing { /// /// Multiply all coordinates until the next PopMatrix with the given matrix. - /// This differs from in that this sets the current matrix directly while stacks with all previously pushed matrices. + /// + /// PushMatrix and PushSetMatrix are slightly different: + /// + /// - PushMatrix stacks with all previously pushed matrices. The active matrix becomes the product of the given matrix and the previously active one. + /// - PushSetMatrix sets the current matrix directly. The active matrix becomes the last pushed matrix. /// public void PushSetMatrix (float4x4 matrix) { Reserve(); @@ -808,7 +824,12 @@ namespace Drawing { Add(matrix); } - /// Pops a matrix from the stack + /// + /// Pops a matrix from the stack. + /// + /// See: + /// See: + /// public void PopMatrix () { Reserve(4); Add(Command.PopMatrix); @@ -1053,7 +1074,7 @@ namespace Drawing { /// /// [Open online documentation to see images] /// - /// See: + /// See: /// See: /// See: /// @@ -1089,7 +1110,7 @@ namespace Drawing { /// /// [Open online documentation to see images] /// - /// See: + /// See: /// See: /// /// Center of the circle or arc. @@ -1499,7 +1520,7 @@ namespace Drawing { } /// Determines the symbol to use for - public enum SymbolDecoration { + public enum SymbolDecoration : byte { /// /// No symbol. /// @@ -1611,20 +1632,43 @@ namespace Drawing { float3 prev; float offset; readonly float symbolSize; - readonly float symbolSpacing; + readonly float connectingSegmentLength; readonly float symbolPadding; readonly float symbolOffset; - readonly SymbolDecoration symbol; - readonly bool reverseSymbols; - bool odd; - /// Create a new polyline with symbol generator. + /// + /// The up direction of the symbols. + /// + /// This is used to determine the orientation of the symbols. + /// By default this is set to (0,1,0). + /// + public float3 up; + + readonly SymbolDecoration symbol; + State state; + readonly bool reverseSymbols; + + enum State : byte { + NotStarted, + ConnectingSegment, + PreSymbolPadding, + Symbol, + PostSymbolPadding, + } + + /// + /// Create a new polyline with symbol generator. + /// + /// Note: If symbolSize + 2*symbolPadding > symbolSpacing, the symbolSpacing parameter will be increased to accommodate the symbol and its padding. + /// There will be no connecting lines between the symbols in this case, as there's no space for them. + /// /// The symbol to use /// The size of the symbol. In case of a circle, this is the diameter. /// The padding on both sides of the symbol between the symbol and the line. /// The spacing between symbols. This is the distance between the centers of the symbols. /// If true, the symbols will be reversed. For cicles this has no effect, but arrowhead symbols will be reversed. - public PolylineWithSymbol(SymbolDecoration symbol, float symbolSize, float symbolPadding, float symbolSpacing, bool reverseSymbols = false) { + /// Distance to shift all symbols forward along the line. Useful for animations. If offset=0, the first symbol's center is at symbolSpacing/2. + public PolylineWithSymbol(SymbolDecoration symbol, float symbolSize, float symbolPadding, float symbolSpacing, bool reverseSymbols = false, float offset = 0) { if (symbolSpacing <= math.FLT_MIN_NORMAL) throw new System.ArgumentOutOfRangeException(nameof(symbolSpacing), "Symbol spacing must be greater than zero"); if (symbolSize <= math.FLT_MIN_NORMAL) throw new System.ArgumentOutOfRangeException(nameof(symbolSize), "Symbol size must be greater than zero"); if (symbolPadding < 0) throw new System.ArgumentOutOfRangeException(nameof(symbolPadding), "Symbol padding must non-negative"); @@ -1633,15 +1677,20 @@ namespace Drawing { this.symbol = symbol; this.symbolSize = symbolSize; this.symbolPadding = symbolPadding; - this.symbolSpacing = math.max(0, symbolSpacing - symbolPadding * 2f - symbolSize); + this.connectingSegmentLength = math.max(0, symbolSpacing - symbolPadding * 2f - symbolSize); + // Calculate actual value, after clamping to a valid range + symbolSpacing = symbolPadding * 2 + symbolSize + connectingSegmentLength; this.reverseSymbols = reverseSymbols; + this.up = new float3(0, 1, 0); symbolOffset = symbol == SymbolDecoration.ArrowHead ? -0.25f * symbolSize : 0; if (reverseSymbols) { symbolOffset = -symbolOffset; } symbolOffset += 0.5f * symbolSize; - offset = -1; - odd = false; + this.offset = (this.connectingSegmentLength * 0.5f + offset) % symbolSpacing; + // Ensure the initial offset is always negative. This makes the state machine start in the correct state when the offset turns positive. + if (this.offset > 0) this.offset -= symbolSpacing; + this.state = State.NotStarted; } /// @@ -1652,48 +1701,77 @@ namespace Drawing { /// The command builder to draw to. You can use a built-in builder like \reflink{Draw.editor} or \reflink{Draw.ingame}, or use a custom one. /// The next point in the polyline to move to. public void MoveTo (ref CommandBuilder draw, float3 next) { - if (offset == -1) { - offset = this.symbolSpacing * 0.5f; + if (state == State.NotStarted) { prev = next; + state = State.ConnectingSegment; return; } + var len = math.length(next - prev); var invLen = math.rcp(len); var dir = next - prev; float3 up = default; if (symbol != SymbolDecoration.None) { - up = math.normalizesafe(math.cross(dir, math.cross(dir, new float3(0, 1, 0)))); + up = math.normalizesafe(math.cross(dir, math.cross(dir, this.up))); if (math.all(up == 0f)) { up = new float3(0, 0, 1); } + if (reverseSymbols) dir = -dir; } - if (reverseSymbols) dir = -dir; - if (offset > 0 && !odd) { - draw.Line(prev, math.lerp(prev, next, math.min(offset * invLen, 1))); - } - while (offset < len) { - if (odd) { - var pLast = math.lerp(prev, next, offset * invLen); - offset += symbolSpacing; - var p = math.lerp(prev, next, math.min(offset * invLen, 1)); - draw.Line(pLast, p); - offset += symbolPadding; - } else { - var p = math.lerp(prev, next, (offset + symbolOffset) * invLen); - switch (symbol) { - case SymbolDecoration.None: - break; - case SymbolDecoration.ArrowHead: - draw.Arrowhead(p, dir, up, symbolSize); - break; - case SymbolDecoration.Circle: - default: - draw.Circle(p, up, symbolSize * 0.5f); + + var currentPositionOnSegment = 0f; + while (true) { + if (state == State.ConnectingSegment) { + if (offset >= 0 && offset != currentPositionOnSegment) { + currentPositionOnSegment = math.max(0, currentPositionOnSegment); + var pLast = math.lerp(prev, next, currentPositionOnSegment * invLen); + var p = math.lerp(prev, next, math.min(offset * invLen, 1)); + draw.Line(pLast, p); + } + + if (offset < len) { + state = State.PreSymbolPadding; + currentPositionOnSegment = offset; + offset += symbolPadding; + } else { break; } - offset += symbolSize + symbolPadding; + } else if (state == State.PreSymbolPadding) { + if (offset >= len) break; + + state = State.Symbol; + currentPositionOnSegment = offset; + offset += symbolOffset; + } else if (state == State.Symbol) { + if (offset >= len) break; + + if (offset >= 0) { + var p = math.lerp(prev, next, offset * invLen); + switch (symbol) { + case SymbolDecoration.None: + break; + case SymbolDecoration.ArrowHead: + draw.Arrowhead(p, dir, up, symbolSize); + break; + case SymbolDecoration.Circle: + default: + draw.Circle(p, up, symbolSize * 0.5f); + break; + } + } + + state = State.PostSymbolPadding; + currentPositionOnSegment = offset; + offset += -symbolOffset + symbolSize + symbolPadding; + } else if (state == State.PostSymbolPadding) { + if (offset >= len) break; + + state = State.ConnectingSegment; + currentPositionOnSegment = offset; + offset += connectingSegmentLength; + } else { + throw new System.Exception("Invalid state"); } - odd = !odd; } offset -= len; prev = next; diff --git a/Packages/com.arongranberg.aline/CommandBuilder.cs.meta b/Packages/com.arongranberg.aline/CommandBuilder.cs.meta index 8f99bb0..efda5b5 100644 --- a/Packages/com.arongranberg.aline/CommandBuilder.cs.meta +++ b/Packages/com.arongranberg.aline/CommandBuilder.cs.meta @@ -13,6 +13,6 @@ AssetOrigin: serializedVersion: 1 productId: 162772 packageName: ALINE - packageVersion: 1.7.6 + packageVersion: 1.7.8 assetPath: Packages/com.arongranberg.aline/CommandBuilder.cs - uploadId: 700292 + uploadId: 754628 diff --git a/Packages/com.arongranberg.aline/CommandBuilder2D.cs b/Packages/com.arongranberg.aline/CommandBuilder2D.cs index d1c2b41..efd3ab5 100644 --- a/Packages/com.arongranberg.aline/CommandBuilder2D.cs +++ b/Packages/com.arongranberg.aline/CommandBuilder2D.cs @@ -162,7 +162,7 @@ namespace Drawing { /// /// [Open online documentation to see images] /// - /// See: + /// See: /// See: /// /// Center of the circle or arc. @@ -380,7 +380,7 @@ namespace Drawing { /// See: /// public void SolidRectangle (Rect rect) { - draw.SolidPlane(new float3(rect.center.x, rect.center.y, 0.0f), xy ? XY_TO_XZ_ROTATION : XZ_TO_XZ_ROTATION, new float2(rect.width, rect.height)); + draw.SolidPlane(xy ? new float3(rect.center.x, rect.center.y, 0.0f) : new float3(rect.center.x, 0, rect.center.y), xy ? XY_TO_XZ_ROTATION : XZ_TO_XZ_ROTATION, new float2(rect.width, rect.height)); } /// diff --git a/Packages/com.arongranberg.aline/CommandBuilder2D.cs.meta b/Packages/com.arongranberg.aline/CommandBuilder2D.cs.meta index 8201a0e..7543d26 100644 --- a/Packages/com.arongranberg.aline/CommandBuilder2D.cs.meta +++ b/Packages/com.arongranberg.aline/CommandBuilder2D.cs.meta @@ -13,6 +13,6 @@ AssetOrigin: serializedVersion: 1 productId: 162772 packageName: ALINE - packageVersion: 1.7.6 + packageVersion: 1.7.8 assetPath: Packages/com.arongranberg.aline/CommandBuilder2D.cs - uploadId: 700292 + uploadId: 754628 diff --git a/Packages/com.arongranberg.aline/CommandBuilder2DExtensions.cs.meta b/Packages/com.arongranberg.aline/CommandBuilder2DExtensions.cs.meta index a7414c6..16e55fb 100644 --- a/Packages/com.arongranberg.aline/CommandBuilder2DExtensions.cs.meta +++ b/Packages/com.arongranberg.aline/CommandBuilder2DExtensions.cs.meta @@ -13,6 +13,6 @@ AssetOrigin: serializedVersion: 1 productId: 162772 packageName: ALINE - packageVersion: 1.7.6 + packageVersion: 1.7.8 assetPath: Packages/com.arongranberg.aline/CommandBuilder2DExtensions.cs - uploadId: 700292 + uploadId: 754628 diff --git a/Packages/com.arongranberg.aline/CommandBuilderExtensions.cs.meta b/Packages/com.arongranberg.aline/CommandBuilderExtensions.cs.meta index c190a8a..4b75adb 100644 --- a/Packages/com.arongranberg.aline/CommandBuilderExtensions.cs.meta +++ b/Packages/com.arongranberg.aline/CommandBuilderExtensions.cs.meta @@ -13,6 +13,6 @@ AssetOrigin: serializedVersion: 1 productId: 162772 packageName: ALINE - packageVersion: 1.7.6 + packageVersion: 1.7.8 assetPath: Packages/com.arongranberg.aline/CommandBuilderExtensions.cs - uploadId: 700292 + uploadId: 754628 diff --git a/Packages/com.arongranberg.aline/Compatibility.cs.meta b/Packages/com.arongranberg.aline/Compatibility.cs.meta index e1087eb..c2efeea 100644 --- a/Packages/com.arongranberg.aline/Compatibility.cs.meta +++ b/Packages/com.arongranberg.aline/Compatibility.cs.meta @@ -13,6 +13,6 @@ AssetOrigin: serializedVersion: 1 productId: 162772 packageName: ALINE - packageVersion: 1.7.6 + packageVersion: 1.7.8 assetPath: Packages/com.arongranberg.aline/Compatibility.cs - uploadId: 700292 + uploadId: 754628 diff --git a/Packages/com.arongranberg.aline/Documentation/documentation.html b/Packages/com.arongranberg.aline/Documentation/documentation.html index 4fa2b1f..75a2a7f 100644 --- a/Packages/com.arongranberg.aline/Documentation/documentation.html +++ b/Packages/com.arongranberg.aline/Documentation/documentation.html @@ -189,10 +189,12 @@ nav.navbar .version-badge { padding-top: 0px; padding-bottom: 5px; } -.sidenav-l0 a:hover, .sidenav-l0 a:focus { +.sidenav-l0 a:hover, +.sidenav-l0 a:focus { text-decoration: none; } -.sidenav-l0 li > a:hover, .sidenav-l0 li.active > a { +.sidenav-l0 li > a:hover, +.sidenav-l0 li.active > a { padding-left: 8px; border-width: 0px 0px 0px 2px; border-color: #000000; @@ -214,7 +216,8 @@ li p { .sidenav-l1 li > a { padding-left: 30px; } -.sidenav-l1 li > a:hover, .sidenav-l1 li.active > a { +.sidenav-l1 li > a:hover, +.sidenav-l1 li.active > a { padding-left: 28px; } @@ -225,7 +228,8 @@ li p { .sidenav-l2 li > a { padding-left: 40px; } -.sidenav-l2 li > a:hover, .sidenav-l2 li.active > a { +.sidenav-l2 li > a:hover, +.sidenav-l2 li.active > a { padding-left: 38px; } @@ -236,7 +240,8 @@ li p { .sidenav-l3 li > a { padding-left: 50px; } -.sidenav-l3 li > a:hover, .sidenav-l3 li.active > a { +.sidenav-l3 li > a:hover, +.sidenav-l3 li.active > a { padding-left: 48px; } @@ -247,7 +252,8 @@ li p { .sidenav-l4 li > a { padding-left: 60px; } -.sidenav-l4 li > a:hover, .sidenav-l4 li.active > a { +.sidenav-l4 li > a:hover, +.sidenav-l4 li.active > a { padding-left: 58px; } @@ -311,7 +317,10 @@ body { font-size: 15px; } -h1, h2, h3, h4 { +h1, +h2, +h3, +h4 { font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", "Liberation Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; } @@ -373,7 +382,8 @@ table.compound-view tr a:hover { background-color: #DDD; } -video, .youtube-video { +video, +.youtube-video { border-radius: 3px; margin: 5px; margin-left: auto; @@ -395,6 +405,10 @@ img { border: 1px solid #444; } +img.tinyshadow { + cursor: pointer; +} + .borderless img { border: none; } @@ -465,7 +479,8 @@ code { background-color: #5050501F; } -.simplesect-author, .simplesect-authors { +.simplesect-author, +.simplesect-authors { border-color: #0BAA0B; background-color: #0BAA0B1F; } @@ -589,12 +604,16 @@ table.member-list-section td { table.member-list-section .member-desc { width: 100%; } -table.member-list-section .member-desc, table.member-list-section .member-name, table.member-list-section .member-type { +table.member-list-section .member-desc, +table.member-list-section .member-name, +table.member-list-section .member-type { font-size: 0.9em; margin-bottom: 0px; padding-bottom: 0px; } -table.member-list-section a, table.member-list-section p, table.member-list-section span { +table.member-list-section a, +table.member-list-section p, +table.member-list-section span { -webkit-margin-after: 0px; line-height: 1.5em; vertical-align: center; @@ -621,14 +640,16 @@ table.member-list-section a, table.member-list-section p, table.member-list-sect margin-left: 30px; margin-top: 5px; } -.member-params-detail td, .member-params-detail th { +.member-params-detail td, +.member-params-detail th { padding-left: 8px; padding-right: 8px; padding-top: 2px; padding-bottom: 2px; vertical-align: top; } -.member-params-detail td p, .member-params-detail th p { +.member-params-detail td p, +.member-params-detail th p { margin: 0 0 5px; } .member-params-detail .param-name { @@ -762,7 +783,9 @@ a:focus { padding-left: 112px; } -.member-depth-6, .member-depth-7, .member-depth-8 { +.member-depth-6, +.member-depth-7, +.member-depth-8 { padding-left: 132px; } @@ -899,6 +922,104 @@ table.horizontalAlternative2D3D td.Alt3D { margin-bottom: 10px; } +.task { + display: flex; + flex-direction: row; + align-items: center; + margin-top: 16px; + margin-bottom: 16px; + padding-left: 10px; + padding-top: 4px; + padding-bottom: 5px; +} +.task .task-icon { + width: 8px; + height: 8px; + flex-shrink: 0; + background: #D9534F; + border-radius: 8px; + box-shadow: 0px 0px 5px #FF6E6A; +} +.task.task-note { + font-style: italic; + color: #6d6d6d; +} +.task.task-note .task-icon { + background: #79a1ff; + box-shadow: 0px 0px 5px #228AC8; +} +.task.sub-task { + margin-top: -20px; + padding-left: 30px; +} +.task p { + margin-top: 0px; + margin-bottom: 0px; + margin-left: 14px; +} + +.horizontal-group { + display: flex; + flex-direction: row; + flex-wrap: wrap; + margin-top: 20px; + margin-bottom: 20px; + gap: 20px; +} +.horizontal-group > div { + flex: 1; + min-width: 400px; +} +.horizontal-group > div:first-child { + flex: 1.2; +} +.horizontal-group .groupchild-text { + margin-top: 16px; +} +@media (min-width: 1200px) { + .horizontal-group .prettyprint { + margin-left: -120px; + font-size: 0.9em; + } +} + +#lightbox { + position: fixed; + z-index: 1000; + max-height: 80vh; + max-width: 80vw; + padding: 0; + background: none; + border: none; + outline: none; + overflow: visible; +} +#lightbox[open] { + display: flex; +} +#lightbox::backdrop { + background: rgba(255, 255, 255, 0.5); +} +#lightbox:-moz-focusring { + color: transparent; + text-shadow: 0 0 0 #000; +} +#lightbox div { + display: flex; + flex-direction: row; + align-items: normal; + justify-content: center; +} +#lightbox div img { + object-fit: contain; + margin: 0; + margin: 0; + box-shadow: 0px 0px 2.2px rgba(0, 0, 0, 0.043), 0px 0px 5.6px rgba(0, 0, 0, 0.062), 0px 0px 11.5px rgba(0, 0, 0, 0.078), 0px 0px 23.7px rgba(0, 0, 0, 0.097), 0px 0px 65px rgba(0, 0, 0, 0.14); + border: none; + border-radius: 3px; + background-color: white; +} + /*# sourceMappingURL=style.css.map */ /* Extra CSS */ @@ -942,186 +1063,16 @@ table.horizontalAlternative2D3D td.Alt3D { src: local('Bitter Regular'), local('Bitter-Regular'), url(https://fonts.gstatic.com/s/bitter/v13/rax8HiqOu8IVPmn7f4xs.ttf) format('truetype'); } - - - -
-
-
-
-
- -

Get Started With ALINE

- - -

In this tutorial we will cover how to create a simple script and draw some things from the Update loop as well as in a gizmo callback.

Contents

-

Downloading

The first thing you need to do, if you haven't done so already, is to download the package.
-You can download the package in the Asset Store or from the package website.

Drawing from the Update loop

If you want to debug what a script does, then drawing things from the code is a great way to do it.

Create a new C# script in Unity and name it GetStartedExample.cs, then open that up in a text editor and write the following code.

using UnityEngine;
// Important for the script to be able to find the Draw class
using Drawing;

public class GetStartedExample : MonoBehaviour {
void Update () {
// Draw a cylinder at the object's position with a height of 2 and a radius of 0.5
Draw.WireCylinder(transform.position, Vector3.up, 2f, 0.5f);
}
}

In your Unity scene you can then create a new GameObject and attach the GetStartedExample script to it. If you press play you should see a cylinder rendered at the object's position.

You can draw other things than cylinders, of course. Take a look at the Drawing Commands page for a list of them.

If you want to render the cylinder in a different color, you can simply add a color parameter at the end. All drawing commands have an optional color parameter at the end.

Draw.WireCylinder(transform.position, Vector3.up, 2f, 0.5f, Color.red);

Scopes

A powerful abstraction used in this package is the notion of scopes. Scopes can be used to set the color, matrix, line width or duration of multiple drawing commands at once without having to individually specify them or having to do matrix multiplications manually. This is both faster and leads to more readable code.

// Draw three red cubes
using (Draw.WithColor(Color.red)) {
Draw.WireBox(transform.position, Vector3.one);
Draw.WireBox(transform.position + Vector3.right, Vector3.one);
Draw.WireBox(transform.position - Vector3.right, Vector3.one);
}
Using matrix scopes is very useful if you want to, for example, draw in local space relative to some object. In the example below, a cylinder is drawn in an object's local space. This means it is moved, rotated and scaled with the object automatically.

using (Draw.InLocalSpace(transform)) {
// Draw a box at (0,0,0) relative to the current object
// This means it will show up at the object's position
Draw.WireBox(Vector3.zero, Vector3.one);
}

// Equivalent code using the lower level WithMatrix scope
using (Draw.WithMatrix(transform.localToWorldMatrix)) {
Draw.WireBox(Vector3.zero, Vector3.one);
}

In the example below the color and duration scopes are shown. // This box will be drawn for 2 seconds
using (Draw.WithDuration(2)) {
Draw.WireBox(Vector3.zero, Vector3.one);
}

// Scopes can be nested
using (Draw.WithColor(Color.red)) {
using (Draw.WithDuration(2)) {
Draw.WireBox(Vector3.zero, Vector3.one);
}
}

-

Drawing object gizmos

Drawing helper visualizations for objects in the scene view is often helpful when developing a game. With Unity's built-in gizmo system you draw everything in the OnDrawGizmos method and you need to use the Gizmos class instead of the Debug class. In this package, you do everything with the Draw class.

To receive gizmo callbacks, you need to make your script inherit from MonoBehaviourGizmos instead of from MonoBehaviour. You can then override the DrawGizmos method and draw your gizmos there exactly as you would in other parts of the code.

using UnityEngine;
using Drawing;

public class GetStartedGizmos : MonoBehaviourGizmos {
public override void DrawGizmos () {
using (Draw.InLocalSpace(transform)) {
// Draw a cylinder at the object's position with a height of 2 and a radius of 0.5
Draw.WireCylinder(Vector3.zero, Vector3.up, 2f, 0.5f);
}
}
}

Gizmos will be drawn all the time, even when the game is not playing or if it is paused. You can toggle gizmo drawing for individual components in the gizmos menu in the top right corner of the scene view and game view.

Selection based drawing

If you have a lot of gizmos in a scene, it can sometimes cause quite a bit of clutter. One solution to this is to draw simple gizmos most of the time and only draw more elaborate or detailed gizmos when the object is selected.

This can easily be accomplished using the GizmoContext class.

public override void DrawGizmos () {
using (Draw.InLocalSpace(transform)) {
if (GizmoContext.InSelection(this)) {
// Draw a yellow cylinder
Draw.WireCylinder(Vector3.zero, Vector3.up, 2f, 0.5f, Color.yellow);
} else {
// Draw a yellow circle with some transparency
Draw.xz.Circle(Vector3.zero, 0.5f, Color.yellow * new Color(1, 1, 1, 0.5f));
}
}
}

-

Project Settings

Sometimes it can be convenient to adjust the opacity of gizmos globally. This can be done in the project settings. Solid objects (e.g. Draw.SolidBox) are by default drawn slightly transparent. You can adjust this in the project settings if you wish.

- -
-
-
-
-
-
-
-
- - - -