From 2a0ee6ee6de4349758109d29b341351b15a8d82d Mon Sep 17 00:00:00 2001 From: action Date: Sun, 26 Nov 2023 18:29:31 +0000 Subject: [PATCH 01/17] Auto increment pre-release version to 2.3.3 [skip ci] --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index eba32759..70ac69b1 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "com.unity.uiextensions", "displayName": "Unity UI Extensions", - "version": "2.3.2-pre.5", + "version": "2.3.3", "description": "An extension project for the Unity3D UI system, all crafted and contributed by the awesome Unity community", "author": "Simon darkside Jackson <@SimonDarksideJ>", "contributors": [ From dde9764fed32edde7395ef670afd469f28911ca4 Mon Sep 17 00:00:00 2001 From: bluefallsky Date: Mon, 29 Jan 2024 00:57:26 +0900 Subject: [PATCH 02/17] Optimize 'Gradient2' 'when 'ModifyMesh' called --- Runtime/Scripts/Effects/Gradient2.cs | 76 ++++++++++++++++++++++++---- 1 file changed, 65 insertions(+), 11 deletions(-) diff --git a/Runtime/Scripts/Effects/Gradient2.cs b/Runtime/Scripts/Effects/Gradient2.cs index 624326a2..b0060df6 100644 --- a/Runtime/Scripts/Effects/Gradient2.cs +++ b/Runtime/Scripts/Effects/Gradient2.cs @@ -9,6 +9,12 @@ /// using System; using System.Collections.Generic; +#if UNITY_2021_2_OR_NEWER +using System.Buffers; +#endif +#if UNITY_2021_1_OR_NEWER +using UnityEngine.Pool; +#endif namespace UnityEngine.UI.Extensions { @@ -36,6 +42,9 @@ public class Gradient2 : BaseMeshEffect [SerializeField] UnityEngine.Gradient _effectGradient = new UnityEngine.Gradient() { colorKeys = new GradientColorKey[] { new GradientColorKey(Color.black, 0), new GradientColorKey(Color.white, 1) } }; + private GradientColorKey[] _colorKeys; + private GradientAlphaKey[] _alphaKeys; + #region Properties public Blend BlendMode { @@ -103,7 +112,11 @@ public override void ModifyMesh(VertexHelper helper) if (!IsActive() || helper.currentVertCount == 0) return; +#if UNITY_2021_1_OR_NEWER + List _vertexList = ListPool.Get(); +#else List _vertexList = new List(); +#endif helper.GetUIVertexStream(_vertexList); @@ -238,6 +251,10 @@ public override void ModifyMesh(VertexHelper helper) } break; } + +#if UNITY_2021_1_OR_NEWER + ListPool.Release(_vertexList); +#endif } Rect GetBounds(List vertices) @@ -264,7 +281,11 @@ Rect GetBounds(List vertices) void SplitTrianglesAtGradientStops(List _vertexList, Rect bounds, float zoomOffset, VertexHelper helper) { - List stops = FindStops(zoomOffset, bounds); +#if UNITY_2021_1_OR_NEWER + List stops = FindStops(zoomOffset, bounds, ListPool.Get()); +#else + List stops = FindStops(zoomOffset, bounds, new List()); +#endif if (stops.Count > 0) { helper.Clear(); @@ -272,10 +293,23 @@ void SplitTrianglesAtGradientStops(List _vertexList, Rect bounds, floa int nCount = _vertexList.Count; for (int i = 0; i < nCount; i += 3) { - float[] positions = GetPositions(_vertexList, i); +#if UNITY_2021_2_OR_NEWER + var positions = ArrayPool.Shared.Rent(3); +#else + var positions = new float[3]; +#endif + + GetPositions(_vertexList, i, ref positions); + +#if UNITY_2021_1_OR_NEWER + List originIndices = ListPool.Get(); + List starts = ListPool.Get(); + List ends = ListPool.Get(); +#else List originIndices = new List(3); List starts = new List(3); List ends = new List(2); +#endif for (int s = 0; s < stops.Count; s++) { @@ -403,13 +437,24 @@ void SplitTrianglesAtGradientStops(List _vertexList, Rect bounds, floa int vertexCount = helper.currentVertCount; helper.AddTriangle(vertexCount - 3, vertexCount - 2, vertexCount - 1); } + +#if UNITY_2021_2_OR_NEWER + ArrayPool.Shared.Return(positions); +#endif +#if UNITY_2021_1_OR_NEWER + ListPool.Release(originIndices); + ListPool.Release(starts); + ListPool.Release(ends); +#endif } } +#if UNITY_2021_1_OR_NEWER + ListPool.Release(stops); +#endif } - float[] GetPositions(List _vertexList, int index) + void GetPositions(List _vertexList, int index, ref float[] positions) { - float[] positions = new float[3]; if (GradientType == Type.Horizontal) { positions[0] = _vertexList[index].position.x; @@ -422,24 +467,27 @@ float[] GetPositions(List _vertexList, int index) positions[1] = _vertexList[index + 1].position.y; positions[2] = _vertexList[index + 2].position.y; } - return positions; } - - List FindStops(float zoomOffset, Rect bounds) + + List FindStops(float zoomOffset, Rect bounds, List stops) { - List stops = new List(); var offset = Offset * (1 - zoomOffset); var startBoundary = zoomOffset - offset; var endBoundary = (1 - zoomOffset) - offset; - foreach (var color in EffectGradient.colorKeys) + if (_colorKeys == null) _colorKeys = EffectGradient.colorKeys; + + foreach (var color in _colorKeys) { if (color.time >= endBoundary) break; if (color.time > startBoundary) stops.Add((color.time - startBoundary) * Zoom); } - foreach (var alpha in EffectGradient.alphaKeys) + + if (_alphaKeys == null) _alphaKeys = _effectGradient.alphaKeys; + + foreach (var alpha in _alphaKeys) { if (alpha.time >= endBoundary) break; @@ -455,7 +503,13 @@ List FindStops(float zoomOffset, Rect bounds) size = bounds.height; } - stops.Sort(); + stops.Sort((x, y) => + { + if (x > y) return 1; + if (x == y) return 0; + return -1; + }); + for (int i = 0; i < stops.Count; i++) { stops[i] = (stops[i] * size) + min; From 86744455f1bc44b71b41718d96701b58ce39737c Mon Sep 17 00:00:00 2001 From: bluefallsky Date: Sun, 28 Apr 2024 20:48:09 +0900 Subject: [PATCH 03/17] fix radial triangle add order(#384) --- Runtime/Scripts/Effects/Gradient2.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Runtime/Scripts/Effects/Gradient2.cs b/Runtime/Scripts/Effects/Gradient2.cs index 624326a2..2197b88e 100644 --- a/Runtime/Scripts/Effects/Gradient2.cs +++ b/Runtime/Scripts/Effects/Gradient2.cs @@ -218,7 +218,7 @@ public override void ModifyMesh(VertexHelper helper) helper.AddVert(centralVertex); - for (int i = 1; i < steps; i++) helper.AddTriangle(i - 1, i, steps); + for (int i = 1; i < steps; i++) helper.AddTriangle(i, i-1, steps); helper.AddTriangle(0, steps - 1, steps); } From 10b90c4fb01d425e45015e274fca708c99afcd3e Mon Sep 17 00:00:00 2001 From: JavierMonton Date: Mon, 19 Aug 2024 11:56:07 +0200 Subject: [PATCH 04/17] Keep Item Rotation configuration. --- .../ReorderableList/ReorderableList.cs | 3 +++ .../ReorderableList/ReorderableListElement.cs | 20 +++++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/Runtime/Scripts/Controls/ReorderableList/ReorderableList.cs b/Runtime/Scripts/Controls/ReorderableList/ReorderableList.cs index 5ef840c2..8063906c 100644 --- a/Runtime/Scripts/Controls/ReorderableList/ReorderableList.cs +++ b/Runtime/Scripts/Controls/ReorderableList/ReorderableList.cs @@ -32,6 +32,9 @@ public class ReorderableList : MonoBehaviour [Tooltip("Should items being dragged over this list have their sizes equalized?")] public bool EqualizeSizesOnDrag = false; + [Tooltip("Should items keep the original rotation?")] + public bool KeepItemRotation = false; + [Tooltip("Maximum number of items this container can hold")] public int maxItems = int.MaxValue; diff --git a/Runtime/Scripts/Controls/ReorderableList/ReorderableListElement.cs b/Runtime/Scripts/Controls/ReorderableList/ReorderableListElement.cs index eb1484cd..8a09c32b 100644 --- a/Runtime/Scripts/Controls/ReorderableList/ReorderableListElement.cs +++ b/Runtime/Scripts/Controls/ReorderableList/ReorderableListElement.cs @@ -266,7 +266,10 @@ private void displaceElement(int targetIndex, Transform displaced) _displacedObjectLE.preferredWidth = _draggingObjectOriginalSize.x; _displacedObjectLE.preferredHeight = _draggingObjectOriginalSize.y; _displacedObject.SetParent(_reorderableList.Content, false); - _displacedObject.rotation = _reorderableList.transform.rotation; + if (!_reorderableList.KeepItemRotation) + { + _displacedObject.rotation = _reorderableList.transform.rotation; + } _displacedObject.SetSiblingIndex(_fromIndex); // Force refreshing both lists because otherwise we get inappropriate FromList in ReorderableListEventStruct _reorderableList.Refresh(); @@ -310,7 +313,10 @@ private void revertDisplacedElement() _displacedObjectLE.preferredWidth = _displacedObjectOriginalSize.x; _displacedObjectLE.preferredHeight = _displacedObjectOriginalSize.y; _displacedObject.SetParent(_displacedObjectOriginList.Content, false); - _displacedObject.rotation = _displacedObjectOriginList.transform.rotation; + if (!_reorderableList.KeepItemRotation) + { + _displacedObject.rotation = _displacedObjectOriginList.transform.rotation; + } _displacedObject.SetSiblingIndex(_displacedFromIndex); _displacedObject.gameObject.SetActive(true); @@ -382,7 +388,10 @@ public void OnEndDrag(PointerEventData eventData) RefreshSizes(); _draggingObject.SetParent(_currentReorderableListRaycasted.Content, false); - _draggingObject.rotation = _currentReorderableListRaycasted.transform.rotation; + if (!_reorderableList.KeepItemRotation) + { + _draggingObject.rotation = _currentReorderableListRaycasted.transform.rotation; + } _draggingObject.SetSiblingIndex(_fakeElement.GetSiblingIndex()); //If the item is transferable, it can be dragged out again @@ -474,7 +483,10 @@ private void CancelDrag() { RefreshSizes(); _draggingObject.SetParent(_reorderableList.Content, false); - _draggingObject.rotation = _reorderableList.Content.transform.rotation; + if (!_reorderableList.KeepItemRotation) + { + _draggingObject.rotation = _reorderableList.Content.transform.rotation; + } _draggingObject.SetSiblingIndex(_fromIndex); From 0e8a588fcaf0d41488c9e75a49af62fec7f73356 Mon Sep 17 00:00:00 2001 From: hugoymh Date: Wed, 2 Oct 2024 16:03:06 +0800 Subject: [PATCH 05/17] UILineConnector point array calculation --- Runtime/Scripts/Primitives/UILineRenderer.cs | 4 -- Runtime/Scripts/Utilities/UILineConnector.cs | 57 +++++++++----------- 2 files changed, 26 insertions(+), 35 deletions(-) diff --git a/Runtime/Scripts/Primitives/UILineRenderer.cs b/Runtime/Scripts/Primitives/UILineRenderer.cs index 4f836c2c..35f4381d 100644 --- a/Runtime/Scripts/Primitives/UILineRenderer.cs +++ b/Runtime/Scripts/Primitives/UILineRenderer.cs @@ -499,10 +499,6 @@ protected override void OnEnable() { m_points = new Vector2[1]; } - if (transform.GetComponent().position != Vector3.zero) - { - Debug.LogWarning("A Line Renderer component should be on a RectTransform positioned at (0,0,0), do not use in child Objects.\nFor best results, create separate RectTransforms as children of the canvas positioned at (0,0) for a UILineRenderer and do not move."); - } } } } diff --git a/Runtime/Scripts/Utilities/UILineConnector.cs b/Runtime/Scripts/Utilities/UILineConnector.cs index 77a3fc93..454e2359 100644 --- a/Runtime/Scripts/Utilities/UILineConnector.cs +++ b/Runtime/Scripts/Utilities/UILineConnector.cs @@ -12,17 +12,13 @@ public class UILineConnector : MonoBehaviour // The elements between which line segments should be drawn public RectTransform[] transforms; private Vector3[] previousPositions; - private RectTransform canvas; + private Vector3 previousLrPos; private RectTransform rt; private UILineRenderer lr; + private void Awake() { - var canvasParent = GetComponentInParent().GetParentCanvas(); - if (canvasParent != null) - { - canvas = canvasParent.GetComponent(); - } rt = GetComponent(); lr = GetComponent(); } @@ -30,14 +26,26 @@ private void Awake() // Update is called once per frame void Update() { + if (lr.RelativeSize) + { + Debug.LogWarning("While using UILineConnector, UILineRenderer should not use relative size, so that even if this RectTransform has a zero-size Rect, the positions of the points can still be calculated"); + lr.RelativeSize = false; + } + if (transforms == null || transforms.Length < 1) { return; } - //Performance check to only redraw when the child transforms move - if (previousPositions != null && previousPositions.Length == transforms.Length) + + // Get world position of UILineRenderer + Vector3 lrWorldPos = rt.position; + + /*Performance check to only redraw when the child transforms move, + or the world position of UILineRenderer moves */ + bool updateLine = lrWorldPos != previousLrPos; + + if (!updateLine && previousPositions != null && previousPositions.Length == transforms.Length) { - bool updateLine = false; for (int i = 0; i < transforms.Length; i++) { if (transforms[i] == null) @@ -47,40 +55,24 @@ void Update() if (!updateLine && previousPositions[i] != transforms[i].position) { updateLine = true; + break; } } - if (!updateLine) return; - } + } + if (!updateLine) return; - // Get the pivot points - Vector2 thisPivot = rt.pivot; - Vector2 canvasPivot = canvas.pivot; - // Set up some arrays of coordinates in various reference systems - Vector3[] worldSpaces = new Vector3[transforms.Length]; - Vector3[] canvasSpaces = new Vector3[transforms.Length]; + // Calculate delta from the local position Vector2[] points = new Vector2[transforms.Length]; - - // First, convert the pivot to worldspace for (int i = 0; i < transforms.Length; i++) { if (transforms[i] == null) { continue; } - worldSpaces[i] = transforms[i].TransformPoint(thisPivot); - } - // Then, convert to canvas space - for (int i = 0; i < transforms.Length; i++) - { - canvasSpaces[i] = canvas.InverseTransformPoint(worldSpaces[i]); - } - - // Calculate delta from the canvas pivot point - for (int i = 0; i < transforms.Length; i++) - { - points[i] = new Vector2(canvasSpaces[i].x, canvasSpaces[i].y); + var offsetPos = rt.InverseTransformPoint(transforms[i].position); + points[i] = new Vector2(offsetPos.x, offsetPos.y); } // And assign the converted points to the line renderer @@ -88,6 +80,8 @@ void Update() lr.RelativeSize = false; lr.drivenExternally = true; + //save previous positions + previousLrPos = lrWorldPos; previousPositions = new Vector3[transforms.Length]; for (int i = 0; i < transforms.Length; i++) { @@ -97,6 +91,7 @@ void Update() } previousPositions[i] = transforms[i].position; } + } } } \ No newline at end of file From 0886131d180750e846f9b4f74b0e80d080847415 Mon Sep 17 00:00:00 2001 From: hugoymh Date: Wed, 2 Oct 2024 18:57:57 +0800 Subject: [PATCH 06/17] add refresh on change in global scale change --- Runtime/Scripts/Utilities/UILineConnector.cs | 49 +++++++++++++------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/Runtime/Scripts/Utilities/UILineConnector.cs b/Runtime/Scripts/Utilities/UILineConnector.cs index 454e2359..7423d53e 100644 --- a/Runtime/Scripts/Utilities/UILineConnector.cs +++ b/Runtime/Scripts/Utilities/UILineConnector.cs @@ -13,18 +13,27 @@ public class UILineConnector : MonoBehaviour public RectTransform[] transforms; private Vector3[] previousPositions; private Vector3 previousLrPos; + private Vector3 previousGlobalScale; private RectTransform rt; private UILineRenderer lr; - private void Awake() { rt = GetComponent(); lr = GetComponent(); } - // Update is called once per frame - void Update() + private void OnEnable() + { + if (transforms == null || transforms.Length < 1) + { + return; + } + + CalculateLinePoints(); + } + + private void Update() { if (lr.RelativeSize) { @@ -43,6 +52,7 @@ void Update() /*Performance check to only redraw when the child transforms move, or the world position of UILineRenderer moves */ bool updateLine = lrWorldPos != previousLrPos; + updateLine = rt.lossyScale != previousGlobalScale; if (!updateLine && previousPositions != null && previousPositions.Length == transforms.Length) { @@ -59,39 +69,44 @@ or the world position of UILineRenderer moves */ } } } - if (!updateLine) return; + if (!updateLine) return; // Calculate delta from the local position - Vector2[] points = new Vector2[transforms.Length]; + CalculateLinePoints(); + + + //save previous states + previousLrPos = lrWorldPos; + previousGlobalScale = rt.lossyScale; + previousPositions = new Vector3[transforms.Length]; for (int i = 0; i < transforms.Length; i++) { if (transforms[i] == null) { continue; } - - var offsetPos = rt.InverseTransformPoint(transforms[i].position); - points[i] = new Vector2(offsetPos.x, offsetPos.y); + previousPositions[i] = transforms[i].position; } + } - // And assign the converted points to the line renderer - lr.Points = points; - lr.RelativeSize = false; - lr.drivenExternally = true; - - //save previous positions - previousLrPos = lrWorldPos; - previousPositions = new Vector3[transforms.Length]; + private void CalculateLinePoints() + { + Vector2[] points = new Vector2[transforms.Length]; for (int i = 0; i < transforms.Length; i++) { if (transforms[i] == null) { continue; } - previousPositions[i] = transforms[i].position; + var offsetPos = rt.InverseTransformPoint(transforms[i].position); + points[i] = new Vector2(offsetPos.x, offsetPos.y); } + // And assign the converted points to the line renderer + lr.Points = points; + lr.RelativeSize = false; + lr.drivenExternally = true; } } } \ No newline at end of file From 45e5ab6810ce80b7bb423d649ab6188af8b0a652 Mon Sep 17 00:00:00 2001 From: "Simon (Darkside) Jackson" Date: Fri, 4 Oct 2024 12:26:05 +0100 Subject: [PATCH 07/17] Update workflows to latest --- .../getpackageversionfrompackage.yml | 4 +- .../workflows/rununitybuildmultiversion.yml | 103 ++++++++++-------- .github/workflows/rununitysinglebuild.yml | 49 +++++---- .github/workflows/tagrelease.yml | 8 +- .github/workflows/upversionandtagrelease.yml | 12 +- 5 files changed, 96 insertions(+), 80 deletions(-) diff --git a/.github/workflows/getpackageversionfrompackage.yml b/.github/workflows/getpackageversionfrompackage.yml index 32c56da3..30d93aef 100644 --- a/.github/workflows/getpackageversionfrompackage.yml +++ b/.github/workflows/getpackageversionfrompackage.yml @@ -25,11 +25,11 @@ jobs: - name: Script Version run: | echo "::group::Script Versioning" - $scriptVersion = "1.0.0" + $scriptVersion = "1.0.1" echo "Build Script Version: $scriptVersion" echo "::endgroup::" shell: pwsh - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: recursive clean: true diff --git a/.github/workflows/rununitybuildmultiversion.yml b/.github/workflows/rununitybuildmultiversion.yml index ee228ee9..b3f9f193 100644 --- a/.github/workflows/rununitybuildmultiversion.yml +++ b/.github/workflows/rununitybuildmultiversion.yml @@ -63,27 +63,31 @@ jobs: - os: windows unityVersion: 2022.3 build-target: WSAPlayer - - os: windows - unityVersion: 2023.1 + - os: windows + unityVersion: 6000.0 build-target: Android - - os: macOS - unityVersion: 2023.1 - build-target: iOS - os: windows - unityVersion: 2023.1 + unityVersion: 6000.0 build-target: StandaloneWindows64 - os: windows - unityVersion: 2023.1 - build-target: WSAPlayer + unityVersion: 6000.0 + build-target: WSAPlayer + - os: macos + unityVersion: 6000.0 + build-target: iOS + - os: macos + unityVersion: 6000.0 + build-target: StandaloneOSX + steps: - name: Script Version run: | echo "::group::Script Versioning" - $scriptVersion = "1.0.0" + $scriptVersion = "1.0.1" echo "Build Script Version: $scriptVersion" echo "::endgroup::" shell: pwsh - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: recursive clean: true @@ -91,8 +95,8 @@ jobs: - id: build name: 'Run Unity Builds' run: | - echo "::group::Set Hub and editor locations" $unityVersion = '${{ matrix.unityVersion }}' + $unityMajorVersion = $unityVersion.Substring(0, 4) echo "::group::Set Hub and editor locations" @@ -100,43 +104,46 @@ jobs: if ( (-not $global:PSVersionTable.Platform) -or ($global:PSVersionTable.Platform -eq "Win32NT") ) { $hubPath = "C:\Program Files\Unity Hub\Unity Hub.exe" - $editorRootPath = "C:\Program Files\Unity\Hub\Editor\" - $editorFileEx = "\Editor\Unity.exe" - $directorySeparatorChar = "\" #"Unity Hub.exe" -- --headless help #. 'C:\Program Files\Unity Hub\Unity Hub.exe' -- --headless help function unity-hub + { + & $hubPath -- --headless $args.Split(" ") | Out-String + } + function unity-hub-raw { & $hubPath -- --headless $args.Split(" ") | Out-String -NoNewline - } + } } elseif ( $global:PSVersionTable.OS.Contains("Darwin") ) { - $hubPath = "/Applications/Unity Hub.app/Contents/macOS/Unity Hub" - $editorRootPath = "/Applications/Unity/Hub/Editor/" - $editorFileEx = "/Unity.app/Contents/macOS/Unity" - $directorySeparatorChar = "/" + $hubPath = "/Applications/Unity Hub.app/Contents/MacOS/Unity Hub" - # /Applications/Unity\ Hub.app/Contents/macOS/Unity\ Hub -- --headless help + # /Applications/Unity\ Hub.app/Contents/MacOS/Unity\ Hub -- --headless help function unity-hub + { + & $hubPath -- --headless $args.Split(" ") | Out-String + } + function unity-hub-raw { & $hubPath -- --headless $args.Split(" ") | Out-String -NoNewline - } + } } elseif ( $global:PSVersionTable.OS.Contains("Linux") ) { $hubPath = "$HOME/Unity Hub/UnityHub.AppImage" - $editorRootPath = "$HOME/Unity/Hub/Editor/" - $editorFileEx = "/Editor/Unity" - $directorySeparatorChar = "/" # /UnityHub.AppImage --headless help # xvfb-run --auto-servernum "$HOME/Unity Hub/UnityHub.AppImage" --headless help function unity-hub { xvfb-run --auto-servernum "$hubPath" --headless $args.Split(" ") - } + } + function unity-hub-raw + { + xvfb-run --auto-servernum "$hubPath" --headless $args.Split(" ") + } } echo "::endgroup::" @@ -168,7 +175,7 @@ jobs: echo "Requested unity version is {$unityVersion}" $InstalledUnityVersions = unity-hub editors - $editorRootPath = unity-hub ip -g + $editorRootPath = unity-hub-raw ip -g echo "Installed unity versions are {$InstalledUnityVersions}" echo "Unity install path is {$editorRootPath}" @@ -230,7 +237,7 @@ jobs: } elseif ( $global:PSVersionTable.OS.Contains("Darwin") ) { echo 'Building using Mac' - $editorFileEx = "/Unity.app/Contents/macOS/Unity" + $editorFileEx = "/Unity.app/Contents/MacOS/Unity" $editorrunpath = Join-Path $editorRootPath $unityVersion $editorFileEx function unity-editor { @@ -267,7 +274,7 @@ jobs: echo "::endgroup::" - echo "::group::Setup logging and run Unit tests" + echo "::group::Setup logging and run Unit tests" # Log detail $logDirectory = "Logs" @@ -283,14 +290,13 @@ jobs: # If run manually, the Refname is actually blank, so just use date if([string]::IsNullOrEmpty(${GITHUB_REF_NAME})) { - $logName = "$logDirectory$directorySeparatorChar$date" - } - else{ - $logName = "$logDirectory$directorySeparatorChar${GITHUB_REF_NAME}-$date" + $logName = Join-Path $logDirectory $date + }else { + $logName = Join-Path $logDirectory ${GITHUB_REF_NAME}-$date } - $logPath = "$logName.log" - $testsLogPath = "$logName-tests.xml" + $logPath = "$unityMajorVersion_${{ matrix.build-target }}_$logName.log" + $testsLogPath = "$unityMajorVersion_${{ matrix.build-target }}_$logName-tests.xml" echo "Logpath [$logPath]" echo "TestsPath [$testsLogPath]" @@ -313,9 +319,20 @@ jobs: $TempUnityProjectName = 'P' - unity-editor '-createProject' $TempUnityProjectName -quit + unity-editor '-createProject' $TempUnityProjectName '-logFile' $logPath '-quit' - $destinationPath = $TempUnityProjectName + $directorySeparatorChar + 'packages' + if ( -not (Test-Path "$TempUnityProjectName") ) + { + $ProjectPath = Get-Location + Write-Error "Editor failed to create project not Found $ProjectPath/$TempUnityProjectName" + exit 1 + } + else { + $ProjectPath = Get-Location + echo "Editor project created at $ProjectPath/$TempUnityProjectName" + } + + $destinationPath = Join-Path $TempUnityProjectName 'packages' Move-Item -Path $UPMFolderName -Destination $destinationPath echo "::endgroup::" @@ -348,10 +365,9 @@ jobs: # Read dependancy input value $dependencies = '${{ inputs.dependencies }}' - if([string]::IsNullOrEmpty('${{ secrets.GIT_USER_NAME }}') -or [string]::IsNullOrEmpty('${{ secrets.GIT_PAT }}')){ + if([string]::IsNullOrEmpty('${{ github.actor }}') -or [string]::IsNullOrEmpty('${{ secrets.GITHUB_TOKEN }}')){ echo "" - echo "Secrets for GIT_USER_NAME or GIT_PAT missing, please register them with access to this runner" - echo "*Note, Organisation secrets are not accessible to Forked repos and need registering in the local fork" + echo "Insufficient credentials supplied to activate the workflow" exit 1 } @@ -362,7 +378,7 @@ jobs: echo $JSONdependencies # Read current Manifest json - $manifestPath = $destinationPath + $directorySeparatorChar + 'manifest.json' + $manifestPath = Join-Path $destinationPath 'manifest.json' $projectManifest = Get-Content -Path $manifestPath | ConvertFrom-Json $strArray = $projectManifest.dependencies.PsObject.Properties | ForEach-Object {"$($_.Name)@$($_.Value),"} @@ -375,7 +391,7 @@ jobs: $dependencyURL = $_.Value echo "---------------------------------------------" echo "Cloning dependency - Name [$dependencyName] - Path [$dependencyPath] - URL [$dependencyURL]" - $cloneURL = "https://${{ secrets.GIT_USER_NAME }}:${{ secrets.GIT_PAT }}@$dependencyURL" + $cloneURL = "https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@$dependencyURL" echo "cloning $dependencyName from $dependencyURL and moving to $destinationPath" echo "git path - $cloneURL" @@ -431,7 +447,7 @@ jobs: echo "::endgroup::" - echo "::group::Run build" + echo "::group::Run build" echo "---------------------------------------------" echo "Start Testing" @@ -461,11 +477,10 @@ jobs: exit $LASTEXITCODE } - echo "::endgroup::" shell: pwsh - uses: actions/upload-artifact@v3 if: always() with: - name: unity-build-log + name: unity-build-log-${{ matrix.unityVersion }}-${{ matrix.build-target }} path: Logs/** \ No newline at end of file diff --git a/.github/workflows/rununitysinglebuild.yml b/.github/workflows/rununitysinglebuild.yml index d6ba2836..7d792f4d 100644 --- a/.github/workflows/rununitysinglebuild.yml +++ b/.github/workflows/rununitysinglebuild.yml @@ -32,18 +32,17 @@ jobs: - name: Script Version run: | echo "::group::Script Versioning" - $scriptVersion = "1.0.0" + $scriptVersion = "1.0.1" echo "Build Script Version: $scriptVersion" echo "::endgroup::" shell: pwsh - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: recursive clean: true - id: build name: 'Run Unity Builds' run: | - echo "::group::Set Hub and editor locations" $unityVersion = '${{ inputs.unityVersion }}' echo "::group::Set Hub and editor locations" @@ -53,8 +52,6 @@ jobs: { $hubPath = "C:\Program Files\Unity Hub\Unity Hub.exe" $editorRootPath = "C:\Program Files\Unity\Hub\Editor\" - $editorFileEx = "\Editor\Unity.exe" - $directorySeparatorChar = "\" #"Unity Hub.exe" -- --headless help #. 'C:\Program Files\Unity Hub\Unity Hub.exe' -- --headless help @@ -67,8 +64,6 @@ jobs: { $hubPath = "/Applications/Unity Hub.app/Contents/MacOS/Unity Hub" $editorRootPath = "/Applications/Unity/Hub/Editor/" - $editorFileEx = "/Unity.app/Contents/MacOS/Unity" - $directorySeparatorChar = "/" # /Applications/Unity\ Hub.app/Contents/MacOS/Unity\ Hub -- --headless help function unity-hub @@ -80,8 +75,6 @@ jobs: { $hubPath = "$HOME/Unity Hub/UnityHub.AppImage" $editorRootPath = "$HOME/Unity/Hub/Editor/" - $editorFileEx = "/Editor/Unity" - $directorySeparatorChar = "/" # /UnityHub.AppImage --headless help # xvfb-run --auto-servernum "$HOME/Unity Hub/UnityHub.AppImage" --headless help @@ -235,10 +228,9 @@ jobs: # If run manually, the Refname is actually blank, so just use date if([string]::IsNullOrEmpty(${GITHUB_REF_NAME})) { - $logName = "$logDirectory$directorySeparatorChar$date" - } - else{ - $logName = "$logDirectory$directorySeparatorChar${GITHUB_REF_NAME}-$date" + $logName = Join-Path $logDirectory $date + }else { + $logName = Join-Path $logDirectory ${GITHUB_REF_NAME}-$date } $logPath = "$logName.log" @@ -265,9 +257,20 @@ jobs: $TempUnityProjectName = 'P' - unity-editor '-createProject' $TempUnityProjectName -quit + unity-editor '-createProject' $TempUnityProjectName '-logFile' $logPath '-quit' - $destinationPath = $TempUnityProjectName + $directorySeparatorChar + 'packages' + if ( -not (Test-Path "$TempUnityProjectName") ) + { + $ProjectPath = Get-Location + Write-Error "Editor failed to create project not Found $ProjectPath/$TempUnityProjectName" + exit 1 + } + else { + $ProjectPath = Get-Location + echo "Editor project created at $ProjectPath/$TempUnityProjectName" + } + + $destinationPath = Join-Path $TempUnityProjectName 'packages' Move-Item -Path $UPMFolderName -Destination $destinationPath echo "::endgroup::" @@ -300,10 +303,9 @@ jobs: # Read dependancy input value $dependencies = '${{ inputs.dependencies }}' - if([string]::IsNullOrEmpty('${{ secrets.GIT_USER_NAME }}') -or [string]::IsNullOrEmpty('${{ secrets.GIT_PAT }}')){ + if([string]::IsNullOrEmpty('${{ github.actor }}') -or [string]::IsNullOrEmpty('${{ secrets.GITHUB_TOKEN }}')){ echo "" - echo "Secrets for GIT_USER_NAME or GIT_PAT missing, please register them with access to this runner" - echo "*Note, Organisation secrets are not accessible to Forked repos and need registering in the local fork" + echo "Insufficient credentials supplied to activate the workflow" exit 1 } @@ -314,7 +316,7 @@ jobs: echo $JSONdependencies # Read current Manifest json - $manifestPath = $destinationPath + $directorySeparatorChar + 'manifest.json' + $manifestPath = Join-Path $destinationPath 'manifest.json' $projectManifest = Get-Content -Path $manifestPath | ConvertFrom-Json $strArray = $projectManifest.dependencies.PsObject.Properties | ForEach-Object {"$($_.Name)@$($_.Value),"} @@ -327,7 +329,7 @@ jobs: $dependencyURL = $_.Value echo "---------------------------------------------" echo "Cloning dependency - Name [$dependencyName] - Path [$dependencyPath] - URL [$dependencyURL]" - $cloneURL = "https://${{ secrets.GIT_USER_NAME }}:${{ secrets.GIT_PAT }}@$dependencyURL" + $cloneURL = "https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@$dependencyURL" echo "cloning $dependencyName from $dependencyURL and moving to $destinationPath" echo "git path - $cloneURL" @@ -413,11 +415,10 @@ jobs: exit $LASTEXITCODE } - echo "::endgroup::" shell: pwsh - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 if: always() with: - name: unity-build-log - path: Logs/** \ No newline at end of file + name: unity-build-log-${{ matrix.build-target }} + path: Logs/** \ No newline at end of file diff --git a/.github/workflows/tagrelease.yml b/.github/workflows/tagrelease.yml index d572d768..fddc3822 100644 --- a/.github/workflows/tagrelease.yml +++ b/.github/workflows/tagrelease.yml @@ -27,17 +27,17 @@ jobs: - name: Script Version run: | echo "::group::Script Versioning" - $scriptVersion = "1.0.2" + $scriptVersion = "1.0.3" echo "Build Script Version: $scriptVersion" echo "::endgroup::" shell: pwsh - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 submodules: recursive clean: true token: ${{ secrets.GIT_PAT }} - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v4 - name: Set Github vars run: | if([string]::IsNullOrEmpty('${{ secrets.GIT_USER_NAME }}')){ @@ -74,6 +74,6 @@ jobs: - name: Create tag and push run: | $tagVersion = "${{ inputs.version }}" - git tag -fa "v$tagVersion" "${GITHUB_SHA}" -m "v$tagVersion Release [skip ci]" + git tag -fa "v$tagVersion" -m "v$tagVersion Release [skip ci]" git push origin "v$tagVersion" --force shell: pwsh \ No newline at end of file diff --git a/.github/workflows/upversionandtagrelease.yml b/.github/workflows/upversionandtagrelease.yml index 4e630ba9..8c8882ba 100644 --- a/.github/workflows/upversionandtagrelease.yml +++ b/.github/workflows/upversionandtagrelease.yml @@ -31,8 +31,8 @@ on: description: "Returns the version of Unity the UPM package requires" value: ${{ jobs.packageRelease.outputs.packageversion }} secrets: - GIT_PAT: - required: true + GIT_USER_NAME: + required: false jobs: packageRelease: @@ -44,18 +44,18 @@ jobs: - name: Script Version run: | echo "::group::Script Versioning" - $scriptVersion = "1.0.2" + $scriptVersion = "1.0.3" echo "Build Script Version: $scriptVersion" echo "::endgroup::" shell: pwsh - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: ref: ${{ inputs.target-branch }} fetch-depth: 0 submodules: recursive clean: true token: ${{ secrets.GIT_PAT }} - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v4 - name: Set Github vars run: | if([string]::IsNullOrEmpty('${{ secrets.GIT_USER_NAME }}')){ @@ -176,6 +176,6 @@ jobs: if: ${{inputs.createTag == true}} run: | $outputVersion = '${{steps.getpackageversion.outputs.packageversion }}' - git tag -fa "v$outputVersion" "${GITHUB_SHA}" -m "v$outputVersion Release" + git tag -fa "v$outputVersion" -m "v$outputVersion Release" git push origin "v$outputVersion" --force --tags shell: pwsh \ No newline at end of file From 16e8f172fcf3d8b52114c9a52b8ff1e77e613ffb Mon Sep 17 00:00:00 2001 From: "Simon (Darkside) Jackson" Date: Fri, 4 Oct 2024 12:26:45 +0100 Subject: [PATCH 08/17] Fix spacing --- .github/workflows/rununitybuildmultiversion.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rununitybuildmultiversion.yml b/.github/workflows/rununitybuildmultiversion.yml index b3f9f193..50e88d7f 100644 --- a/.github/workflows/rununitybuildmultiversion.yml +++ b/.github/workflows/rununitybuildmultiversion.yml @@ -63,7 +63,7 @@ jobs: - os: windows unityVersion: 2022.3 build-target: WSAPlayer - - os: windows + - os: windows unityVersion: 6000.0 build-target: Android - os: windows From b20f567a702af18b14e5d29d0943d6d97ed90b36 Mon Sep 17 00:00:00 2001 From: action Date: Fri, 4 Oct 2024 12:16:36 +0000 Subject: [PATCH 09/17] Auto increment pre-release version to 2.3.3-pre.1 [skip ci] --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 70ac69b1..ae04d038 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "com.unity.uiextensions", "displayName": "Unity UI Extensions", - "version": "2.3.3", + "version": "2.3.3-pre.1", "description": "An extension project for the Unity3D UI system, all crafted and contributed by the awesome Unity community", "author": "Simon darkside Jackson <@SimonDarksideJ>", "contributors": [ From 39a3b8dbf54f34d4851187c0f6239bfc80c5a0d4 Mon Sep 17 00:00:00 2001 From: hugoymh <34024260+hugoymh@users.noreply.github.com> Date: Sat, 29 Mar 2025 23:10:05 +0800 Subject: [PATCH 10/17] force ScrollRect.content setup (#485) --- Runtime/Scripts/Layout/ScrollSnapBase.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Runtime/Scripts/Layout/ScrollSnapBase.cs b/Runtime/Scripts/Layout/ScrollSnapBase.cs index d200bef0..bca4aa1b 100644 --- a/Runtime/Scripts/Layout/ScrollSnapBase.cs +++ b/Runtime/Scripts/Layout/ScrollSnapBase.cs @@ -189,6 +189,11 @@ void Awake() _screensContainer = _scroll_rect.content; + //ScrollRect.content RT anchors has to be stretched first in order for HSS/VSS.DistributePages() to have the correct result + _screensContainer.anchorMin = Vector2.zero; + _screensContainer.anchorMax = Vector2.one; + _screensContainer.sizeDelta = Vector2.zero; + InitialiseChildObjects(); if (NextButton) From 7b47f8647a09416b7ca64bc60981fd5f96b813ff Mon Sep 17 00:00:00 2001 From: hugoymh <34024260+hugoymh@users.noreply.github.com> Date: Thu, 27 Nov 2025 18:02:39 +0800 Subject: [PATCH 11/17] Compile flag support for Unity6 (#493) * Update CardPopup2D.cs add support for Unity 6 api * Gradient2.ModifyMesh Modify Mesh should respond to gradient key updates in inspector and runtime --- Runtime/Scripts/Effects/Gradient2.cs | 4 ++-- Runtime/Scripts/Layout/CardUI/2D Cards/CardPopup2D.cs | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Runtime/Scripts/Effects/Gradient2.cs b/Runtime/Scripts/Effects/Gradient2.cs index cbb0485d..c82bb0c7 100644 --- a/Runtime/Scripts/Effects/Gradient2.cs +++ b/Runtime/Scripts/Effects/Gradient2.cs @@ -475,7 +475,7 @@ List FindStops(float zoomOffset, Rect bounds, List stops) var startBoundary = zoomOffset - offset; var endBoundary = (1 - zoomOffset) - offset; - if (_colorKeys == null) _colorKeys = EffectGradient.colorKeys; + _colorKeys = EffectGradient.colorKeys; foreach (var color in _colorKeys) { @@ -485,7 +485,7 @@ List FindStops(float zoomOffset, Rect bounds, List stops) stops.Add((color.time - startBoundary) * Zoom); } - if (_alphaKeys == null) _alphaKeys = _effectGradient.alphaKeys; + _alphaKeys = _effectGradient.alphaKeys; foreach (var alpha in _alphaKeys) { diff --git a/Runtime/Scripts/Layout/CardUI/2D Cards/CardPopup2D.cs b/Runtime/Scripts/Layout/CardUI/2D Cards/CardPopup2D.cs index 14ce7899..a3c4c68d 100644 --- a/Runtime/Scripts/Layout/CardUI/2D Cards/CardPopup2D.cs +++ b/Runtime/Scripts/Layout/CardUI/2D Cards/CardPopup2D.cs @@ -57,8 +57,12 @@ void Update() { isFalling = false; rbody.useGravity = false; - rbody.velocity = Vector3.zero; - transform.position = new Vector3(0, 8, startZPos); +#if UNITY_6000_0_OR_NEWER + rbody.linearVelocity = Vector3.zero; +#else + rbody.velocity = Vector3.zero; +#endif + transform.position = new Vector3(0, 8, startZPos); if (singleScene) { CardEnter(); From e445537c42fe066ee3c902cc622c6d9dd28919a5 Mon Sep 17 00:00:00 2001 From: Ben MacKinnon Date: Thu, 27 Nov 2025 10:05:08 +0000 Subject: [PATCH 12/17] UILineConnector point array calculation (#495) In #480 the check for a change in length of transforms in a Line Connector was changed, resulting in the UILineRenderer not being updated when new points were added to the UILineConnector. This PR restores that check. --- Runtime/Scripts/Utilities/UILineConnector.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Runtime/Scripts/Utilities/UILineConnector.cs b/Runtime/Scripts/Utilities/UILineConnector.cs index 7423d53e..77bc63ee 100644 --- a/Runtime/Scripts/Utilities/UILineConnector.cs +++ b/Runtime/Scripts/Utilities/UILineConnector.cs @@ -54,7 +54,12 @@ or the world position of UILineRenderer moves */ bool updateLine = lrWorldPos != previousLrPos; updateLine = rt.lossyScale != previousGlobalScale; - if (!updateLine && previousPositions != null && previousPositions.Length == transforms.Length) + if (!updateLine) + { + updateLine = previousPositions.Length != transforms.Length; + } + + if (!updateLine && previousPositions != null) { for (int i = 0; i < transforms.Length; i++) { From 83364ba013cd0d9d336a171a9cbda2535818e763 Mon Sep 17 00:00:00 2001 From: "Simon (Darkside) Jackson" Date: Thu, 27 Nov 2025 10:08:47 +0000 Subject: [PATCH 13/17] Disabiling automatic automation until actions can be updated (known issue due to changes in Unity) --- .github/workflows/development-buildandtestupmrelease.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/development-buildandtestupmrelease.yml b/.github/workflows/development-buildandtestupmrelease.yml index a61bebac..4cd985cd 100644 --- a/.github/workflows/development-buildandtestupmrelease.yml +++ b/.github/workflows/development-buildandtestupmrelease.yml @@ -1,9 +1,9 @@ name: Build and test UPM packages for platforms, all branches except main on: - pull_request: - branches-ignore: - - 'release' + # pull_request: + # branches-ignore: + # - 'release' # Ignore PRs targeting main # Allows you to run this workflow manually from the Actions tab From d489c9f0957490c2cbc269a2b426a04cc02c95ee Mon Sep 17 00:00:00 2001 From: "Simon (Darkside) Jackson" Date: Tue, 2 Dec 2025 16:05:17 +0000 Subject: [PATCH 14/17] Update automation to latest for existing release (#516) --- .../development-buildandtestupmrelease.yml | 95 +++- .github/workflows/development-publish.yml | 26 - .../getpackageversionfrompackage.yml | 70 --- .github/workflows/main-publish.yml | 91 ---- .github/workflows/refreshbranch.yml | 43 -- .../workflows/rununitybuildmultiversion.yml | 486 ------------------ .github/workflows/rununitysinglebuild.yml | 424 --------------- .github/workflows/tagrelease.yml | 79 --- .github/workflows/upversionandtagrelease.yml | 181 ------- 9 files changed, 78 insertions(+), 1417 deletions(-) delete mode 100644 .github/workflows/development-publish.yml delete mode 100644 .github/workflows/getpackageversionfrompackage.yml delete mode 100644 .github/workflows/main-publish.yml delete mode 100644 .github/workflows/refreshbranch.yml delete mode 100644 .github/workflows/rununitybuildmultiversion.yml delete mode 100644 .github/workflows/rununitysinglebuild.yml delete mode 100644 .github/workflows/tagrelease.yml delete mode 100644 .github/workflows/upversionandtagrelease.yml diff --git a/.github/workflows/development-buildandtestupmrelease.yml b/.github/workflows/development-buildandtestupmrelease.yml index 4cd985cd..e2133b94 100644 --- a/.github/workflows/development-buildandtestupmrelease.yml +++ b/.github/workflows/development-buildandtestupmrelease.yml @@ -1,9 +1,9 @@ name: Build and test UPM packages for platforms, all branches except main on: - # pull_request: - # branches-ignore: - # - 'release' + pull_request: + branches-ignore: + - 'main' # Ignore PRs targeting main # Allows you to run this workflow manually from the Actions tab @@ -13,18 +13,79 @@ concurrency: group: ${{ github.ref }} cancel-in-progress: true +# Ensure default token scopes and inherit org-level secrets via env mapping +permissions: + contents: write + packages: read + +env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GIT_PAT: ${{ secrets.GIT_PAT }} + jobs: - # Check Unity version required by the package - # Run Unity build unit tests defined in the package for a single version for feature branches - Run-Partial-Unit-Tests: - name: Run Unity Unit Tests - if: github.ref != 'refs/heads/development' - uses: ./.github/workflows/rununitysinglebuild.yml - with: - unityversion: 2020.3 - - # Run Unity multi-version build unit tests defined in the package for the development branch - Run-Full-Unit-Tests: - name: Run Unity Unit Tests - if: github.ref == 'refs/heads/development' - uses: ./.github/workflows/rununitybuildmultiversion.yml \ No newline at end of file + test-unity-build: + name: Test Unity UPM Build + runs-on: ${{ matrix.os }} + if: always() + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + unity-version: + - 2019 + - 2020 + - 2021 + - 2022 + - 6000.0.x + - 6000 + include: + - os: ubuntu-latest + build-targets: StandaloneLinux64, Android + - os: windows-latest + build-targets: StandaloneWindows64 + - os: macos-latest + build-targets: StandaloneOSX, iOS + steps: + - uses: buildalon/unity-setup@v2 + id: unity-setup + with: + version-file: "None" + unity-version: ${{ matrix.unity-version }} # overrides version in version-file + build-targets: ${{ matrix.build-targets }} + + - run: | + echo "Step Outputs:" + echo "steps.unity-setup.unity-hub-path: '${{ steps.unity-setup.outputs.unity-hub-path }}'" + echo "steps.unity-setup.unity-editors: '${{ steps.unity-setup.outputs.unity-editors }}'" + echo "steps.unity-setup.unity-editor-path: '${{ steps.unity-setup.outputs.unity-editor-path }}'" + echo "steps.unity-setup.unity-project-path: '${{ steps.unity-setup.outputs.unity-project-path }}'" + + echo "Environment Variables:" + echo "UNITY_HUB_PATH: '${{ env.UNITY_HUB_PATH }}'" + echo "UNITY_EDITORS: '${{ env.UNITY_EDITORS }}'" + echo "UNITY_EDITOR_PATH: '${{ env.UNITY_EDITOR_PATH }}'" + echo "UNITY_PROJECT_PATH: '${{ env.UNITY_PROJECT_PATH }}'" + + - uses: buildalon/activate-unity-license@v2 + if: runner.environment == 'github-hosted' + with: + license: "Personal" # Choose license type to use [ Personal, Professional, Floating ] + username: ${{ secrets.UNITY_USER}} + password: ${{ secrets.UNITY_ACC}} + + - uses: buildalon/create-unity-project@v2 + id: create-unity-project + with: + project-name: P + + - name: Setup Unity UPM Build + uses: realitycollective/reality-collective-actions/setup-unity-upm-build@v1 + with: + unity-project-path: ${{ steps.create-unity-project.outputs.project-path }} + + - name: Run Unity Build + uses: realitycollective/reality-collective-actions/run-unity-multitarget-build@v1 + with: + unity-editor-path: ${{ steps.unity-setup.outputs.unity-editor-path }} + unity-project-path: ${{ steps.create-unity-project.outputs.project-path }} + build-targets: ${{ matrix.build-targets }} \ No newline at end of file diff --git a/.github/workflows/development-publish.yml b/.github/workflows/development-publish.yml deleted file mode 100644 index a770e9d8..00000000 --- a/.github/workflows/development-publish.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Publish development branch on Merge - -on: - pull_request: - types: - - closed - branches: - - development - # On close of PR targeting development - - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - -concurrency: - group: ${{ github.ref }} - cancel-in-progress: true - -jobs: - release_on_merge: - if: github.event.pull_request.merged == true - name: Tag and Publish UPM package - uses: ./.github/workflows/upversionandtagrelease.yml - with: - build-host: ubuntu-latest - build-type: pre-release - secrets: inherit \ No newline at end of file diff --git a/.github/workflows/getpackageversionfrompackage.yml b/.github/workflows/getpackageversionfrompackage.yml deleted file mode 100644 index 30d93aef..00000000 --- a/.github/workflows/getpackageversionfrompackage.yml +++ /dev/null @@ -1,70 +0,0 @@ -name: Get the Package version from a UPM Package.json file - -on: - workflow_call: - inputs: - build-host: - required: true - type: string - version-file-path: - description: 'Optional, specify a path to search for the upm package.json file. Use this if validation fails to find a valid package.json file.\n **Note, Version file MUST contain the attribute "Unity" with the full Unity version expected, e.g. "2020.2.3f1"' - type: string - required: false - outputs: - packageversion: - description: "Returns the version of the UPM package" - value: ${{ jobs.get_package_version.outputs.upmpackageversion }} - -jobs: - get_package_version: - name: Get required Package version from UPM Package - runs-on: ${{ inputs.build-host }} - outputs: - upmpackageversion: ${{ steps.getVersion.outputs.packageversion }} - steps: - - name: Script Version - run: | - echo "::group::Script Versioning" - $scriptVersion = "1.0.1" - echo "Build Script Version: $scriptVersion" - echo "::endgroup::" - shell: pwsh - - uses: actions/checkout@v4 - with: - submodules: recursive - clean: true - - id: getVersion - name: 'Get Package Version Number' - run: | - echo "::group::Validating input" - - $versionFile = "${{ inputs.version-file-path }}" - if([string]::IsNullOrEmpty($versionFile)) - { - echo 'version input was empty, using default' - $versionFile = 'package.json' - } - echo 'Checking for project json at $versionFile' - - if ( -not (Test-Path -Path $versionFile) ) { - Write-Error "Failed to find a valid package.json file" - exit 1 - } - - echo "::endgroup::" - - echo "::group::Package Version UPM check" - - $package_json = Get-Content -Path $versionFile | ConvertFrom-Json - $packageVersion = $package_json.version - - if([string]::IsNullOrEmpty($packageVersion)) { - Write-Error "Project.json version number does not exist or is empty" - exit 1 - } - - echo "packageversion=$packageVersion" >> $env:GITHUB_OUTPUT - - echo "Detected version is $packageVersion" - echo "::endgroup::" - shell: pwsh \ No newline at end of file diff --git a/.github/workflows/main-publish.yml b/.github/workflows/main-publish.yml deleted file mode 100644 index f667dc63..00000000 --- a/.github/workflows/main-publish.yml +++ /dev/null @@ -1,91 +0,0 @@ -name: Publish main branch and increment version - -on: - pull_request: - types: - - closed - branches: - - release - -jobs: - # Get Version to tag and release the branch, no up-version - [no-ver] included in PR title - validate-environment: - if: github.event.pull_request.merged == true && contains(github.event.pull_request.title, 'no-ver') - name: Get Version from UPM package - uses: ./.github/workflows/getpackageversionfrompackage.yml - with: - build-host: ubuntu-latest - - # Perform tagging - release-Package-only: - needs: validate-environment - name: Release package only, no upversion - uses: ./.github/workflows/tagrelease.yml - with: - build-host: ubuntu-latest - version: ${{ needs.validate-environment.outputs.packageversion }} - secrets: inherit - - # Up version the release and publish major release - upversion-major-Package: - if: github.event.pull_request.merged == true && contains(github.event.pull_request.title, 'no-ver') == false && contains(github.event.pull_request.title, 'major-release') - name: Major Version package and release - uses: ./.github/workflows/upversionandtagrelease.yml - with: - build-host: ubuntu-latest - build-type: major - secrets: inherit - - # Up version the release and publish minor release - upversion-minor-Package: - if: github.event.pull_request.merged == true && contains(github.event.pull_request.title, 'no-ver') == false && contains(github.event.pull_request.title, 'minor-release') - name: Minor Version package and release - uses: ./.github/workflows/upversionandtagrelease.yml - with: - build-host: ubuntu-latest - build-type: minor - secrets: inherit - - # Up version the release and publish patch release (default) - upversion-patch-Package: - if: github.event.pull_request.merged == true && contains(github.event.pull_request.title, 'no-ver') == false && contains(github.event.pull_request.title, 'minor-release') == false && contains(github.event.pull_request.title, 'major-release') == false - name: Patch Version package and release - uses: ./.github/workflows/upversionandtagrelease.yml - with: - build-host: ubuntu-latest - build-type: patch-release - secrets: inherit - - release-Complete: - if: ${{ always() }} - needs: [upversion-major-Package, upversion-minor-Package, upversion-patch-Package, release-Package-only] - name: Release complete - runs-on: ubuntu-latest - steps: - - name: Script Version - run: echo "Release done, updating Development" - - # Refresh the development branch with the main publish - refresh-development: - if: ${{ always() }} - needs: [release-Complete] - name: Refresh development branch - uses: ./.github/workflows/refreshbranch.yml - with: - build-host: ubuntu-latest - target-branch: development - source-branch: main - secrets: inherit - - # Up version the development branch ready for future development - upversion-development: - if: ${{ always() }} - needs: [refresh-development] - name: UpVersion the development branch for the next release - uses: ./.github/workflows/upversionandtagrelease.yml - with: - build-host: ubuntu-latest - build-type: patch - target-branch: development - createTag: false - secrets: inherit \ No newline at end of file diff --git a/.github/workflows/refreshbranch.yml b/.github/workflows/refreshbranch.yml deleted file mode 100644 index fb8a0215..00000000 --- a/.github/workflows/refreshbranch.yml +++ /dev/null @@ -1,43 +0,0 @@ -name: Refresh branch - -on: - workflow_call: - inputs: - build-host: - required: true - type: string - target-branch: - required: true - type: string - source-branch: - required: true - type: string - -concurrency: - group: ${{ github.ref }} - cancel-in-progress: true - -jobs: - packageRelease: - name: Refresh ${{ inputs.target-branch }} branch from ${{ inputs.source-branch }} branch - runs-on: ${{ inputs.build-host }} - steps: - - name: Script Version - run: | - echo "::group::Script Versioning" - $scriptVersion = "1.0.1" - echo "Build Script Version: $scriptVersion" - echo "::endgroup::" - shell: pwsh - - uses: actions/checkout@v3 - with: - ref: ${{ inputs.target-branch }} - clean: true - token: ${{ secrets.GIT_PAT }} - - name: Refresh from Source Branch - run: | - git pull origin ${{ inputs.source-branch }} - git commit -m "Branch ${{ inputs.target-branch }} updated with changes from ${{ inputs.source-branch }} [skip ci]" - git push origin ${{ inputs.target-branch }} - echo "Branch ${{ inputs.target-branch }} updated with changes from ${{ inputs.source-branch }}" - shell: pwsh \ No newline at end of file diff --git a/.github/workflows/rununitybuildmultiversion.yml b/.github/workflows/rununitybuildmultiversion.yml deleted file mode 100644 index 50e88d7f..00000000 --- a/.github/workflows/rununitybuildmultiversion.yml +++ /dev/null @@ -1,486 +0,0 @@ -name: Run Unity Builds - -on: - workflow_call: - inputs: - dependencies: - description: "json array of dependencies and their targets" - required: false - type: string - -jobs: - run_build: - name: Run Unity Build process - runs-on: ${{ matrix.os }} - strategy: - matrix: - include: - - os: windows - unityVersion: 2019.4 - build-target: Android - - os: macOS - unityVersion: 2019.4 - build-target: iOS - - os: windows - unityVersion: 2019.4 - build-target: StandaloneWindows64 - - os: windows - unityVersion: 2019.4 - build-target: WSAPlayer - - os: windows - unityVersion: 2020.3 - build-target: Android - - os: macOS - unityVersion: 2020.3 - build-target: iOS - - os: windows - unityVersion: 2020.3 - build-target: StandaloneWindows64 - - os: windows - unityVersion: 2020.3 - build-target: WSAPlayer - - os: windows - unityVersion: 2021.3 - build-target: Android - - os: macOS - unityVersion: 2021.3 - build-target: iOS - - os: windows - unityVersion: 2021.3 - build-target: StandaloneWindows64 - - os: windows - unityVersion: 2021.3 - build-target: WSAPlayer - - os: windows - unityVersion: 2022.3 - build-target: Android - - os: macOS - unityVersion: 2022.3 - build-target: iOS - - os: windows - unityVersion: 2022.3 - build-target: StandaloneWindows64 - - os: windows - unityVersion: 2022.3 - build-target: WSAPlayer - - os: windows - unityVersion: 6000.0 - build-target: Android - - os: windows - unityVersion: 6000.0 - build-target: StandaloneWindows64 - - os: windows - unityVersion: 6000.0 - build-target: WSAPlayer - - os: macos - unityVersion: 6000.0 - build-target: iOS - - os: macos - unityVersion: 6000.0 - build-target: StandaloneOSX - - steps: - - name: Script Version - run: | - echo "::group::Script Versioning" - $scriptVersion = "1.0.1" - echo "Build Script Version: $scriptVersion" - echo "::endgroup::" - shell: pwsh - - uses: actions/checkout@v4 - with: - submodules: recursive - clean: true - - - id: build - name: 'Run Unity Builds' - run: | - $unityVersion = '${{ matrix.unityVersion }}' - $unityMajorVersion = $unityVersion.Substring(0, 4) - - echo "::group::Set Hub and editor locations" - - ## Set Hub and editor locations - if ( (-not $global:PSVersionTable.Platform) -or ($global:PSVersionTable.Platform -eq "Win32NT") ) - { - $hubPath = "C:\Program Files\Unity Hub\Unity Hub.exe" - - #"Unity Hub.exe" -- --headless help - #. 'C:\Program Files\Unity Hub\Unity Hub.exe' -- --headless help - function unity-hub - { - & $hubPath -- --headless $args.Split(" ") | Out-String - } - function unity-hub-raw - { - & $hubPath -- --headless $args.Split(" ") | Out-String -NoNewline - } - } - elseif ( $global:PSVersionTable.OS.Contains("Darwin") ) - { - $hubPath = "/Applications/Unity Hub.app/Contents/MacOS/Unity Hub" - - # /Applications/Unity\ Hub.app/Contents/MacOS/Unity\ Hub -- --headless help - function unity-hub - { - & $hubPath -- --headless $args.Split(" ") | Out-String - } - function unity-hub-raw - { - & $hubPath -- --headless $args.Split(" ") | Out-String -NoNewline - } - } - elseif ( $global:PSVersionTable.OS.Contains("Linux") ) - { - $hubPath = "$HOME/Unity Hub/UnityHub.AppImage" - - # /UnityHub.AppImage --headless help - # xvfb-run --auto-servernum "$HOME/Unity Hub/UnityHub.AppImage" --headless help - function unity-hub - { - xvfb-run --auto-servernum "$hubPath" --headless $args.Split(" ") - } - function unity-hub-raw - { - xvfb-run --auto-servernum "$hubPath" --headless $args.Split(" ") - } - } - - echo "::endgroup::" - - echo "::group::Get String function to query a string for a value" - - function GetString($InputString, $InputPattern, $MatchIndex) - { - $regExResult = $InputString | Select-String -Pattern $InputPattern - if($regExResult.Length -gt 0) - { - return $regExResult.Matches[$MatchIndex].Value - } - else - { - return 0 - } - } - - function Get-LetterCount - { - Param ([string]$string) - return $string.Length - } - echo "::endgroup::" - - echo "::group::Get Installed Unity version based on Matrix" - echo "Unity hub path is {$hubPath}" - echo "Requested unity version is {$unityVersion}" - - $InstalledUnityVersions = unity-hub editors - $editorRootPath = unity-hub-raw ip -g - echo "Installed unity versions are {$InstalledUnityVersions}" - echo "Unity install path is {$editorRootPath}" - - $versionLength = Get-LetterCount $unityVersion - if ($versionLength -eq 4) { - $queryUnityVersion = GetString $InstalledUnityVersions "$unityVersion.{4,7}" -MatchIndex 0 - } - elseif ($versionLength -eq 6) { - $queryUnityVersion = GetString $InstalledUnityVersions "$unityVersion.{4,5}" -MatchIndex 0 - } - else { - $queryUnityVersion = GetString $InstalledUnityVersions "$unityVersion" -MatchIndex 0 - } - - echo "Found unity version is {$queryUnityVersion} for input {$unityVersion}" - - if ($queryUnityVersion -ne 0) - { - $unityVersion = $queryUnityVersion.Trim(","," ").Trim() - echo "Long Unity version is $unityVersion" - } - else - { - echo "Unity $unityVersion not found on this machine, skipping" - exit 0 - } - - echo "::endgroup::" - - echo "::group::Search for Editor if not found" - $checkPath = Join-Path $editorRootPath $unityVersion - echo "Testing for editor at $checkPath" - while (-not (Test-Path "$checkPath")) { - $source = $unityVersion.Replace("f1","") - $newversion = $source.Split(".") - $newversion[2] = [int]$newversion[2] - 1 - if ([int]$newversion[2] -lt 1) { - echo "Unity ${{ matrix.unityVersion }} not found on this machine, skipping" - exit 0 - } - $newunityVersion = "{0}.{1}.{2}f1" -f $newversion[0],$newversion[1],$newversion[2] - echo "Unity $unityVersion not found on this machine, trying $newunityVersion" - $unityVersion = $newunityVersion - $checkPath = Join-Path $editorRootPath $unityVersion - } - echo "::endgroup::" - - echo "::group::Set editor locations" - - if ( (-not $global:PSVersionTable.Platform) -or ($global:PSVersionTable.Platform -eq "Win32NT") ) { - echo 'Building using Windows' - $editorFileEx = "/Editor/Unity.exe" - $editorrunpath = Join-Path $editorRootPath $unityVersion $editorFileEx - - function unity-editor { - #$p = Start-Process -Verbose -NoNewWindow -PassThru -Wait -FilePath "$editorrunpath" -ArgumentList (@(' -batchmode') + $args.Split(" ")) - & $editorrunpath -batchmode $args.Split(" ") | Out-String - } - } - elseif ( $global:PSVersionTable.OS.Contains("Darwin") ) { - echo 'Building using Mac' - $editorFileEx = "/Unity.app/Contents/MacOS/Unity" - $editorrunpath = Join-Path $editorRootPath $unityVersion $editorFileEx - - function unity-editor { - #$p = Start-Process -Verbose -NoNewWindow -PassThru -Wait -FilePath "$editorrunpath" -ArgumentList (@(' -batchmode') + $args.Split(" ")) - & $editorrunpath -batchmode $args.Split(" ") | Out-String - } - } - elseif ( $global:PSVersionTable.OS.Contains("Linux") ) { - echo 'Building using Linux' - $editorFileEx = "/Editor/Unity" - $editorrunpath = Join-Path $editorRootPath $unityVersion $editorFileEx - - function unity-editor { - xvfb-run --auto-servernum "$editorrunpath" -batchmode $args.Split(" ") - } - } - else - { - echo 'Unknown build platform' - } - - echo "::endgroup::" - - echo "::group::Test Unity version is installed" - - if ( -not (Test-Path "$editorrunpath") ) - { - Write-Error "Editor not Found for $unityVersion" - exit 1 - } - else { - echo "Editor Path is {$editorrunpath}" - } - - echo "::endgroup::" - - echo "::group::Setup logging and run Unit tests" - - # Log detail - $logDirectory = "Logs" - if (Test-Path -Path $logDirectory) { - echo "Clearing logs from a previous run" - Remove-item $logDirectory -recurse - } - - $logDirectory = New-Item -ItemType Directory -Force -Path $logDirectory | Select-Object - - echo "Log Directory: $logDirectory" - $date = Get-Date -Format "yyyyMMddTHHmmss" - - # If run manually, the Refname is actually blank, so just use date - if([string]::IsNullOrEmpty(${GITHUB_REF_NAME})) { - $logName = Join-Path $logDirectory $date - }else { - $logName = Join-Path $logDirectory ${GITHUB_REF_NAME}-$date - } - - $logPath = "$unityMajorVersion_${{ matrix.build-target }}_$logName.log" - $testsLogPath = "$unityMajorVersion_${{ matrix.build-target }}_$logName-tests.xml" - - echo "Logpath [$logPath]" - echo "TestsPath [$testsLogPath]" - echo "::endgroup::" - - echo "::group::Grouping Package in a UPM folder" - - $UPMFolderName = 'u' - - if ( -not (Test-Path '$UPMFolderName') ) - { - New-Item $UPMFolderName -ItemType Directory - } - - Move-Item -Path * -Destination $UPMFolderName -exclude $UPMFolderName - - echo "::endgroup::" - - echo "::group::Creating Temp Unity project" - - $TempUnityProjectName = 'P' - - unity-editor '-createProject' $TempUnityProjectName '-logFile' $logPath '-quit' - - if ( -not (Test-Path "$TempUnityProjectName") ) - { - $ProjectPath = Get-Location - Write-Error "Editor failed to create project not Found $ProjectPath/$TempUnityProjectName" - exit 1 - } - else { - $ProjectPath = Get-Location - echo "Editor project created at $ProjectPath/$TempUnityProjectName" - } - - $destinationPath = Join-Path $TempUnityProjectName 'packages' - Move-Item -Path $UPMFolderName -Destination $destinationPath - - echo "::endgroup::" - - echo "::group::If required, clone dependencies in to test project" - - <# Dependency option requires specific inputs - - * A dependency input string in json format, listing each dependency by name and git url, e.g. - $dependencies = '[{"ASADependencies": "github.com/SimonDarksideJ/upmGithubActionsTests.git"}]' - *Note, remove the https:// portion to allow using a PAT to access the repo - The Name of the dependency should ALSO MATCH the name of the branch on the repo where the dependency is held (files intended for the packages folder) - - * Additionally, if Manifest entries are required, then a manifest file with those dependencies (and ONLY the new dependancies) should also be in the dependency branch named the same as the branch name - e.g. "ASADependencies.json" - keep the same structure, but only the dependancy entries - - !!Does NOT support additional scoped registries at this time! #> - - echo "---------------------------------------------" - echo "Read dependancy input value" - if([string]::IsNullOrEmpty('${{ inputs.dependencies }}')) - { - echo "No dependencies provided" - echo "input ${{ inputs.dependencies }}" - echo "------------------------------" - } - else { - echo "dependencies provided, validating" - - # Read dependancy input value - $dependencies = '${{ inputs.dependencies }}' - - if([string]::IsNullOrEmpty('${{ github.actor }}') -or [string]::IsNullOrEmpty('${{ secrets.GITHUB_TOKEN }}')){ - echo "" - echo "Insufficient credentials supplied to activate the workflow" - exit 1 - } - - echo "---------------------------------------------" - echo "Read dependancy input values as json" - $JSONdependencies = $dependencies | ConvertFrom-Json - - echo $JSONdependencies - - # Read current Manifest json - $manifestPath = Join-Path $destinationPath 'manifest.json' - $projectManifest = Get-Content -Path $manifestPath | ConvertFrom-Json - $strArray = $projectManifest.dependencies.PsObject.Properties | ForEach-Object {"$($_.Name)@$($_.Value),"} - - echo "---------------------------------------------" - echo "Loop through new dependancies and add them to the project Manifest" - foreach($dependency in $JSONdependencies){ - $dependency.PsObject.Properties | ForEach-Object -Process { - $dependencyName = $_.Name - $dependencyPath = $dependencyName.Replace("/","_") - $dependencyURL = $_.Value - echo "---------------------------------------------" - echo "Cloning dependency - Name [$dependencyName] - Path [$dependencyPath] - URL [$dependencyURL]" - $cloneURL = "https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@$dependencyURL" - - echo "cloning $dependencyName from $dependencyURL and moving to $destinationPath" - echo "git path - $cloneURL" - - # Clone Dependancy repo to destination folder - git clone -b $dependencyName --single-branch $cloneURL $dependencyPath - - if( -not (Test-Path -Path "$dependencyPath")){ - echo "Unable to clone $dependencyName from $dependencyURL" - exit 1 - } - - # Move files from clone path into packages folder, if the dependency contains a UPM package then move the entire folder and not just its contents - if (Test-Path -Path "$dependencyPath/package.json") { - $package_json = Get-Content -Path $dependencyPath/package.json | ConvertFrom-Json - $packageName = $package_json.name - Rename-Item $dependencyPath $packageName - echo "Moving whole $packageName UPM package to $destinationPath" - Move-Item -Path "$packageName" -Destination $destinationPath - } - else { - echo "Moving the contents of $dependencyName into the $destinationPath folder" - Move-Item -Path "$dependencyPath/*" -Destination $destinationPath - } - - # Get Dependency manifest entries (if applicable) - if (Test-Path -Path "$destinationPath/$dependencyName.json") { - $dependencyManifest = Get-Content -Path "$destinationPath/$dependencyName.json" | ConvertFrom-Json - $dependencyManifest.dependencies.PsObject.Properties | ForEach-Object { - $strArray += "$($_.Name)@$($_.Value)," - } - } - else{ - echo "No denendency json found called $destinationPath/$dependencyName.json, skipping adding additional manifest entries" - } - } - } - echo "---------------------------------------------" - - # Reformat combined dependancies list - $strArray = $strArray.Trim(",") | ConvertTo-Json - $strArray = $strArray.Replace("@",'":"').Replace("[","{").Replace("]","}") - $strArrayObject = $strArray | ConvertFrom-Json - - # Save manifest back to project - $projectManifest.dependencies = $strArrayObject - $projectManifest | ConvertTo-Json | Set-Content -Path "$destinationPath/manifest.json" - - echo "Project updated with the following dependencies" - echo "-----------------------------------------------" - echo $projectManifest - } - - echo "::endgroup::" - - echo "::group::Run build" - - echo "---------------------------------------------" - echo "Start Testing" - echo "Unity Command\n[unity-editor -projectPath $TempUnityProjectName -logfile $logPath -batchmode -nographics -quit -buildTarget ${{ matrix.build-target }}]" - - unity-editor -projectPath $TempUnityProjectName -logfile $logPath -batchmode -nographics -quit -buildTarget ${{ matrix.build-target }} - - echo "---------------------------------------------" - echo "::group::Unity Unit tests Results" - if (Test-Path $testsLogPath) { - echo "Test Run results for ${GITHUB_REPOSITORY} Branch ${GITHUB_REF}" - echo "" - Select-Xml -Path $testsLogPath -XPath '/test-run/test-suite' | ForEach-Object { "Name: " +$_.Node.name, ", Result: " + $_.Node.result, ", Total Tests: " + $_.Node.total, ", Passed: " + $_.Node.passed, ", Failed: " + $_.Node.failed, ", Skipped: " + $_.Node.skipped } - } - else { - echo "No test results found for ${GITHUB_REPOSITORY} Branch ${GITHUB_REF} at $testsLogPath" - echo "" - } - echo "::endgroup::" - - if($LASTEXITCODE -ne '0'){ - echo "::group::Unity Unit tests errors" - $exitCode = $testResult.ExitCode - Get-Content $logPath - echo "Build failed due to errors ($LASTEXITCODE), please check the log at $logPath" - echo "::endgroup::" - - exit $LASTEXITCODE - } - - shell: pwsh - - uses: actions/upload-artifact@v3 - if: always() - with: - name: unity-build-log-${{ matrix.unityVersion }}-${{ matrix.build-target }} - path: Logs/** \ No newline at end of file diff --git a/.github/workflows/rununitysinglebuild.yml b/.github/workflows/rununitysinglebuild.yml deleted file mode 100644 index 7d792f4d..00000000 --- a/.github/workflows/rununitysinglebuild.yml +++ /dev/null @@ -1,424 +0,0 @@ -name: Run Limited Unity Builds - -on: - workflow_call: - inputs: - unityVersion: - description: "The version of Unity to validate on" - required: true - type: string - dependencies: - description: "json array of dependencies and their targets" - required: false - type: string - -jobs: - run_build: - name: Run Unity Build process - runs-on: ${{ matrix.os }} - strategy: - matrix: - include: - - os: macOS - build-target: iOS - - os: windows - build-target: Android - - os: windows - build-target: StandaloneWindows64 - - os: windows - build-target: WSAPlayer - - steps: - - name: Script Version - run: | - echo "::group::Script Versioning" - $scriptVersion = "1.0.1" - echo "Build Script Version: $scriptVersion" - echo "::endgroup::" - shell: pwsh - - uses: actions/checkout@v4 - with: - submodules: recursive - clean: true - - id: build - name: 'Run Unity Builds' - run: | - $unityVersion = '${{ inputs.unityVersion }}' - - echo "::group::Set Hub and editor locations" - - ## Set Hub and editor locations - if ( (-not $global:PSVersionTable.Platform) -or ($global:PSVersionTable.Platform -eq "Win32NT") ) - { - $hubPath = "C:\Program Files\Unity Hub\Unity Hub.exe" - $editorRootPath = "C:\Program Files\Unity\Hub\Editor\" - - #"Unity Hub.exe" -- --headless help - #. 'C:\Program Files\Unity Hub\Unity Hub.exe' -- --headless help - function unity-hub - { - & $hubPath -- --headless $args.Split(" ") | Out-String -NoNewline - } - } - elseif ( $global:PSVersionTable.OS.Contains("Darwin") ) - { - $hubPath = "/Applications/Unity Hub.app/Contents/MacOS/Unity Hub" - $editorRootPath = "/Applications/Unity/Hub/Editor/" - - # /Applications/Unity\ Hub.app/Contents/MacOS/Unity\ Hub -- --headless help - function unity-hub - { - & $hubPath -- --headless $args.Split(" ") | Out-String -NoNewline - } - } - elseif ( $global:PSVersionTable.OS.Contains("Linux") ) - { - $hubPath = "$HOME/Unity Hub/UnityHub.AppImage" - $editorRootPath = "$HOME/Unity/Hub/Editor/" - - # /UnityHub.AppImage --headless help - # xvfb-run --auto-servernum "$HOME/Unity Hub/UnityHub.AppImage" --headless help - function unity-hub - { - xvfb-run --auto-servernum "$hubPath" --headless $args.Split(" ") - } - } - - echo "::endgroup::" - - echo "::group::Get String function to query a string for a value" - - function GetString($InputString, $InputPattern, $MatchIndex) - { - $regExResult = $InputString | Select-String -Pattern $InputPattern - if($regExResult.Length -gt 0) - { - return $regExResult.Matches[$MatchIndex].Value - } - else - { - return 0 - } - } - - function Get-LetterCount - { - Param ([string]$string) - return $string.Length - } - echo "::endgroup::" - - echo "::group::Find Installed Unity version based on input" - echo "Unity hub path is {$hubPath}" - echo "Requested unity version is {$unityVersion}" - - $InstalledUnityVersions = unity-hub editors - $editorRootPath = unity-hub ip -g - echo "Installed unity versions are {$InstalledUnityVersions}" - echo "Unity install path is {$editorRootPath}" - - $versionLength = Get-LetterCount $unityVersion - if ($versionLength -eq 4) { - $queryUnityVersion = GetString $InstalledUnityVersions "$unityVersion.{4,7}" -MatchIndex 0 - } - elseif ($versionLength -eq 6) { - $queryUnityVersion = GetString $InstalledUnityVersions "$unityVersion.{4,5}" -MatchIndex 0 - } - else { - $queryUnityVersion = GetString $InstalledUnityVersions "$unityVersion" -MatchIndex 0 - } - - echo "Found unity version is {$queryUnityVersion} for input {$unityVersion}" - - if ($queryUnityVersion -ne 0) - { - $unityVersion = $queryUnityVersion.Trim(","," ").Trim() - echo "Long Unity version is $unityVersion" - } - else - { - echo "Unity $unityVersion not found on this machine, skipping" - exit 0 - } - - echo "::endgroup::" - - echo "::group::Search for Editor if not found" - $checkPath = Join-Path $editorRootPath $unityVersion - echo "Testing for editor at $checkPath" - while (-not (Test-Path "$checkPath")) { - $source = $unityVersion.Replace("f1","") - $newversion = $source.Split(".") - $newversion[2] = [int]$newversion[2] - 1 - if ([int]$newversion[2] -lt 1) { - echo "Unity ${{ inputs.unityVersion }} not found on this machine, skipping" - exit 0 - } - $newunityVersion = "{0}.{1}.{2}f1" -f $newversion[0],$newversion[1],$newversion[2] - echo "Unity $unityVersion not found on this machine, trying $newunityVersion" - $unityVersion = $newunityVersion - $checkPath = Join-Path $editorRootPath $unityVersion - } - echo "::endgroup::" - - echo "::group::Set editor locations" - - if ( (-not $global:PSVersionTable.Platform) -or ($global:PSVersionTable.Platform -eq "Win32NT") ) { - echo 'Building using Windows' - $editorFileEx = "/Editor/Unity.exe" - $editorrunpath = Join-Path $editorRootPath $unityVersion $editorFileEx - - function unity-editor { - #$p = Start-Process -Verbose -NoNewWindow -PassThru -Wait -FilePath "$editorrunpath" -ArgumentList (@(' -batchmode') + $args.Split(" ")) - & $editorrunpath -batchmode $args.Split(" ") | Out-String - } - } - elseif ( $global:PSVersionTable.OS.Contains("Darwin") ) { - echo 'Building using Mac' - $editorFileEx = "/Unity.app/Contents/MacOS/Unity" - $editorrunpath = Join-Path $editorRootPath $unityVersion $editorFileEx - - function unity-editor { - #$p = Start-Process -Verbose -NoNewWindow -PassThru -Wait -FilePath "$editorrunpath" -ArgumentList (@(' -batchmode') + $args.Split(" ")) - & $editorrunpath -batchmode $args.Split(" ") | Out-String - } - } - elseif ( $global:PSVersionTable.OS.Contains("Linux") ) { - echo 'Building using Linux' - $editorFileEx = "/Editor/Unity" - $editorrunpath = Join-Path $editorRootPath $unityVersion $editorFileEx - - function unity-editor { - xvfb-run --auto-servernum "$editorrunpath" -batchmode $args.Split(" ") - } - } - else - { - echo 'Unknown build platform' - } - - echo "::endgroup::" - - echo "::group::Test Unity version is installed" - - if ( -not (Test-Path "$editorrunpath") ) - { - Write-Error "Editor not Found for $unityVersion" - exit 1 - } - else { - echo "Editor Path is {$editorrunpath}" - } - - echo "::endgroup::" - - echo "::group::Setup logging and run Unit tests" - - # Log detail - $logDirectory = "Logs" - if (Test-Path -Path $logDirectory) { - echo "Clearing logs from a previous run" - Remove-item $logDirectory -recurse - } - - $logDirectory = New-Item -ItemType Directory -Force -Path $logDirectory | Select-Object - - echo "Log Directory: $logDirectory" - $date = Get-Date -Format "yyyyMMddTHHmmss" - - # If run manually, the Refname is actually blank, so just use date - if([string]::IsNullOrEmpty(${GITHUB_REF_NAME})) { - $logName = Join-Path $logDirectory $date - }else { - $logName = Join-Path $logDirectory ${GITHUB_REF_NAME}-$date - } - - $logPath = "$logName.log" - $testsLogPath = "$logName-tests.xml" - - echo "Logpath [$logPath]" - echo "TestsPath [$testsLogPath]" - echo "::endgroup::" - - echo "::group::Grouping Package in a UPM folder" - - $UPMFolderName = 'u' - - if ( -not (Test-Path '$UPMFolderName') ) - { - New-Item $UPMFolderName -ItemType Directory - } - - Move-Item -Path * -Destination $UPMFolderName -exclude $UPMFolderName - - echo "::endgroup::" - - echo "::group::Creating Temp Unity project" - - $TempUnityProjectName = 'P' - - unity-editor '-createProject' $TempUnityProjectName '-logFile' $logPath '-quit' - - if ( -not (Test-Path "$TempUnityProjectName") ) - { - $ProjectPath = Get-Location - Write-Error "Editor failed to create project not Found $ProjectPath/$TempUnityProjectName" - exit 1 - } - else { - $ProjectPath = Get-Location - echo "Editor project created at $ProjectPath/$TempUnityProjectName" - } - - $destinationPath = Join-Path $TempUnityProjectName 'packages' - Move-Item -Path $UPMFolderName -Destination $destinationPath - - echo "::endgroup::" - - echo "::group::If required, clone dependencies in to test project" - - <# Dependency option requires specific inputs - - * A dependency input string in json format, listing each dependency by name and git url, e.g. - $dependencies = '[{"ASADependencies": "github.com/SimonDarksideJ/upmGithubActionsTests.git"}]' - *Note, remove the https:// portion to allow using a PAT to access the repo - The Name of the dependency should ALSO MATCH the name of the branch on the repo where the dependency is held (files intended for the packages folder) - - * Additionally, if Manifest entries are required, then a manifest file with those dependencies (and ONLY the new dependancies) should also be in the dependency branch named the same as the branch name - e.g. "ASADependencies.json" - keep the same structure, but only the dependancy entries - - !!Does NOT support additional scoped registries at this time! #> - - echo "---------------------------------------------" - echo "Read dependancy input value" - if([string]::IsNullOrEmpty('${{ inputs.dependencies }}')) - { - echo "No dependencies provided" - echo "input ${{ inputs.dependencies }}" - echo "------------------------------" - } - else { - echo "dependencies provided, validating" - - # Read dependancy input value - $dependencies = '${{ inputs.dependencies }}' - - if([string]::IsNullOrEmpty('${{ github.actor }}') -or [string]::IsNullOrEmpty('${{ secrets.GITHUB_TOKEN }}')){ - echo "" - echo "Insufficient credentials supplied to activate the workflow" - exit 1 - } - - echo "---------------------------------------------" - echo "Read dependancy input values as json" - $JSONdependencies = $dependencies | ConvertFrom-Json - - echo $JSONdependencies - - # Read current Manifest json - $manifestPath = Join-Path $destinationPath 'manifest.json' - $projectManifest = Get-Content -Path $manifestPath | ConvertFrom-Json - $strArray = $projectManifest.dependencies.PsObject.Properties | ForEach-Object {"$($_.Name)@$($_.Value),"} - - echo "---------------------------------------------" - echo "Loop through new dependancies and add them to the project Manifest" - foreach($dependency in $JSONdependencies){ - $dependency.PsObject.Properties | ForEach-Object -Process { - $dependencyName = $_.Name - $dependencyPath = $dependencyName.Replace("/","_") - $dependencyURL = $_.Value - echo "---------------------------------------------" - echo "Cloning dependency - Name [$dependencyName] - Path [$dependencyPath] - URL [$dependencyURL]" - $cloneURL = "https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@$dependencyURL" - - echo "cloning $dependencyName from $dependencyURL and moving to $destinationPath" - echo "git path - $cloneURL" - - # Clone Dependancy repo to destination folder - git clone -b $dependencyName --single-branch $cloneURL $dependencyPath - - if( -not (Test-Path -Path "$dependencyPath")){ - echo "Unable to clone $dependencyName from $dependencyURL" - exit 1 - } - - # Move files from clone path into packages folder, if the dependency contains a UPM package then move the entire folder and not just its contents - if (Test-Path -Path "$dependencyPath/package.json") { - $package_json = Get-Content -Path $dependencyPath/package.json | ConvertFrom-Json - $packageName = $package_json.name - Rename-Item $dependencyPath $packageName - echo "Moving whole $packageName UPM package to $destinationPath" - Move-Item -Path "$packageName" -Destination $destinationPath - } - else { - echo "Moving the contents of $dependencyName into the $destinationPath folder" - Move-Item -Path "$dependencyPath/*" -Destination $destinationPath - } - - # Get Dependency manifest entries (if applicable) - if (Test-Path -Path "$destinationPath/$dependencyName.json") { - $dependencyManifest = Get-Content -Path "$destinationPath/$dependencyName.json" | ConvertFrom-Json - $dependencyManifest.dependencies.PsObject.Properties | ForEach-Object { - $strArray += "$($_.Name)@$($_.Value)," - } - } - else{ - echo "No denendency json found called $destinationPath/$dependencyName.json, skipping adding additional manifest entries" - } - } - } - echo "---------------------------------------------" - - # Reformat combined dependancies list - $strArray = $strArray.Trim(",") | ConvertTo-Json - $strArray = $strArray.Replace("@",'":"').Replace("[","{").Replace("]","}") - $strArrayObject = $strArray | ConvertFrom-Json - - # Save manifest back to project - $projectManifest.dependencies = $strArrayObject - $projectManifest | ConvertTo-Json | Set-Content -Path "$destinationPath/manifest.json" - - echo "Project updated with the following dependencies" - echo "-----------------------------------------------" - echo $projectManifest - } - - echo "::endgroup::" - - echo "::group::Run build" - - echo "---------------------------------------------" - echo "Start Testing" - echo "Unity Command\n[unity-editor -projectPath $TempUnityProjectName -logfile $logPath -batchmode -nographics -quit -buildTarget ${{ matrix.build-target }}]" - - unity-editor -projectPath $TempUnityProjectName -logfile $logPath -batchmode -nographics -quit -buildTarget ${{ matrix.build-target }} - - echo "---------------------------------------------" - echo "::group::Unity Unit tests Results" - if (Test-Path $testsLogPath) { - echo "Test Run results for ${GITHUB_REPOSITORY} Branch ${GITHUB_REF}" - echo "" - Select-Xml -Path $testsLogPath -XPath '/test-run/test-suite' | ForEach-Object { "Name: " +$_.Node.name, ", Result: " + $_.Node.result, ", Total Tests: " + $_.Node.total, ", Passed: " + $_.Node.passed, ", Failed: " + $_.Node.failed, ", Skipped: " + $_.Node.skipped } - } - else { - echo "No test results found for ${GITHUB_REPOSITORY} Branch ${GITHUB_REF} at $testsLogPath" - echo "" - } - echo "::endgroup::" - - if($LASTEXITCODE -ne '0'){ - echo "::group::Unity Unit tests errors" - $exitCode = $testResult.ExitCode - Get-Content $logPath - echo "Build failed due to errors ($LASTEXITCODE), please check the log at $logPath" - echo "::endgroup::" - - exit $LASTEXITCODE - } - - shell: pwsh - - uses: actions/upload-artifact@v4 - if: always() - with: - name: unity-build-log-${{ matrix.build-target }} - path: Logs/** \ No newline at end of file diff --git a/.github/workflows/tagrelease.yml b/.github/workflows/tagrelease.yml deleted file mode 100644 index fddc3822..00000000 --- a/.github/workflows/tagrelease.yml +++ /dev/null @@ -1,79 +0,0 @@ -name: Tag Release - -on: - workflow_call: - inputs: - build-host: - required: true - type: string - version: - required: true - type: string - - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - -concurrency: - group: ${{ github.ref }} - cancel-in-progress: true - -jobs: - packageRelease: - name: Package UPM Project and tag - runs-on: ${{ inputs.build-host }} - outputs: - packageversion: ${{ steps.getpackageversion.outputs.packageversion }} - steps: - - name: Script Version - run: | - echo "::group::Script Versioning" - $scriptVersion = "1.0.3" - echo "Build Script Version: $scriptVersion" - echo "::endgroup::" - shell: pwsh - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - submodules: recursive - clean: true - token: ${{ secrets.GIT_PAT }} - - uses: actions/setup-node@v4 - - name: Set Github vars - run: | - if([string]::IsNullOrEmpty('${{ secrets.GIT_USER_NAME }}')){ - if([string]::IsNullOrEmpty('${{ secrets.GIT_USER_NAME }}')){ - $gitUser = "action" - $gitEmail = "action@github.com" - } - else { - $gitUser = "${GITHUB_ACTOR}" - $gitEmail = "$gitUser@users.noreply.github.com" - } - } - else { - $gitUser = "${{ secrets.GIT_USER_NAME }}" - $gitEmail = "$gitUser@users.noreply.github.com" - } - git config --global user.email "$gitUser@users.noreply.github.com" - git config --global user.name "$gitUser" - shell: pwsh - - name: Check if Tag Exists - run: | - $tagVersion = "${{ inputs.version }}" - $tags = git tag - echo "Tags found are [$tags], searching for [$tagVersion]" - foreach ($tag in $tags) - { - if($tag.Trim() -eq "$tagVersion") - { - Write-Error "$tagVersion tag already exists" - exit 1 - } - } - shell: pwsh - - name: Create tag and push - run: | - $tagVersion = "${{ inputs.version }}" - git tag -fa "v$tagVersion" -m "v$tagVersion Release [skip ci]" - git push origin "v$tagVersion" --force - shell: pwsh \ No newline at end of file diff --git a/.github/workflows/upversionandtagrelease.yml b/.github/workflows/upversionandtagrelease.yml deleted file mode 100644 index 8c8882ba..00000000 --- a/.github/workflows/upversionandtagrelease.yml +++ /dev/null @@ -1,181 +0,0 @@ -name: UpVersion Package UPM project and create new tag - -on: - workflow_call: - inputs: - build-host: - required: true - type: string - build-type: - required: false - default: 'pre-release' - type: string -# options: -# - major -# - minor -# - patch -# - patch-release -# - pre-release -# - build - target-branch: - required: false - type: string - default: ${{ github.ref }} - createTag: - required: false - type: boolean - default: true - - outputs: - packageversion: - description: "Returns the version of Unity the UPM package requires" - value: ${{ jobs.packageRelease.outputs.packageversion }} - secrets: - GIT_USER_NAME: - required: false - -jobs: - packageRelease: - name: Package UPM Project and tag - runs-on: ${{ inputs.build-host }} - outputs: - packageversion: ${{ steps.getpackageversion.outputs.packageversion }} - steps: - - name: Script Version - run: | - echo "::group::Script Versioning" - $scriptVersion = "1.0.3" - echo "Build Script Version: $scriptVersion" - echo "::endgroup::" - shell: pwsh - - uses: actions/checkout@v4 - with: - ref: ${{ inputs.target-branch }} - fetch-depth: 0 - submodules: recursive - clean: true - token: ${{ secrets.GIT_PAT }} - - uses: actions/setup-node@v4 - - name: Set Github vars - run: | - if([string]::IsNullOrEmpty('${{ secrets.GIT_USER_NAME }}')){ - if([string]::IsNullOrEmpty('${{ secrets.GIT_USER_NAME }}')){ - $gitUser = "action" - $gitEmail = "action@github.com" - } - else { - $gitUser = "${GITHUB_ACTOR}" - $gitEmail = "$gitUser@users.noreply.github.com" - } - } - else { - $gitUser = "${{ secrets.GIT_USER_NAME }}" - $gitEmail = "$gitUser@users.noreply.github.com" - } - git config --global user.email "$gitUser@users.noreply.github.com" - git config --global user.name "$gitUser" - shell: pwsh - - id: getpackageversion - name: Bump UPM Package version - run: | - function UpdateProjectVersionJSON { - param ( - [Parameter(Mandatory)] - $type, - $packageFile = 'package.json' - ) - <# - Type of build can be one of the following - - 'build' # Build release - 1.0.0-pre.0+1 - - 'pre-release' # Pre-Release - 1.0.0-pre.1 - - 'patch-release' # Patch release - 1.0.1 (reset preview version to current patch, no increase) - - 'patch' # Patch release - 1.0.1 - - 'minor' # Minor release - 1.1.0 - - 'major' # Major release - 2.0.0 - #> - - if ( -not (Test-Path -Path $packageFile) ) { - Write-Error "Failed to find a valid project manifest at `"$packageFile`"" - return $null - } - - $packageInfo = (Get-Content $packageFile -Raw) | ConvertFrom-Json - Write-Host "Detected Project Version:" $packageInfo.version - function IfNull($a, $b, $c) { if ($null -eq $a) { return $b } else { return $c } } - - $packageSemVer = [System.Management.Automation.SemanticVersion]$packageInfo.version - $majorVersion = if($null -eq $packageSemVer.Major) {0} else {$packageSemVer.Major} - $minorVersion = if($null -eq $packageSemVer.Minor) {0} else {$packageSemVer.Minor} - $patchVersion = if($null -eq $packageSemVer.Patch) {0} else {$packageSemVer.Patch} - $prereleaseVersion = if($null -eq $packageSemVer.PreReleaseLabel) {0} else {$packageSemVer.PreReleaseLabel.Replace('pre.','')} - $buildVersion = if($null -eq $packageSemVer.BuildLabel) {0} else {$packageSemVer.BuildLabel} - - # work out new version - switch ($type) { - 'build' { - [int]$buildVersion += 1 - $newPackageSemVer = [System.Management.Automation.SemanticVersion]::New($majorVersion, $minorVersion, $patchVersion, "pre." + $prereleaseVersion, $buildVersion) - } - 'pre-release' { - [int]$prereleaseVersion += 1 - $newPackageSemVer = [System.Management.Automation.SemanticVersion]::New($majorVersion, $minorVersion, $patchVersion, "pre." + $prereleaseVersion) - } - 'patch-release' { - $newPackageSemVer = [System.Management.Automation.SemanticVersion]::New($majorVersion, $minorVersion, $patchVersion) - } - 'patch' { - [int]$patchVersion += 1 - $newPackageSemVer = [System.Management.Automation.SemanticVersion]::New($majorVersion, $minorVersion, $patchVersion) - } - 'minor' { - [int]$minorVersion += 1 - $newPackageSemVer = [System.Management.Automation.SemanticVersion]::New($majorVersion, $minorVersion, 0) - } - 'major' { - [int]$majorVersion += 1 - $newPackageSemVer = [System.Management.Automation.SemanticVersion]::New($majorVersion, 0, 0) - } - } - - Write-Host "Upgrading project version [$packageSemVer] to [$newPackageSemVer]" - - # Write out updated package info - - $packageInfo.version = $newPackageSemVer.ToString() - $packageInfo | ConvertTo-Json | Set-Content $packageFile - - return $packageInfo.version - } - - $packageFile = 'package.json' - $result = UpdateProjectVersionJSON("${{ inputs.build-type }}","$packageFile") - if([string]::IsNullOrEmpty($result)) { - echo "Version patch failed" - exit 1 - } - git add "$packageFile" - git commit -m "Auto increment pre-release version to $result [skip ci]" - git push origin - echo "packageversion=$result" >> $env:GITHUB_OUTPUT - shell: pwsh - - name: Check if Tag Exists - run: | - $tagVersion = '${{steps.getpackageversion.outputs.packageversion }}' - $tags = git tag - echo "Tags found are [$tags], searching for [$tagVersion]" - foreach ($tag in $tags) - { - if($tag.Trim() -eq "$tagVersion") - { - Write-Error "$tagVersion tag already exists" - exit 1 - } - } - shell: pwsh - - name: Publish package tag - if: ${{inputs.createTag == true}} - run: | - $outputVersion = '${{steps.getpackageversion.outputs.packageversion }}' - git tag -fa "v$outputVersion" -m "v$outputVersion Release" - git push origin "v$outputVersion" --force --tags - shell: pwsh \ No newline at end of file From fa5ad49332349727db31361ecdd0f3181c0f8804 Mon Sep 17 00:00:00 2001 From: "Simon (Darkside) Jackson" Date: Sun, 7 Dec 2025 10:15:05 +0000 Subject: [PATCH 15/17] Initial check-in for Unity 6 update - thank you Unity for continuing to support Unity UI (#497) * Initial check-in for Unity 6 update - thank you Unity for continuing to support Unity UI * Update workflows from base update * Unity 6 script clean-up (remove legacy dependencies) * Update package definition for Unity 6 focus * Update examples checkout * Updated Picker control and samples to latest * Update UIVertical Scroller to be more efficient for U6 and update example * Clear out old text controls, no longer valid. Update combobox scripts * Reverted Curly Text back to old Text component as it is not compatible with TextMeshPro - will investigate alternatives * All scenes tested, 2 issues remain, re-orderable list and selection box * Pausing Linux testing until Unity sort their stuff out --- .../development-buildandtestupmrelease.yml | 10 +- Editor/CUIImageEditor.cs | 4 - Editor/CanvasGroupActivator.cs | 6 +- Editor/UIExtensionsMenuOptions.cs | 184 ++-- Examples~ | 2 +- README.md | 4 + .../Controls/ColorPicker/ColorImage.cs | 34 +- .../Controls/ColorPicker/ColorLabel.cs | 15 +- .../Controls/ColorPicker/ColorSampler.cs | 6 +- .../Controls/ColorPicker/HexColorField.cs | 12 +- .../Controls/ComboBox/AutoCompleteComboBox.cs | 10 +- Runtime/Scripts/Controls/ComboBox/ComboBox.cs | 12 +- .../Controls/ComboBox/DropDownListButton.cs | 8 - .../ReorderableList/ReorderableListDebug.cs | 8 - Runtime/Scripts/Controls/Segment.cs | 4 - .../SelectionBox/ExampleSelectable.cs | 8 - .../Controls/SelectionBox/SelectionBox.cs | 392 +++++---- Runtime/Scripts/Controls/Sliders/BoxSlider.cs | 7 +- Runtime/Scripts/Controls/TextPic.cs | 822 ++++++++++-------- Runtime/Scripts/Effects/BestFitOutline.cs | 74 -- .../Scripts/Effects/BestFitOutline.cs.meta | 8 - Runtime/Scripts/Effects/CurlyUI/CUIText.cs | 8 - Runtime/Scripts/Effects/CurvedText.cs | 95 -- Runtime/Scripts/Effects/CurvedText.cs.meta | 8 - Runtime/Scripts/Effects/CylinderText.cs | 67 -- Runtime/Scripts/Effects/CylinderText.cs.meta | 8 - Runtime/Scripts/Effects/Gradient2.cs | 46 +- Runtime/Scripts/Effects/LetterSpacing.cs | 187 ---- Runtime/Scripts/Effects/LetterSpacing.cs.meta | 8 - Runtime/Scripts/Effects/MonoSpacing.cs | 205 ----- Runtime/Scripts/Effects/MonoSpacing.cs.meta | 12 - Runtime/Scripts/Effects/NicerOutline.cs | 211 ----- Runtime/Scripts/Effects/NicerOutline.cs.meta | 8 - Runtime/Scripts/Effects/SoftMaskScript.cs | 4 - Runtime/Scripts/Effects/UIParticleSystem.cs | 12 +- Runtime/Scripts/Layout/FlowLayoutGroup.cs | 7 +- .../Scripts/Layout/UIHorizontalScroller.cs | 10 +- Runtime/Scripts/Layout/UIVerticalScroller.cs | 60 +- .../ToolTips/BoundTooltip/BoundTooltipItem.cs | 10 +- Runtime/Scripts/ToolTips/HoverTooltip.cs | 4 - Runtime/Scripts/ToolTips/ToolTip.cs | 73 +- Runtime/Scripts/Utilities/ExtensionsToggle.cs | 5 - Runtime/Scripts/Utilities/PPIViewer.cs | 12 - .../Utilities/UIExtensionsInputManager.cs | 2 +- .../Utilities/UI_ScrollRectOcclusion.cs | 4 +- package.json | 9 +- 46 files changed, 895 insertions(+), 1810 deletions(-) delete mode 100644 Runtime/Scripts/Effects/BestFitOutline.cs delete mode 100644 Runtime/Scripts/Effects/BestFitOutline.cs.meta delete mode 100644 Runtime/Scripts/Effects/CurvedText.cs delete mode 100644 Runtime/Scripts/Effects/CurvedText.cs.meta delete mode 100644 Runtime/Scripts/Effects/CylinderText.cs delete mode 100644 Runtime/Scripts/Effects/CylinderText.cs.meta delete mode 100644 Runtime/Scripts/Effects/LetterSpacing.cs delete mode 100644 Runtime/Scripts/Effects/LetterSpacing.cs.meta delete mode 100644 Runtime/Scripts/Effects/MonoSpacing.cs delete mode 100644 Runtime/Scripts/Effects/MonoSpacing.cs.meta delete mode 100644 Runtime/Scripts/Effects/NicerOutline.cs delete mode 100644 Runtime/Scripts/Effects/NicerOutline.cs.meta diff --git a/.github/workflows/development-buildandtestupmrelease.yml b/.github/workflows/development-buildandtestupmrelease.yml index e2133b94..7bdae5ca 100644 --- a/.github/workflows/development-buildandtestupmrelease.yml +++ b/.github/workflows/development-buildandtestupmrelease.yml @@ -32,17 +32,13 @@ jobs: matrix: os: [ubuntu-latest, windows-latest, macos-latest] unity-version: - - 2019 - - 2020 - - 2021 - - 2022 - 6000.0.x - 6000 include: - - os: ubuntu-latest - build-targets: StandaloneLinux64, Android + # - os: ubuntu-latest + # build-targets: StandaloneLinux64, Android - os: windows-latest - build-targets: StandaloneWindows64 + build-targets: StandaloneWindows64, Android - os: macos-latest build-targets: StandaloneOSX, iOS steps: diff --git a/Editor/CUIImageEditor.cs b/Editor/CUIImageEditor.cs index a3eb6f1c..f3ac1839 100644 --- a/Editor/CUIImageEditor.cs +++ b/Editor/CUIImageEditor.cs @@ -68,11 +68,7 @@ protected override void OnSceneGUI() Handles.color = Color.gray; EditorGUI.BeginChangeCheck(); -#if UNITY_2022_1_OR_NEWER Vector3 newCornerPos = Handles.FreeMoveHandle(script.transform.TransformPoint(cornerPos), HandleUtility.GetHandleSize(script.transform.TransformPoint(cornerPos)) / 7, Vector3.one, Handles.SphereHandleCap); -#else - Vector3 newCornerPos = Handles.FreeMoveHandle(script.transform.TransformPoint(cornerPos), script.transform.rotation, HandleUtility.GetHandleSize(script.transform.TransformPoint(cornerPos)) / 7, Vector3.one, Handles.SphereHandleCap); -#endif Handles.Label(newCornerPos, string.Format("Corner Mover")); diff --git a/Editor/CanvasGroupActivator.cs b/Editor/CanvasGroupActivator.cs index cd716573..99cb48e0 100644 --- a/Editor/CanvasGroupActivator.cs +++ b/Editor/CanvasGroupActivator.cs @@ -29,11 +29,7 @@ void OnFocus() void ObtainCanvasGroups() { -#if UNITY_2023_1_OR_NEWER - canvasGroups = GameObject.FindObjectsByType(FindObjectsSortMode.None); -#else - canvasGroups = GameObject.FindObjectsOfType(); -#endif + canvasGroups = GameObject.FindObjectsByType(FindObjectsSortMode.None); } void OnGUI() diff --git a/Editor/UIExtensionsMenuOptions.cs b/Editor/UIExtensionsMenuOptions.cs index ac4bbe42..def2a80b 100644 --- a/Editor/UIExtensionsMenuOptions.cs +++ b/Editor/UIExtensionsMenuOptions.cs @@ -1,4 +1,4 @@ -#if UNITY_2019_1_OR_NEWER && !ENABLE_LEGACY_INPUT_MANAGER +#if !ENABLE_LEGACY_INPUT_MANAGER #define NEW_INPUT_SYSTEM #endif @@ -159,11 +159,7 @@ private static void CreateEventSystem(bool select) private static void CreateEventSystem(bool select, GameObject parent) { -#if UNITY_2023_1_OR_NEWER var esys = Object.FindFirstObjectByType(); -#else - var esys = Object.FindObjectOfType(); -#endif if (esys == null) { var eventSystem = new GameObject("EventSystem"); @@ -195,11 +191,7 @@ static public GameObject GetOrCreateCanvasGameObject() return canvas.gameObject; // No canvas in selection or its parents? Then use just any canvas.. -#if UNITY_2023_1_OR_NEWER canvas = Object.FindFirstObjectByType(); -#else - canvas = Object.FindObjectOfType(typeof(Canvas)) as Canvas; -#endif if (canvas != null && canvas.gameObject.activeInHierarchy) return canvas.gameObject; @@ -677,91 +669,91 @@ static public void AddUIVerticallScroller(MenuCommand menuCommand) Selection.activeGameObject = uiVerticalScrollerRoot; } - #endregion - - #region UIHorizontal Scroller - [MenuItem("GameObject/UI/Extensions/Layout/UI Horizontal Scroller", false)] - static public void AddUIHorizontalScroller(MenuCommand menuCommand) - { - GameObject uiHorizontalScrollerRoot = CreateUIElementRoot("UI Horizontal Scroller", menuCommand, s_ThickGUIElementSize); - - GameObject uiScrollerCenter = CreateUIObject("Center", uiHorizontalScrollerRoot); - - GameObject childContent = CreateUIObject("Content", uiHorizontalScrollerRoot); - - // Set RectTransform to stretch - RectTransform rectTransformScrollSnapRoot = uiHorizontalScrollerRoot.GetComponent(); - rectTransformScrollSnapRoot.anchorMin = new Vector2(0.5f, 0.5f); - rectTransformScrollSnapRoot.anchorMax = new Vector2(0.5f, 0.5f); - rectTransformScrollSnapRoot.anchoredPosition = Vector2.zero; - rectTransformScrollSnapRoot.sizeDelta = new Vector2(500f, 150f); - - // Add required ScrollRect - ScrollRect sr = uiHorizontalScrollerRoot.AddComponent(); - sr.vertical = false; - sr.horizontal = true; - sr.movementType = ScrollRect.MovementType.Unrestricted; - var uiscr = uiHorizontalScrollerRoot.AddComponent(); - - //Setup container center point - RectTransform rectTransformCenter = uiScrollerCenter.GetComponent(); - rectTransformCenter.anchorMin = new Vector2(0.3f,0f); - rectTransformCenter.anchorMax = new Vector2(0.6f,1f); - rectTransformCenter.sizeDelta = Vector2.zero; - - uiscr.Center = uiScrollerCenter.GetComponent(); - - //Setup Content container - RectTransform rectTransformContent = childContent.GetComponent(); - rectTransformContent.anchorMin = Vector2.zero; - rectTransformContent.anchorMax = new Vector2(1f, 1f); - rectTransformContent.sizeDelta = Vector2.zero; - - sr.content = rectTransformContent; - - // Add sample children - for (int i = 0; i < 10; i++) - { - GameObject childPage = CreateUIObject("Page_" + i, childContent); - - GameObject childText = CreateUIObject("Text", childPage); - - //Setup 1st Child - Image pageImage = childPage.AddComponent(); - pageImage.sprite = AssetDatabase.GetBuiltinExtraResource(kStandardSpritePath); - pageImage.type = Image.Type.Sliced; - pageImage.color = s_DefaultSelectableColor; - - RectTransform rectTransformPage = childPage.GetComponent(); - rectTransformPage.anchorMin = new Vector2(0.5f, 0); - rectTransformPage.anchorMax = new Vector2(0.5f, 1f); - rectTransformPage.sizeDelta = new Vector2(80f, 0f); - rectTransformPage.pivot = new Vector2(0.5f, 0.5f); - rectTransformPage.localPosition = new Vector3(80 * i, 0, 0); - childPage.AddComponent