com.wallstop-studios.unity-helpers 2.0.0-rc38 → 2.0.0-rc40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/.github/workflows/npm-publish.yml +22 -26
  2. package/Editor/AnimationCopier.cs +25 -2
  3. package/Editor/AnimationCreator.cs +18 -27
  4. package/Editor/AnimatorControllerCopier.cs +7 -7
  5. package/Editor/EnsureTextureSizeWizard.cs +14 -9
  6. package/Editor/PrefabCheckWizard.cs +1 -1
  7. package/Editor/Utils/{ReadOnlyPropertyDrawer.cs → DxReadOnlyPropertyDrawer.cs} +2 -2
  8. package/README.md +37 -1
  9. package/Runtime/Core/Attributes/ChildComponentAttribute.cs +39 -19
  10. package/Runtime/Core/Attributes/DxReadOnlyAttribute.cs +6 -0
  11. package/Runtime/Core/Attributes/ParentComponent.cs +16 -15
  12. package/Runtime/Core/Attributes/SiblingComponentAttribute.cs +7 -9
  13. package/Runtime/Core/Helper/Partials/TransformHelpers.cs +26 -0
  14. package/Runtime/Core/Helper/ReflectionHelpers.cs +97 -22
  15. package/Tests/Runtime/Components/{RelationalComponentTester.cs → RelationalComponentTesterComplex.cs} +1 -1
  16. package/Tests/Runtime/Components/RelationalComponentsTesterSimple.cs +40 -0
  17. package/Tests/Runtime/Components/RelationalComponentsTesterSimple.cs.meta +3 -0
  18. package/Tests/Runtime/Helper/ReflectionHelperTests.cs +179 -0
  19. package/Tests/Runtime/Helper/ReflectionHelperTests.cs.meta +3 -0
  20. package/Tests/Runtime/Performance/RelationComponentPerformanceTests.cs +27 -3
  21. package/package.json +1 -1
  22. package/.github/workflows/unity-package.yml +0 -106
  23. package/Editor/BuildScript.cs +0 -30
  24. package/Editor/BuildScript.cs.meta +0 -3
  25. package/Editor/Scenes/SampleScene.unity +0 -221
  26. package/Editor/Scenes/SampleScene.unity.meta +0 -7
  27. package/Editor/Scenes.meta +0 -3
  28. package/Runtime/Core/Attributes/ReadOnlyAttribute.cs +0 -6
  29. /package/Editor/Utils/{ReadOnlyPropertyDrawer.cs.meta → DxReadOnlyPropertyDrawer.cs.meta} +0 -0
  30. /package/Runtime/Core/Attributes/{ReadOnlyAttribute.cs.meta → DxReadOnlyAttribute.cs.meta} +0 -0
  31. /package/Tests/Runtime/Components/{RelationalComponentTester.cs.meta → RelationalComponentTesterComplex.cs.meta} +0 -0
@@ -8,22 +8,20 @@
8
8
  using System.Runtime.CompilerServices;
9
9
  using Extension;
10
10
 
11
+ public delegate void FieldSetter<TInstance, in TValue>(ref TInstance instance, TValue value);
12
+
11
13
  public static class ReflectionHelpers
12
14
  {
13
15
  private static readonly Dictionary<Type, Func<int, Array>> ArrayCreators = new();
14
16
  private static readonly Dictionary<Type, Func<IList>> ListCreators = new();
15
17
  private static readonly Dictionary<Type, Func<int, IList>> ListWithCapacityCreators = new();
16
18
 
17
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
18
- public static Func<int, Array> GetOrCreateArrayCreator(Type type)
19
- {
20
- return ArrayCreators.GetOrAdd(type, elementType => GetArrayCreator(elementType));
21
- }
22
-
23
19
  [MethodImpl(MethodImplOptions.AggressiveInlining)]
24
20
  public static Array CreateArray(Type type, int length)
25
21
  {
26
- return GetOrCreateArrayCreator(type).Invoke(length);
22
+ return ArrayCreators
23
+ .GetOrAdd(type, elementType => GetArrayCreator(elementType))
24
+ .Invoke(length);
27
25
  }
28
26
 
29
27
  [MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -40,32 +38,110 @@
40
38
  return ListCreators.GetOrAdd(elementType, type => GetListCreator(type)).Invoke();
41
39
  }
42
40
 
43
- public static Action<object, object> CreateFieldSetter(Type type, FieldInfo field)
41
+ public static Func<object, object> GetFieldGetter(FieldInfo field)
42
+ {
43
+ #if WEB_GL
44
+ return field.GetValue;
45
+ #else
46
+ DynamicMethod dynamicMethod = new(
47
+ $"Get{(field.DeclaringType?.Name ?? string.Empty)}{field.Name}",
48
+ typeof(object),
49
+ new[] { typeof(object) },
50
+ field.DeclaringType,
51
+ true
52
+ );
53
+
54
+ ILGenerator il = dynamicMethod.GetILGenerator();
55
+ il.Emit(OpCodes.Ldarg_0);
56
+ il.Emit(
57
+ field.DeclaringType.IsValueType ? OpCodes.Unbox : OpCodes.Castclass,
58
+ field.DeclaringType
59
+ );
60
+
61
+ il.Emit(OpCodes.Ldfld, field);
62
+
63
+ // If the field's type is a value type, box it.
64
+ if (field.FieldType.IsValueType)
65
+ {
66
+ il.Emit(OpCodes.Box, field.FieldType);
67
+ }
68
+
69
+ il.Emit(OpCodes.Ret);
70
+
71
+ return (Func<object, object>)dynamicMethod.CreateDelegate(typeof(Func<object, object>));
72
+ #endif
73
+ }
74
+
75
+ public static FieldSetter<TInstance, TValue> GetFieldSetter<TInstance, TValue>(
76
+ FieldInfo field
77
+ )
78
+ {
79
+ #if WEB_GL
80
+ return Setter;
81
+ void Setter(ref TInstance instance, TValue newValue)
82
+ {
83
+ object value = instance;
84
+ field.SetValue(value, newValue);
85
+ instance = (TInstance)value;
86
+ }
87
+ #else
88
+ Type instanceType = field.DeclaringType;
89
+ Type valueType = field.FieldType;
90
+
91
+ DynamicMethod dynamicMethod = new(
92
+ $"SetFieldGeneric{field.DeclaringType.Name}{field.Name}",
93
+ MethodAttributes.Public | MethodAttributes.Static,
94
+ CallingConventions.Standard,
95
+ typeof(void),
96
+ new[] { instanceType.MakeByRefType(), valueType },
97
+ field.Module,
98
+ true
99
+ );
100
+
101
+ ILGenerator il = dynamicMethod.GetILGenerator();
102
+ il.Emit(OpCodes.Ldarg_0);
103
+ if (!instanceType.IsValueType)
104
+ {
105
+ il.Emit(OpCodes.Ldind_Ref);
106
+ }
107
+
108
+ il.Emit(OpCodes.Ldarg_1);
109
+ il.Emit(OpCodes.Stfld, field);
110
+ il.Emit(OpCodes.Ret);
111
+
112
+ Type delegateType = typeof(FieldSetter<,>).MakeGenericType(instanceType, valueType);
113
+ return (FieldSetter<TInstance, TValue>)dynamicMethod.CreateDelegate(delegateType);
114
+ #endif
115
+ }
116
+
117
+ public static Action<object, object> GetFieldSetter(FieldInfo field)
44
118
  {
45
119
  #if WEB_GL
46
120
  return field.SetValue;
47
121
  #else
48
122
  DynamicMethod dynamicMethod = new(
49
- $"SetField{field.Name}",
123
+ $"SetField{field.DeclaringType.Name}{field.Name}",
50
124
  null,
51
125
  new[] { typeof(object), typeof(object) },
52
- type.Module,
126
+ field.DeclaringType.Module,
53
127
  true
54
128
  );
55
129
 
56
130
  ILGenerator il = dynamicMethod.GetILGenerator();
57
131
 
58
- il.Emit(OpCodes.Ldarg_0); // Load the object (arg0)
59
- il.Emit(OpCodes.Castclass, type); // Cast to the actual type
132
+ il.Emit(OpCodes.Ldarg_0);
133
+ il.Emit(
134
+ field.DeclaringType.IsValueType ? OpCodes.Unbox : OpCodes.Castclass,
135
+ field.DeclaringType
136
+ );
60
137
 
61
- il.Emit(OpCodes.Ldarg_1); // Load the value (arg1)
138
+ il.Emit(OpCodes.Ldarg_1);
62
139
  il.Emit(
63
140
  field.FieldType.IsValueType ? OpCodes.Unbox_Any : OpCodes.Castclass,
64
141
  field.FieldType
65
- ); // Cast for reference types
66
- // Unbox if it's a value type
67
- il.Emit(OpCodes.Stfld, field); // Set the field
68
- il.Emit(OpCodes.Ret); // Return
142
+ );
143
+ il.Emit(OpCodes.Stfld, field);
144
+ il.Emit(OpCodes.Ret);
69
145
  return (Action<object, object>)
70
146
  dynamicMethod.CreateDelegate(typeof(Action<object, object>));
71
147
  #endif
@@ -76,9 +152,8 @@
76
152
  #if WEB_GL
77
153
  return size => Array.CreateInstance(elementType, size);
78
154
  #else
79
-
80
- DynamicMethod dynamicMethod = new DynamicMethod(
81
- $"CreateArray{elementType.Namespace}",
155
+ DynamicMethod dynamicMethod = new(
156
+ $"CreateArray{elementType.Name}",
82
157
  typeof(Array), // Return type: Array
83
158
  new[] { typeof(int) }, // Parameter: int (size)
84
159
  true
@@ -98,7 +173,7 @@
98
173
  #if WEB_GL
99
174
  return () => (IList)Activator.CreateInstance(listType);
100
175
  #else
101
- DynamicMethod dynamicMethod = new DynamicMethod(
176
+ DynamicMethod dynamicMethod = new(
102
177
  $"CreateList{listType.Name}",
103
178
  typeof(IList), // Return type: IList
104
179
  Type.EmptyTypes, // No parameters
@@ -126,7 +201,7 @@
126
201
  #if WEB_GL
127
202
  return _ => (IList)Activator.CreateInstance(listType);
128
203
  #else
129
- DynamicMethod dynamicMethod = new DynamicMethod(
204
+ DynamicMethod dynamicMethod = new(
130
205
  $"CreateListWithCapacity{listType.Name}",
131
206
  typeof(IList), // Return type: IList
132
207
  new[] { typeof(int) }, // Parameter: int (size)
@@ -8,7 +8,7 @@
8
8
  [RequireComponent(typeof(BoxCollider2D))]
9
9
  [RequireComponent(typeof(BoxCollider2D))]
10
10
  [RequireComponent(typeof(PolygonCollider2D))]
11
- public sealed class RelationalComponentTester : MonoBehaviour
11
+ public sealed class RelationalComponentTesterComplex : MonoBehaviour
12
12
  {
13
13
  [SiblingComponent]
14
14
  internal SpriteRenderer _spriteRenderer;
@@ -0,0 +1,40 @@
1
+ namespace UnityHelpers.Tests.Components
2
+ {
3
+ namespace UnityHelpers.Tests.Components
4
+ {
5
+ using Core.Attributes;
6
+ using UnityEngine;
7
+
8
+ [DisallowMultipleComponent]
9
+ [RequireComponent(typeof(SpriteRenderer))]
10
+ [RequireComponent(typeof(BoxCollider2D))]
11
+ [RequireComponent(typeof(BoxCollider2D))]
12
+ [RequireComponent(typeof(PolygonCollider2D))]
13
+ public sealed class RelationalComponentTesterSimple : MonoBehaviour
14
+ {
15
+ [SiblingComponent]
16
+ internal SpriteRenderer _spriteRenderer;
17
+
18
+ [SiblingComponent]
19
+ internal Transform _transform;
20
+
21
+ [SiblingComponent]
22
+ internal PolygonCollider2D _polygonCollider;
23
+
24
+ // [ParentComponent]
25
+ // internal PolygonCollider2D _polygonColliderParent;
26
+
27
+ [SiblingComponent]
28
+ internal BoxCollider2D _boxCollider;
29
+
30
+ // [ParentComponent]
31
+ // internal BoxCollider2D _boxColliderParent;
32
+ //
33
+ // [ChildComponent]
34
+ // internal BoxCollider2D _boxColliderChild;
35
+ //
36
+ // [ChildComponent]
37
+ // internal BoxCollider2D _boxColliderParentChild;
38
+ }
39
+ }
40
+ }
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: 56d8fae7976140d3b7eb031a8dfccdba
3
+ timeCreated: 1742094536
@@ -0,0 +1,179 @@
1
+ namespace UnityHelpers.Tests.Tests.Runtime.Helper
2
+ {
3
+ using System;
4
+ using System.Collections;
5
+ using System.Collections.Generic;
6
+ using Core.Helper;
7
+ using NUnit.Framework;
8
+
9
+ public struct TestStruct
10
+ {
11
+ public int intValue;
12
+ }
13
+
14
+ public sealed class TestClass
15
+ {
16
+ public int intValue;
17
+ }
18
+
19
+ public sealed class ReflectionHelperTests
20
+ {
21
+ internal const int NumTries = 1_000;
22
+
23
+ private readonly Random _random = new();
24
+
25
+ [Test]
26
+ public void GetFieldGetterClass()
27
+ {
28
+ TestClass testClass = new();
29
+ Func<object, object> classGetter = ReflectionHelpers.GetFieldGetter(
30
+ typeof(TestClass).GetField(nameof(TestClass.intValue))
31
+ );
32
+ Assert.AreEqual(testClass.intValue, classGetter(testClass));
33
+ for (int i = 0; i < NumTries; ++i)
34
+ {
35
+ testClass.intValue = _random.Next(int.MinValue, int.MaxValue);
36
+ Assert.AreEqual(testClass.intValue, classGetter(testClass));
37
+ }
38
+ }
39
+
40
+ [Test]
41
+ public void GetFieldGetterStruct()
42
+ {
43
+ TestStruct testStruct = new();
44
+ Func<object, object> structGetter = ReflectionHelpers.GetFieldGetter(
45
+ typeof(TestStruct).GetField(nameof(TestStruct.intValue))
46
+ );
47
+ Assert.AreEqual(testStruct.intValue, structGetter(testStruct));
48
+ for (int i = 0; i < NumTries; ++i)
49
+ {
50
+ testStruct.intValue = _random.Next(int.MinValue, int.MaxValue);
51
+ Assert.AreEqual(testStruct.intValue, structGetter(testStruct));
52
+ }
53
+ }
54
+
55
+ [Test]
56
+ public void GetFieldSetterClass()
57
+ {
58
+ TestClass testClass = new();
59
+ Action<object, object> structSetter = ReflectionHelpers.GetFieldSetter(
60
+ typeof(TestClass).GetField(nameof(TestClass.intValue))
61
+ );
62
+ for (int i = 0; i < NumTries; ++i)
63
+ {
64
+ int expected = _random.Next(int.MinValue, int.MaxValue);
65
+ structSetter(testClass, expected);
66
+ Assert.AreEqual(expected, testClass.intValue);
67
+ }
68
+ }
69
+
70
+ [Test]
71
+ public void GetFieldSetterStruct()
72
+ {
73
+ // Need boxing
74
+ object testStruct = new TestStruct();
75
+ Action<object, object> structSetter = ReflectionHelpers.GetFieldSetter(
76
+ typeof(TestStruct).GetField(nameof(TestStruct.intValue))
77
+ );
78
+ for (int i = 0; i < NumTries; ++i)
79
+ {
80
+ int expected = _random.Next(int.MinValue, int.MaxValue);
81
+ structSetter(testStruct, expected);
82
+ Assert.AreEqual(expected, ((TestStruct)testStruct).intValue);
83
+ }
84
+ }
85
+
86
+ [Test]
87
+ public void GetFieldSetterClassGeneric()
88
+ {
89
+ TestClass testClass = new();
90
+ FieldSetter<TestClass, int> structSetter = ReflectionHelpers.GetFieldSetter<
91
+ TestClass,
92
+ int
93
+ >(typeof(TestClass).GetField(nameof(TestClass.intValue)));
94
+ for (int i = 0; i < NumTries; ++i)
95
+ {
96
+ int expected = _random.Next(int.MinValue, int.MaxValue);
97
+ structSetter(ref testClass, expected);
98
+ Assert.AreEqual(expected, testClass.intValue);
99
+ }
100
+ }
101
+
102
+ [Test]
103
+ public void GetFieldSetterStructGeneric()
104
+ {
105
+ TestStruct testStruct = new();
106
+ FieldSetter<TestStruct, int> structSetter = ReflectionHelpers.GetFieldSetter<
107
+ TestStruct,
108
+ int
109
+ >(typeof(TestStruct).GetField(nameof(TestStruct.intValue)));
110
+ for (int i = 0; i < NumTries; ++i)
111
+ {
112
+ int expected = _random.Next(int.MinValue, int.MaxValue);
113
+ structSetter(ref testStruct, expected);
114
+ Assert.AreEqual(expected, testStruct.intValue);
115
+ }
116
+ }
117
+
118
+ [Test]
119
+ public void ArrayCreator()
120
+ {
121
+ for (int i = 0; i < NumTries; ++i)
122
+ {
123
+ int count = _random.Next(1_000);
124
+ Array created = ReflectionHelpers.CreateArray(typeof(int), count);
125
+ Assert.AreEqual(count, created.Length);
126
+ Assert.IsTrue(created is int[]);
127
+ int[] typed = (int[])created;
128
+ Assert.AreEqual(count, typed.Length);
129
+ }
130
+ }
131
+
132
+ [Test]
133
+ public void ListCreator()
134
+ {
135
+ for (int i = 0; i < NumTries; ++i)
136
+ {
137
+ IList created = ReflectionHelpers.CreateList(typeof(int));
138
+ Assert.AreEqual(0, created.Count);
139
+ Assert.IsTrue(created is List<int>);
140
+ List<int> typedCreated = (List<int>)created;
141
+ int count = _random.Next(50);
142
+ List<int> expected = new();
143
+ for (int j = 0; j < count; ++j)
144
+ {
145
+ int element = _random.Next();
146
+ created.Add(element);
147
+ expected.Add(element);
148
+ Assert.AreEqual(j + 1, created.Count);
149
+ Assert.That(expected, Is.EqualTo(typedCreated));
150
+ }
151
+ }
152
+ }
153
+
154
+ [Test]
155
+ public void ListWithSizeCreator()
156
+ {
157
+ for (int i = 0; i < NumTries; ++i)
158
+ {
159
+ int capacity = _random.Next(1_000);
160
+ IList created = ReflectionHelpers.CreateList(typeof(int), capacity);
161
+ Assert.AreEqual(0, created.Count);
162
+ Assert.IsTrue(created is List<int>);
163
+ List<int> typedCreated = (List<int>)created;
164
+ Assert.AreEqual(capacity, typedCreated.Capacity);
165
+
166
+ int count = _random.Next(50);
167
+ List<int> expected = new();
168
+ for (int j = 0; j < count; ++j)
169
+ {
170
+ int element = _random.Next();
171
+ created.Add(element);
172
+ expected.Add(element);
173
+ Assert.AreEqual(j + 1, created.Count);
174
+ Assert.That(expected, Is.EqualTo(typedCreated));
175
+ }
176
+ }
177
+ }
178
+ }
179
+ }
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: 727a306f7f144d758b6f6425b6a442ed
3
+ timeCreated: 1742157564
@@ -3,6 +3,7 @@
3
3
  using System;
4
4
  using System.Diagnostics;
5
5
  using Components;
6
+ using Components.UnityHelpers.Tests.Components;
6
7
  using Core.Attributes;
7
8
  using NUnit.Framework;
8
9
  using UnityEngine;
@@ -10,12 +11,13 @@
10
11
  public sealed class RelationComponentPerformanceTests
11
12
  {
12
13
  [Test]
13
- public void RelationalPerformanceTest()
14
+ public void RelationalPerformanceComplexTest()
14
15
  {
15
16
  int count = 0;
16
17
 
17
- GameObject go = new("Test", typeof(RelationalComponentTester));
18
- RelationalComponentTester tester = go.GetComponent<RelationalComponentTester>();
18
+ GameObject go = new("Test", typeof(RelationalComponentTesterComplex));
19
+ RelationalComponentTesterComplex tester =
20
+ go.GetComponent<RelationalComponentTesterComplex>();
19
21
  // Pre-warm
20
22
  tester.AssignRelationalComponents();
21
23
 
@@ -33,5 +35,27 @@
33
35
  Assert.AreNotEqual(0, tester._parentColliders.Length);
34
36
  Assert.AreNotEqual(0, tester._siblingColliders.Length);
35
37
  }
38
+
39
+ [Test]
40
+ public void RelationalPerformanceSimpleTest()
41
+ {
42
+ int count = 0;
43
+
44
+ GameObject go = new("Test", typeof(RelationalComponentTesterSimple));
45
+ RelationalComponentTesterSimple tester =
46
+ go.GetComponent<RelationalComponentTesterSimple>();
47
+ // Pre-warm
48
+ tester.AssignRelationalComponents();
49
+
50
+ TimeSpan timeout = TimeSpan.FromSeconds(10);
51
+ Stopwatch timer = Stopwatch.StartNew();
52
+ do
53
+ {
54
+ tester.AssignRelationalComponents();
55
+ ++count;
56
+ } while (timer.Elapsed < timeout);
57
+
58
+ UnityEngine.Debug.Log($"Averaged {count / timeout.TotalSeconds} operations / second.");
59
+ }
36
60
  }
37
61
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "com.wallstop-studios.unity-helpers",
3
- "version": "2.0.0-rc38",
3
+ "version": "2.0.0-rc40",
4
4
  "displayName": "Unity Helpers",
5
5
  "description": "Various Unity Helper Library",
6
6
  "dependencies": {},
@@ -1,106 +0,0 @@
1
- name: Export and Release Unity Package
2
-
3
- on:
4
- push:
5
- branches:
6
- - main
7
- paths:
8
- - 'package.json'
9
- workflow_dispatch:
10
- inputs:
11
- logLevel:
12
- description: 'Log level'
13
- required: true
14
- default: 'warning'
15
- environment:
16
- description: 'Environment to deploy'
17
- required: false
18
- default: 'staging'
19
-
20
- env:
21
- UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
22
-
23
- jobs:
24
- package_unity:
25
- runs-on: ubuntu-latest
26
-
27
- steps:
28
- - name: Checkout Repository
29
- uses: actions/checkout@v4
30
- with:
31
- fetch-depth: 0 # Ensure full commit history for version comparison
32
-
33
- - name: Set up Node.js
34
- uses: actions/setup-node@v4
35
- with:
36
- node-version: 18
37
-
38
- - name: Check if version changed
39
- id: version_check
40
- run: |
41
- PREV_VERSION=$(git show HEAD~1:package.json | jq -r '.version' || echo "0.0.0")
42
- NEW_VERSION=$(jq -r '.version' package.json)
43
- echo "Previous version: $PREV_VERSION"
44
- echo "New version: $NEW_VERSION"
45
-
46
- if [ "$PREV_VERSION" != "$NEW_VERSION" ]; then
47
- echo "Version changed, proceeding..."
48
- echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
49
- echo "should_build=true" >> $GITHUB_ENV
50
-
51
- # Check for pre-release versions
52
- if [[ "$NEW_VERSION" == *"rc"* ]]; then
53
- echo "This is a pre-release (next tag)."
54
- echo "IS_PRERELEASE=true" >> $GITHUB_ENV
55
- else
56
- echo "This is a stable release."
57
- echo "IS_PRERELEASE=false" >> $GITHUB_ENV
58
- fi
59
- else
60
- echo "Version did not change, skipping..."
61
- echo "should_build=false" >> $GITHUB_ENV
62
- fi
63
-
64
- - name: Set up Unity
65
- if: env.should_build == 'true'
66
- uses: game-ci/unity-builder@v4
67
- env:
68
- UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
69
- UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
70
- UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
71
- with:
72
- unityVersion: 2022.3.5f1
73
- targetPlatform: StandaloneWindows64
74
- buildMethod: BuildScript.BuildProject
75
-
76
-
77
- - name: Export Unity Package
78
- if: env.should_build == 'true'
79
- run: |
80
- EXPORT_DIR="UnityHelpers"
81
- PACKAGE_NAME="WallstopStudios.UnityHelpers.unitypackage"
82
-
83
- mkdir -p $EXPORT_DIR
84
-
85
- echo "Exporting package: $EXPORT_DIR/$PACKAGE_NAME"
86
-
87
- /opt/unity/Editor/Unity \
88
- -batchmode -quit \
89
- -projectPath "$(pwd)" \
90
- -exportPackage "Assets" "$EXPORT_DIR/$PACKAGE_NAME"
91
-
92
- echo "PACKAGE_PATH=$EXPORT_DIR/$PACKAGE_NAME" >> $GITHUB_ENV
93
-
94
- - name: Create GitHub Release
95
- if: env.should_build == 'true'
96
- id: create_release
97
- uses: softprops/action-gh-release@v2
98
- with:
99
- tag_name: v${{ env.NEW_VERSION }}
100
- release_name: "Unity Helpers v${{ env.NEW_VERSION }}"
101
- body: "Automatically generated release for version ${{ env.NEW_VERSION }}."
102
- draft: false
103
- prerelease: ${{ env.IS_PRERELEASE == 'true' }}
104
- files: ${{ env.PACKAGE_PATH }}
105
- env:
106
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -1,30 +0,0 @@
1
- namespace UnityHelpers.Editor
2
- {
3
- #if UNITY_EDITOR
4
- using UnityEditor;
5
- using System.IO;
6
-
7
- // Needed for build
8
- public static class BuildScript
9
- {
10
- [MenuItem("Build/Build Unity Package")]
11
- public static void BuildProject()
12
- {
13
- string[] scenes = { "Editor/Scenes/SampleScene.unity" };
14
-
15
- const string buildPath = "Builds/UnityHelpers";
16
- if (!Directory.Exists(buildPath))
17
- {
18
- Directory.CreateDirectory(buildPath);
19
- }
20
-
21
- BuildPipeline.BuildPlayer(
22
- scenes,
23
- buildPath + "/UnityHelpers.x86_64",
24
- BuildTarget.StandaloneLinux64,
25
- BuildOptions.None
26
- );
27
- }
28
- }
29
- #endif
30
- }
@@ -1,3 +0,0 @@
1
- fileFormatVersion: 2
2
- guid: a65511569d504d0daeca9db204f1fa7d
3
- timeCreated: 1742089208