Skip to content

Commit 24e4ede

Browse files
Feature/unity6 (#521)
* 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 * Added GridRawImage & UI_Knob2 * UISegmentedCIrcle control * Added UI Graphic Selector * Renamed Segment to SegmentedControlSegment: * Addressed NRE in Reorderable List * Patch debug option to allow both Text and TMPro * Update layout groups to rebuild on disable/enable - Resolves: #468 * Resolved stacking issue with the Reorderable list when moving the elements "slightly" - Resolves #470 * Added a close line option which finished the line off with a "closer" to fill any gaps at the end - Resolves: #449 * Resolved race condition issue in regards to the ScrollSnap control which could raise a NaN error when lerping - Resolves: #452 / #508 * Patch the HSS/VSS against a potential divide by zero error is the scroll snap has a single page * Update GetCurrentPage to be more resilient - Fixes #254 * Resolve out of bounds issues with the Infinite scroll control - Fixes #237 * Updated UI Particle system to address #486/#487 requiring a new "CullingMode" option that when enabled alters the control to resolve unscaleddeltatime - Fixes #486, #487 * Patch for #477 plus some general housekeeping for maintaining TMPro/Text compatibility * Update SegmentedCircle controls with new meta files and update examples checkout * Update scrollsnap to be more resilient to rescaling and patch full screen scroll snap RIF - Fixes #257, #260 * Address layout issues with the flow layout group - Fixes #456 * Remove unused variable in UITextureLineRenderer * Patch GridRawImage for editor and update automation steps * Patch workflow to FIX the release due to obsolete errors in 6000.5
1 parent 077415a commit 24e4ede

105 files changed

Lines changed: 4910 additions & 464 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/development-buildandtestupmrelease.yml

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,21 @@ env:
2424

2525
jobs:
2626
test-unity-build:
27-
name: Test Unity UPM Build
27+
name: Test Unity UPM Build (${{ matrix.os }}, Unity ${{ matrix.unity-version }})
2828
runs-on: ${{ matrix.os }}
2929
if: always()
3030
strategy:
3131
fail-fast: false
3232
matrix:
3333
os: [ubuntu-latest, windows-latest, macos-latest]
3434
unity-version:
35-
- 6000.0.x
36-
- 6000
35+
- '6000.0.x'
36+
- '6000.1'
37+
- '6000.2'
38+
- '6000.3'
3739
include:
38-
# - os: ubuntu-latest
39-
# build-targets: StandaloneLinux64, Android
40+
- os: ubuntu-latest
41+
build-targets: StandaloneLinux64, Android
4042
- os: windows-latest
4143
build-targets: StandaloneWindows64, Android
4244
- os: macos-latest
@@ -49,18 +51,20 @@ jobs:
4951
unity-version: ${{ matrix.unity-version }} # overrides version in version-file
5052
build-targets: ${{ matrix.build-targets }}
5153

52-
- run: |
54+
- name: Inspect Unity setup outputs
55+
shell: pwsh
56+
run: |
5357
echo "Step Outputs:"
5458
echo "steps.unity-setup.unity-hub-path: '${{ steps.unity-setup.outputs.unity-hub-path }}'"
5559
echo "steps.unity-setup.unity-editors: '${{ steps.unity-setup.outputs.unity-editors }}'"
5660
echo "steps.unity-setup.unity-editor-path: '${{ steps.unity-setup.outputs.unity-editor-path }}'"
5761
echo "steps.unity-setup.unity-project-path: '${{ steps.unity-setup.outputs.unity-project-path }}'"
5862
5963
echo "Environment Variables:"
60-
echo "UNITY_HUB_PATH: '${{ env.UNITY_HUB_PATH }}'"
61-
echo "UNITY_EDITORS: '${{ env.UNITY_EDITORS }}'"
62-
echo "UNITY_EDITOR_PATH: '${{ env.UNITY_EDITOR_PATH }}'"
63-
echo "UNITY_PROJECT_PATH: '${{ env.UNITY_PROJECT_PATH }}'"
64+
echo "UNITY_HUB_PATH: '$env:UNITY_HUB_PATH'"
65+
echo "UNITY_EDITORS: '$env:UNITY_EDITORS'"
66+
echo "UNITY_EDITOR_PATH: '$env:UNITY_EDITOR_PATH'"
67+
echo "UNITY_PROJECT_PATH: '$env:UNITY_PROJECT_PATH'"
6468
6569
- uses: buildalon/activate-unity-license@v2
6670
if: runner.environment == 'github-hosted'
Lines changed: 310 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,310 @@
1+
///Credit Dmitry (mitay-walle)
2+
///Sourced from - https://github.com/mitay-walle/com.mitay-walle.rect-transform-editor
3+
4+
using System;
5+
using System.Reflection;
6+
using UnityEditor;
7+
using UnityEditorInternal;
8+
using UnityEngine;
9+
using Object = UnityEngine.Object;
10+
11+
namespace Plugins.UI.Editor
12+
{
13+
[CustomEditor(typeof(RectTransform), true), CanEditMultipleObjects]
14+
public class CustomRectTransformEditor : UnityEditor.Editor
15+
{
16+
private const string NATIVE_EDITOR_TYPE = "UnityEditor.RectTransformEditor";
17+
private static PropertyInfo _rectDrivenObject = typeof(RectTransform).GetProperty("drivenByObject"
18+
, BindingFlags.Public | BindingFlags.Instance);
19+
private UnityEditor.Editor editorInstance;
20+
private static Type nativeEditorType;
21+
private MethodInfo onSceneGui;
22+
private MethodInfo onDisable;
23+
private Action<SceneView> drawAnchorsOnSceneViewDelegate;
24+
25+
private Rect _rect = new Rect(45, 65, 45, 18);
26+
private Rect _rect2 = new Rect(70, 25, 20, 18);
27+
private Rect _rect3 = new Rect(70, 45, 20, 18);
28+
private Rect _rect4 = new Rect(0, 65, 45, 18);
29+
30+
private void OnEnable()
31+
{
32+
if (targets.Length == 0 || targets[0] == null) return;
33+
34+
Initialize();
35+
if (nativeEditorType == null) return;
36+
if (editorInstance == null) return;
37+
38+
InitOnSceneGUIFix();
39+
ExecuteOnSceneGUIFix();
40+
try
41+
{
42+
if (editorInstance.targets.Length > 0 && editorInstance.targets[0] != null)
43+
{
44+
nativeEditorType.GetMethod("OnEnable",
45+
BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic)
46+
?.Invoke(editorInstance, null);
47+
}
48+
}
49+
catch
50+
{
51+
}
52+
}
53+
54+
private void Initialize()
55+
{
56+
if (nativeEditorType == null)
57+
{
58+
nativeEditorType = Assembly.GetAssembly(typeof(UnityEditor.Editor)).GetType(NATIVE_EDITOR_TYPE);
59+
}
60+
61+
if (editorInstance)
62+
{
63+
CreateCachedEditor(targets, nativeEditorType, ref editorInstance);
64+
}
65+
else
66+
{
67+
editorInstance = CreateEditor(targets, nativeEditorType);
68+
}
69+
}
70+
71+
private void InitOnSceneGUIFix()
72+
{
73+
// fix recursive SceneView.duringSceneGui subscription, that affects performance
74+
onSceneGui = nativeEditorType.GetMethod("OnSceneGUI", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
75+
onDisable = nativeEditorType.GetMethod("OnDisable", BindingFlags.NonPublic | BindingFlags.Instance);
76+
var method = nativeEditorType.GetMethod("DrawAnchorsOnSceneView", BindingFlags.NonPublic | BindingFlags.Instance);
77+
drawAnchorsOnSceneViewDelegate = (Action<SceneView>)method.CreateDelegate(typeof(Action<SceneView>), editorInstance);
78+
}
79+
80+
private void ExecuteOnSceneGUIFix()
81+
{
82+
SceneView.duringSceneGui -= drawAnchorsOnSceneViewDelegate;
83+
}
84+
85+
public override void OnInspectorGUI()
86+
{
87+
editorInstance.OnInspectorGUI();
88+
89+
bool needMoveY = NeedMoveY();
90+
91+
Rect rect = _rect;
92+
rect.y += needMoveY ? 20 : 0;
93+
94+
// Code here
95+
if (GUI.Button(rect, "Snap"))
96+
{
97+
foreach (Object targ in targets)
98+
{
99+
if (targ is RectTransform rectTr)
100+
{
101+
Undo.RecordObject(targ, "Snap to parent");
102+
SnapToParent(rectTr);
103+
EditorUtility.SetDirty(targ);
104+
}
105+
}
106+
}
107+
108+
rect = _rect4;
109+
rect.y += needMoveY ? 20 : 0;
110+
111+
if (GUI.Button(rect, "New"))
112+
{
113+
foreach (Object targ in targets)
114+
{
115+
if (targ is RectTransform rectTr)
116+
{
117+
CreateEmptyParentRect(rectTr);
118+
}
119+
}
120+
}
121+
122+
if (targets.Length > 1)
123+
{
124+
GUI.enabled = false;
125+
}
126+
127+
rect = _rect2;
128+
rect.y += needMoveY ? 20 : 0;
129+
130+
if (GUI.Button(rect, "C"))
131+
{
132+
ComponentUtility.CopyComponent(target as RectTransform);
133+
}
134+
135+
GUI.enabled = true;
136+
137+
rect = _rect3;
138+
rect.y += needMoveY ? 20 : 0;
139+
140+
if (GUI.Button(rect, "P"))
141+
{
142+
foreach (Object targ in targets)
143+
{
144+
Undo.RecordObject(targ, "Paste");
145+
ComponentUtility.PasteComponentValues(targ as RectTransform);
146+
EditorUtility.SetDirty(targ);
147+
}
148+
}
149+
}
150+
151+
private void OnSceneGUI()
152+
{
153+
if (!(bool)target)
154+
return;
155+
156+
onSceneGui.Invoke(editorInstance, null);
157+
}
158+
159+
private void OnDisable()
160+
{
161+
SceneView.duringSceneGui -= drawAnchorsOnSceneViewDelegate;
162+
if (editorInstance)
163+
{
164+
onDisable?.Invoke(editorInstance, null);
165+
DestroyImmediate(editorInstance);
166+
}
167+
}
168+
169+
private static void SnapToParent(RectTransform rect)
170+
{
171+
rect.pivot = new Vector2(.5f, .5f);
172+
rect.localScale = Vector3.one;
173+
rect.localPosition = Vector3.zero;
174+
rect.localRotation = Quaternion.identity;
175+
rect.anchoredPosition = Vector2.zero;
176+
rect.anchorMin = Vector2.zero;
177+
rect.anchorMax = Vector2.one;
178+
rect.sizeDelta = Vector2.zero;
179+
}
180+
181+
public static void CreateEmptyParentRect(RectTransform rect)
182+
{
183+
GameObject go = new GameObject("Create Empty Parent");
184+
185+
ComponentUtility.CopyComponent(rect);
186+
ComponentUtility.PasteComponentAsNew(go);
187+
188+
Undo.RecordObject(rect, "Create Empty, Reparent");
189+
190+
Undo.RegisterCreatedObjectUndo(go, "Create Empty Parent");
191+
192+
RectTransform rect2 = go.transform as RectTransform;
193+
194+
PlaceSameAs(go.transform, rect, true, true, true);
195+
ComponentUtility.PasteComponentValues(rect2);
196+
Undo.SetTransformParent(rect, go.transform, "Create Empty, Reparent");
197+
SnapToParent(rect);
198+
199+
EditorUtility.SetDirty(rect);
200+
201+
Selection.activeGameObject = go;
202+
EditorGUIUtility.PingObject(go);
203+
}
204+
205+
private static void PlaceSameAs(Transform target, Transform source, bool copyName = false, bool undo = false,
206+
bool setDirty = false)
207+
{
208+
if (!source) return;
209+
210+
if (undo && Application.isPlaying)
211+
{
212+
Undo.RecordObject(target, "PlaceSameAs");
213+
if (copyName) Undo.RecordObject(target.gameObject, "PlaceSameAs");
214+
}
215+
216+
VectorArray matrix = new VectorArray(source, false);
217+
matrix.Apply(target);
218+
if (undo)
219+
{
220+
Undo.SetTransformParent(target, source.parent, "PlaceSameAs");
221+
}
222+
else
223+
{
224+
target.SetParent(source.parent);
225+
}
226+
227+
target.SetSiblingIndex(source.GetSiblingIndex());
228+
229+
if (copyName) target.name = source.name;
230+
231+
if (setDirty && Application.isPlaying)
232+
{
233+
EditorUtility.SetDirty(target);
234+
if (copyName) EditorUtility.SetDirty(target.gameObject);
235+
}
236+
}
237+
238+
// ReSharper disable Unity.PerformanceAnalysis
239+
private bool NeedMoveY()
240+
{
241+
bool value = false;
242+
foreach (RectTransform target in targets)
243+
{
244+
if (NeedMoveY(target))
245+
{
246+
value = true;
247+
break;
248+
}
249+
}
250+
251+
return value;
252+
}
253+
254+
private bool NeedMoveY(RectTransform target) => _rectDrivenObject.GetValue(target) != null;
255+
}
256+
257+
[Serializable]
258+
public struct VectorArray
259+
{
260+
[SerializeField] public bool local;
261+
[SerializeField] public Vector3 Pos;
262+
[SerializeField] public Quaternion Rot;
263+
[SerializeField] public Vector3 Scale;
264+
265+
public VectorArray(Transform tr, bool local)
266+
{
267+
this.local = local;
268+
if (!tr)
269+
{
270+
Pos = default;
271+
Rot = default;
272+
Scale = default;
273+
}
274+
else
275+
{
276+
Scale = local ? tr.localScale : tr.lossyScale;
277+
278+
if (local)
279+
{
280+
Pos = tr.localPosition;
281+
Rot = tr.localRotation;
282+
}
283+
else
284+
{
285+
Pos = tr.position;
286+
Rot = tr.rotation;
287+
}
288+
}
289+
}
290+
291+
public void Apply(Transform tr)
292+
{
293+
if (local)
294+
{
295+
tr.localPosition = Pos;
296+
tr.localRotation = Rot;
297+
}
298+
else
299+
{
300+
tr.position = Pos;
301+
tr.rotation = Rot;
302+
}
303+
304+
tr.localScale = Scale;
305+
#if UNITY_EDITOR
306+
if (!Application.isPlaying) EditorUtility.SetDirty(tr);
307+
#endif
308+
}
309+
}
310+
}

Editor/CustomRectTransformEditor.cs.meta

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Editor/GridRawImage.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)