gg.easy.airship 0.1.2105 → 0.1.2107

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 (90) hide show
  1. package/AuthenticationForUnity/Runtime/Browser/AndroidBrowser.cs +85 -0
  2. package/AuthenticationForUnity/Runtime/Browser/AndroidBrowser.cs.meta +3 -0
  3. package/Editor/Accessories/AccessoryEditorWindow.cs +1 -1
  4. package/Editor/Accessories/Clothing/PlatformGearBundleManifestEditor.cs +18 -11
  5. package/Editor/AirshipComponentEditor.cs +33 -28
  6. package/Editor/AirshipComponents/AirshipComponentHeaderHandler.cs +1 -2
  7. package/Editor/AirshipComponents/AirshipComponentHeaderWrapper.cs +7 -9
  8. package/Editor/AirshipScriptGUI.cs +8 -5
  9. package/Editor/BinaryFileDragDrop.cs +38 -70
  10. package/Editor/BuildMenu.cs +42 -0
  11. package/Editor/EditorInternal/EditorGUIExtensions.cs +5 -0
  12. package/Editor/EditorInternal/EditorGUIExtensions.cs.meta +3 -0
  13. package/Editor/GameConfig/GameConfigEditor.cs +12 -0
  14. package/Editor/LuauImporter.cs +1 -1
  15. package/Editor/Packages/AirshipPackagesWindow.cs +36 -18
  16. package/Editor/Publish/API/DeploymentDto.cs +3 -0
  17. package/Editor/Publish/Deploy.cs +43 -40
  18. package/Editor/TypescriptServices/Editor/AirshipComponentButton.cs +4 -3
  19. package/Editor/TypescriptServices/Editor/AirshipScriptFileEditor.cs +8 -8
  20. package/Editor/TypescriptServices/Editor/TypescriptOptions.cs +42 -58
  21. package/Editor/TypescriptServices/Projects/TypescriptProjectsService.cs +2 -1
  22. package/Editor/Util/AirshipEditorGUI.cs +87 -0
  23. package/Runtime/Code/Agones/AutoShutdownBridge.cs +1 -1
  24. package/Runtime/Code/Auth/AuthManager.cs +2 -0
  25. package/Runtime/Code/Bootstrap/BundleDownloader.cs +8 -2
  26. package/Runtime/Code/Bootstrap/SignalHandler.cs +29 -30
  27. package/Runtime/Code/Bundles/AirshipEditorNetworkConfig.cs.meta +9 -1
  28. package/Runtime/Code/Bundles/AirshipPlatform.cs +1 -12
  29. package/Runtime/Code/Bundles/SystemRoot.cs +45 -5
  30. package/Runtime/Code/CoreUI/Loading/LoadingQuitButton.cs +7 -0
  31. package/Runtime/Code/GameConfig/GameConfig.cs +2 -0
  32. package/Runtime/Code/Luau/AirshipComponent.cs +399 -847
  33. package/Runtime/Code/Luau/AirshipComponentV2.cs +360 -0
  34. package/Runtime/Code/Luau/AirshipComponentV2.cs.meta +3 -0
  35. package/Runtime/Code/Luau/Editor/LuauCoreEditor.cs +30 -0
  36. package/Runtime/Code/Luau/Editor/LuauCoreEditor.cs.meta +3 -0
  37. package/Runtime/Code/Luau/LuauCompiler.cs +1 -1
  38. package/Runtime/Code/Luau/LuauCore.cs +19 -64
  39. package/Runtime/Code/Luau/LuauCore.cs.meta +11 -11
  40. package/Runtime/Code/Luau/LuauCoreCallbacks.cs +72 -89
  41. package/Runtime/Code/Luau/LuauCoreSystemNamespaces.cs +4 -1
  42. package/Runtime/Code/Luau/LuauCoreUtilities.cs +3 -26
  43. package/Runtime/Code/Luau/LuauMetadata.cs +12 -13
  44. package/Runtime/Code/Luau/LuauPlugin.cs +16 -4
  45. package/Runtime/Code/Luau/LuauPluginRaw.cs +17 -17
  46. package/Runtime/Code/Luau/LuauScript.cs +191 -0
  47. package/Runtime/Code/Luau/LuauScript.cs.meta +3 -0
  48. package/Runtime/Code/Luau/LuauState.cs +8 -3
  49. package/Runtime/Code/Luau/ReflectionList.cs +1 -1
  50. package/Runtime/Code/Luau/ScriptingEntryPoint.cs +13 -21
  51. package/Runtime/Code/LuauAPI/AirshipBehaviourHelper.cs +34 -42
  52. package/Runtime/Code/LuauAPI/Bridge.cs +7 -0
  53. package/Runtime/Code/LuauHelper/AssetBridgeInjector.cs +3 -4
  54. package/Runtime/Code/LuauHelper/LuauHelper.cs +2 -1
  55. package/Runtime/Code/LuauHelper/LuauHelper.cs.meta +9 -1
  56. package/Runtime/Code/MainMenu/MainMenuSceneManager.cs +3 -5
  57. package/Runtime/Code/Misc/AirshipBuildInfo.cs +1 -1
  58. package/Runtime/Code/Misc/CanvasDistanceCondition.cs +2 -0
  59. package/Runtime/Code/Network/AirshipNetworkManager.cs +4 -5
  60. package/Runtime/Code/Platform/Shared/AirshipInventoryServiceDto.cs +7 -2
  61. package/Runtime/Code/Player/Accessories/AccessoryBuilder.cs +0 -6
  62. package/Runtime/Code/Player/Character/Animation/CharacterAnimationHelper.cs +13 -13
  63. package/Runtime/Code/Player/OcclusionCam.cs +60 -53
  64. package/Runtime/Code/TSCodeGen/TypeGenerator.cs +3 -0
  65. package/Runtime/Code/UserInput/InputBridge.cs.meta +11 -11
  66. package/Runtime/Plugins/Android/libLuauPlugin.so +0 -0
  67. package/Runtime/Plugins/Android/libLuauPlugin.so.meta +61 -0
  68. package/Runtime/Plugins/{Mac/LuauPlugin.bundle/Contents/MacOS/LuauPlugin.meta → Android.meta} +2 -1
  69. package/Runtime/Plugins/Linux/libLuauPlugin.so +0 -0
  70. package/Runtime/Plugins/Linux/libLuauPlugin.so.meta +21 -40
  71. package/Runtime/Plugins/Mac/LuauPlugin.bundle/Contents/Info.plist +1 -1
  72. package/Runtime/Plugins/Mac/LuauPlugin.bundle/Contents/MacOS/LuauPlugin +0 -0
  73. package/Runtime/Plugins/Windows/x64/LuauPlugin.dll +0 -0
  74. package/Runtime/Plugins/Windows/x64/LuauPlugin.dll.meta +36 -34
  75. package/Runtime/Plugins/Windows/x64/LuauPlugin.pdb +0 -0
  76. package/Runtime/Plugins/iOS/LuauPluginIos.a +0 -0
  77. package/Runtime/Plugins/iOS/LuauPluginIos.a.meta +27 -39
  78. package/Runtime/Prefabs/LuauCore.prefab +104 -0
  79. package/{Editor/Resources/HumanAnimationPrefab.prefab.meta → Runtime/Prefabs/LuauCore.prefab.meta} +1 -1
  80. package/Runtime/Scenes/CoreScene.unity +231 -263
  81. package/Runtime/Scenes/Login.unity +371 -315
  82. package/Runtime/Scenes/MainMenu.unity +146 -66
  83. package/ThirdParty/AppleAuth/Editor/ProjectCapabilityManagerExtension.cs +58 -46
  84. package/ThirdParty/NativeGallery/Editor/NGPostProcessBuild.cs +7 -1
  85. package/URP/AirshipURPAssetBaked.asset +2 -2
  86. package/URP/Shaders/AirshipCharacterAlpha.shader +2 -3
  87. package/package.json +1 -1
  88. package/Editor/Resources/HumanAnimationPrefab.prefab +0 -23574
  89. package/Runtime/Code/Luau/AirshipComponentUpdater.cs +0 -59
  90. package/Runtime/Code/Luau/AirshipComponentUpdater.cs.meta +0 -3
@@ -0,0 +1,85 @@
1
+ using System;
2
+ using System.Net;
3
+ using System.Threading;
4
+ using System.Threading.Tasks;
5
+ using UnityEngine;
6
+
7
+ namespace Cdm.Authentication.Browser {
8
+ /// <summary>
9
+ /// OAuth 2.0 verification browser that runs a local server and waits for a call with
10
+ /// the authorization verification code.
11
+ /// </summary>
12
+ public class AndroidBrowser : IBrowser {
13
+ private string _prefix;
14
+
15
+ public AndroidBrowser(string prefix) {
16
+ _prefix = prefix;
17
+ }
18
+
19
+ private TaskCompletionSource<BrowserResult> _taskCompletionSource;
20
+
21
+ /// <summary>
22
+ /// Gets or sets the close page response. This HTML response is shown to the user after redirection is done.
23
+ /// </summary>
24
+ public string closePageResponse { get; set; } =
25
+ "<html><body><b>DONE!</b><br>(You can close this tab/window now)</body></html>";
26
+
27
+ public async Task<BrowserResult> StartAsync(string loginUrl, string redirectUrl, CancellationToken cancellationToken = default) {
28
+ _taskCompletionSource = new TaskCompletionSource<BrowserResult>();
29
+
30
+ cancellationToken.Register(() => {
31
+ _taskCompletionSource?.TrySetCanceled();
32
+ });
33
+
34
+ using var httpListener = new HttpListener();
35
+
36
+ try {
37
+ var prefix = _prefix;
38
+ prefix = AddForwardSlashIfNecessary(prefix);
39
+ httpListener.Prefixes.Add(prefix);
40
+ if (httpListener.IsListening) {
41
+ httpListener.Stop();
42
+ }
43
+ httpListener.Start();
44
+ httpListener.BeginGetContext(IncomingHttpRequest, httpListener);
45
+
46
+ Application.OpenURL(loginUrl);
47
+
48
+ return await _taskCompletionSource.Task;
49
+ } finally {
50
+ httpListener.Stop();
51
+ }
52
+ }
53
+
54
+ private void IncomingHttpRequest(IAsyncResult result) {
55
+ var httpListener = (HttpListener)result.AsyncState;
56
+ var httpContext = httpListener.EndGetContext(result);
57
+ var httpRequest = httpContext.Request;
58
+
59
+ // Build a response to send an "ok" back to the browser for the user to see.
60
+ var httpResponse = httpContext.Response;
61
+ var buffer = System.Text.Encoding.UTF8.GetBytes(closePageResponse);
62
+
63
+ // Send the output to the client browser.
64
+ httpResponse.ContentLength64 = buffer.Length;
65
+ var output = httpResponse.OutputStream;
66
+ output.Write(buffer, 0, buffer.Length);
67
+ output.Close();
68
+
69
+ _taskCompletionSource.SetResult(new BrowserResult(BrowserStatus.Success, httpRequest.Url.ToString()));
70
+ }
71
+
72
+ /// <summary>
73
+ /// Prefixes must end in a forward slash ("/")
74
+ /// </summary>
75
+ /// <see href="https://learn.microsoft.com/en-us/dotnet/api/system.net.httplistener?view=net-7.0#remarks" />
76
+ private string AddForwardSlashIfNecessary(string url) {
77
+ string forwardSlash = "/";
78
+ if (!url.EndsWith(forwardSlash)) {
79
+ url += forwardSlash;
80
+ }
81
+
82
+ return url;
83
+ }
84
+ }
85
+ }
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: 8f64d370a4f941beaf2c599b91c73adc
3
+ timeCreated: 1741806451
@@ -46,7 +46,7 @@ namespace Editor.Accessories {
46
46
 
47
47
  private static void Log(string message){
48
48
  #if AIRSHIP_INTERNAL
49
- Debug.Log("AccEditor: " + message);
49
+ // Debug.Log("AccEditor: " + message);
50
50
  #endif
51
51
  }
52
52
 
@@ -109,21 +109,28 @@ namespace Editor.Accessories.Clothing {
109
109
  (string category, string subcategory) = GetGearCategory(gear);
110
110
 
111
111
  // Create a new class id
112
- var req = UnityWebRequest.PostWwwForm($"{AirshipPlatformUrl.contentService}/gear/resource-id/{easyOrgId}",
113
- JsonUtility.ToJson(new GearCreateRequest() {
114
- name = gear.name,
115
- imageId = "c0e07e88-09d4-4962-b42d-7794a7ad4cb2",
116
- description = "Clothing",
117
- gear = new GearCreateRequest() {
118
- airAssets = new string[]{},
119
- category = category,
120
- subcategory = subcategory
121
- }
122
- }));
112
+ var data = JsonUtility.ToJson(new GearCreateRequest() {
113
+ name = gear.name,
114
+ imageId = "64351892-40d4-409b-ab3a-501818213b50",
115
+ description = "Clothing",
116
+ airAssets = new string[] { },
117
+ category = category,
118
+ subcategory = subcategory,
119
+ });
120
+ var req = UnityWebRequest.Post($"{AirshipPlatformUrl.contentService}/gear/resource-id/{easyOrgId}", data, "application/json");
123
121
  req.SetRequestHeader("Authorization", "Bearer " + InternalHttpManager.editorAuthToken);
124
122
  req.SetRequestHeader("x-airship-ignore-rate-limit", "true");
125
123
  await req.SendWebRequest();
124
+ if (req.result != UnityWebRequest.Result.Success) {
125
+ Debug.Log("Post request: " + data);
126
+ Debug.LogError("Failed to create gear class: " + req.downloadHandler.text);
127
+ return;
128
+ }
126
129
  Debug.Log("Create classId response: " + req.downloadHandler.text);
130
+ var createResponse = JsonUtility.FromJson<GearCreateResponse>(req.downloadHandler.text);
131
+ gear.classId = createResponse.classId;
132
+ EditorUtility.SetDirty(gear);
133
+ AssetDatabase.SaveAssets();
127
134
  }
128
135
 
129
136
  string airId = manifest.airId;
@@ -31,7 +31,7 @@ public class ScriptBindingEditor : UnityEditor.Editor {
31
31
 
32
32
  public void OnEnable() {
33
33
  var comp = (Component)serializedObject.targetObject;
34
- var metadata = serializedObject.FindProperty("m_metadata");
34
+ var metadata = serializedObject.FindProperty("metadata");
35
35
  var metadataProperties = metadata.FindPropertyRelative("properties");
36
36
  for (var i = 0; i < metadataProperties.arraySize; i++) {
37
37
  var serializedProperty = metadataProperties.GetArrayElementAtIndex(i);
@@ -49,18 +49,18 @@ public class ScriptBindingEditor : UnityEditor.Editor {
49
49
 
50
50
  AirshipComponent binding = (AirshipComponent)target;
51
51
 
52
- if (binding.scriptFile == null && !string.IsNullOrEmpty(binding.m_fileFullPath)) {
53
- // Debug.Log("Setting Script File from Path: " + binding.m_fileFullPath);
54
- // binding.SetScriptFromPath(binding.m_fileFullPath, LuauContext.Game);
55
- if (binding.scriptFile == null) {
56
- Debug.LogWarning($"Failed to load script asset: {binding.m_fileFullPath}");
57
- EditorGUILayout.HelpBox("Missing reference. This is likely from renaming a script.\n\nOld path: " + binding.m_fileFullPath.Replace("Assets/Bundles/", ""), MessageType.Warning);
52
+ if (binding.script == null && !string.IsNullOrEmpty(binding.scriptPath)) {
53
+ // Debug.Log("Setting Script File from Path: " + binding.scriptPath);
54
+ // binding.SetScriptFromPath(binding.scriptPath, LuauContext.Game);
55
+ if (binding.script == null) {
56
+ Debug.LogWarning($"Failed to load script asset: {binding.scriptPath}");
57
+ EditorGUILayout.HelpBox("Missing reference. This is likely from renaming a script.\n\nOld path: " + binding.scriptPath.Replace("Assets/Bundles/", ""), MessageType.Warning);
58
58
  }
59
59
  }
60
60
 
61
61
  DrawScriptBindingProperties(binding);
62
62
 
63
- if (binding.scriptFile != null && binding.scriptFile.m_metadata != null) {
63
+ if (binding.script != null && binding.script.m_metadata != null) {
64
64
  if (ShouldReconcile(binding)) {
65
65
  binding.ReconcileMetadata();
66
66
  serializedObject.ApplyModifiedProperties();
@@ -70,8 +70,8 @@ public class ScriptBindingEditor : UnityEditor.Editor {
70
70
  CheckDefaults(binding);
71
71
  }
72
72
 
73
- if (binding.scriptFile != null) {
74
- var metadata = serializedObject.FindProperty("m_metadata");
73
+ if (binding.script != null) {
74
+ var metadata = serializedObject.FindProperty("metadata");
75
75
  var metadataName = metadata.FindPropertyRelative("name");
76
76
  if (!string.IsNullOrEmpty(metadataName.stringValue)) {
77
77
  DrawBinaryFileMetadata(binding, metadata);
@@ -87,6 +87,10 @@ public class ScriptBindingEditor : UnityEditor.Editor {
87
87
  EditorGUILayout.LabelField("Component Id", binding.GetAirshipComponentId().ToString());
88
88
  }
89
89
  EditorGUILayout.EndHorizontal();
90
+
91
+ EditorGUILayout.BeginHorizontal();
92
+ EditorGUILayout.LabelField("Context", binding.context.ToString());
93
+ EditorGUILayout.EndHorizontal();
90
94
  }
91
95
  #endif
92
96
 
@@ -155,10 +159,10 @@ public class ScriptBindingEditor : UnityEditor.Editor {
155
159
  }
156
160
 
157
161
  private void CheckDefaults(AirshipComponent binding) {
158
- var metadata = serializedObject.FindProperty("m_metadata");
162
+ var metadata = serializedObject.FindProperty("metadata");
159
163
 
160
164
  var metadataProperties = metadata.FindPropertyRelative("properties");
161
- var originalMetadataProperties = binding.scriptFile.m_metadata.properties;
165
+ var originalMetadataProperties = binding.script.m_metadata.properties;
162
166
 
163
167
  var setDefault = false;
164
168
 
@@ -201,12 +205,12 @@ public class ScriptBindingEditor : UnityEditor.Editor {
201
205
  }
202
206
 
203
207
  private bool ShouldReconcile(AirshipComponent binding) {
204
- if (binding.m_metadata == null || binding.scriptFile.m_metadata == null) return false;
208
+ if (binding.metadata == null || binding.script.m_metadata == null) return false;
205
209
 
206
- var metadata = serializedObject.FindProperty("m_metadata");
210
+ var metadata = serializedObject.FindProperty("metadata");
207
211
 
208
212
  var metadataProperties = metadata.FindPropertyRelative("properties");
209
- var originalMetadataProperties = binding.scriptFile.m_metadata?.properties;
213
+ var originalMetadataProperties = binding.script.m_metadata?.properties;
210
214
 
211
215
  if (metadataProperties.arraySize != originalMetadataProperties.Count) {
212
216
  return true;
@@ -282,27 +286,27 @@ public class ScriptBindingEditor : UnityEditor.Editor {
282
286
  private void DrawScriptBindingProperties(AirshipComponent binding) {
283
287
  EditorGUILayout.Space(5);
284
288
 
285
- var script = binding.scriptFile;
286
- var scriptPath = serializedObject.FindProperty("m_fileFullPath");
289
+ var script = binding.script;
290
+ var scriptPath = serializedObject.FindProperty("scriptPath");
287
291
  var content = new GUIContent {
288
292
  text = "Script",
289
293
  tooltip = scriptPath.stringValue,
290
294
  };
291
295
 
292
- if (binding.scriptFile != null && (binding.m_metadata != null || Application.isPlaying)) {
296
+ if (script != null && (binding.metadata != null || Application.isPlaying)) {
293
297
  GUI.enabled = false;
294
298
  }
295
299
 
296
300
  var newScript = EditorGUILayout.ObjectField(content, script, typeof(AirshipScript), true);
297
301
  if (newScript != script) {
298
- binding.scriptFile = (AirshipScript)newScript;
299
- scriptPath.stringValue = newScript == null ? "" : ((AirshipScript)newScript).assetPath;
302
+ binding.script = (AirshipScript)newScript;
303
+ scriptPath.stringValue = newScript == null ? "" : binding.script.m_path;
300
304
  serializedObject.ApplyModifiedProperties();
301
305
  }
302
306
 
303
307
  GUI.enabled = true;
304
308
 
305
- if (newScript == null) {
309
+ if (newScript == null && !Application.isPlaying) {
306
310
  EditorGUILayout.Space(5);
307
311
 
308
312
  var rect = GUILayoutUtility.GetLastRect();
@@ -312,8 +316,9 @@ public class ScriptBindingEditor : UnityEditor.Editor {
312
316
 
313
317
  EditorGUILayout.BeginHorizontal();
314
318
  if (GUILayout.Button("Select Airship Component", style)) {
315
- AirshipComponentDropdown dd = new AirshipComponentDropdown(new AdvancedDropdownState(), (binaryFile) => {
316
- binding.SetScript(binaryFile, Application.isPlaying);
319
+ AirshipComponentDropdown dd = new AirshipComponentDropdown(new AdvancedDropdownState(), (airshipScript) => {
320
+ binding.script = airshipScript;
321
+ binding.scriptPath = airshipScript.m_path;
317
322
  serializedObject.ApplyModifiedProperties();
318
323
  EditorUtility.SetDirty(serializedObject.targetObject);
319
324
  });
@@ -333,11 +338,11 @@ public class ScriptBindingEditor : UnityEditor.Editor {
333
338
  var propertyList = new List<SerializedProperty>();
334
339
  var indexDictionary = new Dictionary<string, int>();
335
340
 
336
- if (binding.scriptFile.m_metadata != null) {
341
+ if (binding.script.m_metadata != null) {
337
342
  for (var i = 0; i < metadataProperties.arraySize; i++) {
338
343
  var property = metadataProperties.GetArrayElementAtIndex(i);
339
344
  propertyList.Add(property);
340
- indexDictionary.Add(binding.scriptFile.m_metadata.properties[i].name, i);
345
+ indexDictionary.Add(binding.script.m_metadata.properties[i].name, i);
341
346
  }
342
347
  }
343
348
 
@@ -348,7 +353,7 @@ public class ScriptBindingEditor : UnityEditor.Editor {
348
353
  );
349
354
 
350
355
  foreach (var prop in propertyList) {
351
- DrawCustomProperty(binding.GetInstanceID(), binding.scriptFile.m_metadata, prop);
356
+ DrawCustomProperty(binding.GetInstanceID(), binding.script.m_metadata, prop);
352
357
  }
353
358
  }
354
359
 
@@ -532,13 +537,13 @@ public class ScriptBindingEditor : UnityEditor.Editor {
532
537
  var scriptPath = buildInfo.GetScriptPathByTypeName(typeName);
533
538
 
534
539
  switch (draggedObject) {
535
- case AirshipComponent component when scriptPath != null && buildInfo.Inherits(component.scriptFile, scriptPath):
540
+ case AirshipComponent component when scriptPath != null && buildInfo.Inherits(component.script, scriptPath):
536
541
  objRef = component;
537
542
  break;
538
543
  case AirshipComponent:
539
544
  continue;
540
545
  case GameObject go: {
541
- var firstMatchingComponent = go.GetComponents<AirshipComponent>().FirstOrDefault(f => buildInfo.Inherits(f.scriptFile, scriptPath));
546
+ var firstMatchingComponent = go.GetComponents<AirshipComponent>().FirstOrDefault(f => buildInfo.Inherits(f.script, scriptPath));
542
547
  if (firstMatchingComponent != null) {
543
548
  objRef = firstMatchingComponent;
544
549
  }
@@ -21,8 +21,7 @@ public class AirshipComponentHeaderHandler {
21
21
  if (inspectorMode == InspectorMode.Debug) return;
22
22
 
23
23
  var component = editorAndHeader.editor.target as Component;
24
- if (component is not AirshipComponent binding || binding.scriptFile == null ||
25
- !binding.scriptFile.airshipBehaviour) continue;
24
+ if (component is not AirshipComponent binding || binding.script == null || !binding.script.airshipBehaviour) continue;
26
25
 
27
26
  if(onGUIHandler.Method is { Name: "DrawWrappedHeaderGUI" }) continue;
28
27
 
@@ -15,7 +15,7 @@ internal static class AirshipComponentHeader {
15
15
  private static readonly GUIContent label = new GUIContent("");
16
16
 
17
17
  internal static float AfterComponentHeader(AirshipComponent component, Rect headerRect, bool isHeaderSelected) {
18
- var scriptFile = component.scriptFile;
18
+ var scriptFile = component.script;
19
19
  var metadata = scriptFile.m_metadata;
20
20
 
21
21
  if (metadata == null) return 0f;
@@ -69,25 +69,23 @@ internal class AirshipComponentHeaderWrapper {
69
69
  }
70
70
 
71
71
  public void DrawWrappedHeaderGUI() {
72
- if (component == null || component.scriptFile == null || !component.scriptFile.airshipBehaviour) {
72
+ if (component == null || component.script == null || !component.script.airshipBehaviour) {
73
73
  RemoveOverrideHeader();
74
74
  return;
75
75
  }
76
76
 
77
77
  Rect headerRect = headerElement.contentRect;
78
- bool HeaderIsSelected = headerElement.focusController.focusedElement == headerElement;
78
+ bool headerIsSelected = headerElement.focusController.focusedElement == headerElement;
79
79
 
80
80
  unityOnGUIHandler.Invoke();
81
81
 
82
- if (component.m_metadata.name != "") {
83
- AirshipComponentHeader.AfterComponentHeader(component, headerRect, HeaderIsSelected);
82
+ if (component.metadata.name != "") {
83
+ AirshipComponentHeader.AfterComponentHeader(component, headerRect, headerIsSelected);
84
84
  }
85
85
  }
86
86
 
87
- private void RemoveOverrideHeader()
88
- {
89
- if(headerElement is null)
90
- {
87
+ private void RemoveOverrideHeader() {
88
+ if (headerElement is null) {
91
89
  return;
92
90
  }
93
91
 
@@ -10,6 +10,10 @@ using Object = UnityEngine.Object;
10
10
  namespace Code.Luau {
11
11
  public static class AirshipScriptGUI {
12
12
  internal delegate Object AirshipBehaviourValidator(Object[] references, SerializedProperty property);
13
+
14
+ private static bool IsBindableAsComponent(AirshipComponent component, AirshipScript file) {
15
+ return file.assetPath == component.script.assetPath;
16
+ }
13
17
 
14
18
  private static Object Validate(Object[] references, AirshipScript script, AirshipComponent binding) {
15
19
  if (references.Length <= 0) return null;
@@ -21,13 +25,13 @@ namespace Code.Luau {
21
25
  references = gameObject.GetComponents(typeof(AirshipComponent));
22
26
  foreach (var reference in references) {
23
27
  if (reference != null && reference is AirshipComponent bindingComponent &&
24
- (bindingComponent.IsBindableAsComponent(script) ||
28
+ (IsBindableAsComponent(bindingComponent, script) ||
25
29
  buildInfo.ComponentIsValidInheritance(bindingComponent, script))) {
26
30
  return reference;
27
31
  }
28
32
  }
29
33
  }
30
- else if (objectReference is AirshipComponent otherBinding && (otherBinding.IsBindableAsComponent(script) || buildInfo.ComponentIsValidInheritance(otherBinding, script))) {
34
+ else if (objectReference is AirshipComponent otherBinding && (IsBindableAsComponent(otherBinding, script) || buildInfo.ComponentIsValidInheritance(otherBinding, script))) {
31
35
  return otherBinding;
32
36
  }
33
37
 
@@ -130,8 +134,7 @@ namespace Code.Luau {
130
134
  },
131
135
  item => {
132
136
  var itemScriptBinding = item.ToObject<AirshipComponent>();
133
- return itemScriptBinding != null &&
134
- itemScriptBinding.IsBindableAsComponent(script);
137
+ return itemScriptBinding != null && IsBindableAsComponent(itemScriptBinding, script);
135
138
  }, null, script.m_metadata?.displayName ?? "AirshipBehaviour");
136
139
  view.SetSearchText($"h:t:ScriptBinding"); // #m_fileFullPath={script.m_path}
137
140
 
@@ -168,7 +171,7 @@ namespace Code.Luau {
168
171
  case EventType.Repaint: {
169
172
  var temp = EditorGUIUtility.ObjectContent(obj, typeof(AirshipComponent));
170
173
 
171
- var scriptInfo = airshipComponent && airshipComponent.scriptFile ? airshipComponent.scriptFile : script;
174
+ var scriptInfo = airshipComponent && airshipComponent.script ? airshipComponent.script : script;
172
175
 
173
176
  var displayName = scriptInfo.m_metadata != null && !string.IsNullOrEmpty(scriptInfo.m_metadata.displayName)
174
177
  ? scriptInfo.m_metadata.displayName
@@ -3,38 +3,29 @@ using Luau;
3
3
  using UnityEditor;
4
4
  using UnityEngine;
5
5
 
6
- namespace Editor
7
- {
8
- public static class BinaryFileDragDrop
9
- {
6
+ namespace Editor {
7
+ public static class BinaryFileDragDrop {
10
8
  [InitializeOnLoadMethod]
11
- private static void OnLoad()
12
- {
9
+ private static void OnLoad() {
13
10
  DragAndDrop.AddDropHandler(OnInspectorDrop);
14
11
  DragAndDrop.AddDropHandler(OnHierarchyDrop);
15
12
  DragAndDrop.AddDropHandler(OnSceneDrop);
16
13
  }
17
14
 
18
- private static bool IsDraggingBinaryFile()
19
- {
20
- foreach (var obj in DragAndDrop.objectReferences)
21
- {
22
- if (obj is AirshipScript)
23
- {
15
+ private static bool IsDraggingBinaryFile() {
16
+ foreach (var obj in DragAndDrop.objectReferences) {
17
+ if (obj is AirshipScript) {
24
18
  return true;
25
19
  }
26
20
  }
27
21
  return false;
28
22
  }
29
23
 
30
- private static Dictionary<string, AirshipScript> GetDraggedBinaryFiles()
31
- {
24
+ private static Dictionary<string, AirshipScript> GetDraggedBinaryFiles() {
32
25
  var binaryFiles = new Dictionary<string, AirshipScript>();
33
- for (var i = 0; i < DragAndDrop.objectReferences.Length; i++)
34
- {
26
+ for (var i = 0; i < DragAndDrop.objectReferences.Length; i++) {
35
27
  var obj = DragAndDrop.objectReferences[i];
36
- if (obj is AirshipScript binaryFile)
37
- {
28
+ if (obj is AirshipScript binaryFile) {
38
29
  var path = DragAndDrop.paths[i];
39
30
  binaryFiles[path] = binaryFile;
40
31
  }
@@ -43,27 +34,22 @@ namespace Editor
43
34
  return binaryFiles;
44
35
  }
45
36
 
46
- private static DragAndDropVisualMode OnSceneDrop(object dropUpon, Vector3 worldPos, Vector2 viewportPos, Transform parent, bool perform)
47
- {
48
- if (!perform)
49
- {
37
+ private static DragAndDropVisualMode OnSceneDrop(object dropUpon, Vector3 worldPos, Vector2 viewportPos, Transform parent, bool perform) {
38
+ if (!perform) {
50
39
  return IsDraggingBinaryFile() && dropUpon != null ? DragAndDropVisualMode.Move : DragAndDropVisualMode.None;
51
40
  }
52
41
 
53
42
  GameObject go = null;
54
- if (dropUpon is GameObject gameObj)
55
- {
43
+ if (dropUpon is GameObject gameObj) {
56
44
  go = gameObj;
57
45
  }
58
46
 
59
- if (go == null)
60
- {
47
+ if (go == null) {
61
48
  return DragAndDropVisualMode.None;
62
49
  }
63
50
 
64
51
  var binaryFiles = GetDraggedBinaryFiles();
65
- if (binaryFiles.Count == 0)
66
- {
52
+ if (binaryFiles.Count == 0) {
67
53
  return DragAndDropVisualMode.None;
68
54
  }
69
55
 
@@ -72,42 +58,34 @@ namespace Editor
72
58
  return DragAndDropVisualMode.Move;
73
59
  }
74
60
 
75
- private static DragAndDropVisualMode OnHierarchyDrop(int instanceId, HierarchyDropFlags dropMode, Transform parent, bool perform)
76
- {
77
- if (!perform)
78
- {
61
+ private static DragAndDropVisualMode OnHierarchyDrop(int instanceId, HierarchyDropFlags dropMode, Transform parent, bool perform) {
62
+ if (!perform) {
79
63
  return IsDraggingBinaryFile() && dropMode == HierarchyDropFlags.DropUpon ? DragAndDropVisualMode.Move : DragAndDropVisualMode.None;
80
64
  }
81
65
 
82
- if (dropMode != HierarchyDropFlags.DropUpon)
83
- {
66
+ if (dropMode != HierarchyDropFlags.DropUpon) {
84
67
  return DragAndDropVisualMode.None;
85
68
  }
86
69
 
87
70
  // Grab the game object:
88
71
  GameObject go = null;
89
- if (instanceId != 0)
90
- {
72
+ if (instanceId != 0) {
91
73
  var target = EditorUtility.InstanceIDToObject(instanceId);
92
- if (target is GameObject gameObj)
93
- {
74
+ if (target is GameObject gameObj) {
94
75
  go = gameObj;
95
76
  }
96
77
  }
97
- else if (parent != null)
98
- {
78
+ else if (parent != null) {
99
79
  // If instanceId is 0, then we're dragging into a prefab and need to use the 'parent' transform:
100
80
  go = parent.gameObject;
101
81
  }
102
82
 
103
- if (go == null)
104
- {
83
+ if (go == null) {
105
84
  return DragAndDropVisualMode.None;
106
85
  }
107
86
 
108
87
  var binaryFiles = GetDraggedBinaryFiles();
109
- if (binaryFiles.Count == 0)
110
- {
88
+ if (binaryFiles.Count == 0) {
111
89
  return DragAndDropVisualMode.None;
112
90
  }
113
91
 
@@ -116,27 +94,22 @@ namespace Editor
116
94
  return DragAndDropVisualMode.Move;
117
95
  }
118
96
 
119
- private static DragAndDropVisualMode OnInspectorDrop(object[] targets, bool perform)
120
- {
97
+ private static DragAndDropVisualMode OnInspectorDrop(object[] targets, bool perform) {
121
98
  // If hovering, just quickly check if any of the grabbed items are a BinaryFile:
122
- if (!perform)
123
- {
99
+ if (!perform) {
124
100
  return IsDraggingBinaryFile() ? DragAndDropVisualMode.Move : DragAndDropVisualMode.None;
125
101
  }
126
102
 
127
103
  // Collect all dragged binary files:
128
104
  var binaryFiles = GetDraggedBinaryFiles();
129
105
 
130
- if (binaryFiles.Count == 0)
131
- {
106
+ if (binaryFiles.Count == 0) {
132
107
  return DragAndDropVisualMode.None;
133
108
  }
134
109
 
135
110
  // Add the script bindings into the given targets:
136
- foreach (var target in targets)
137
- {
138
- if (target is GameObject go)
139
- {
111
+ foreach (var target in targets) {
112
+ if (target is GameObject go) {
140
113
  AddAllScriptBindings(go, binaryFiles);
141
114
  }
142
115
  }
@@ -144,30 +117,25 @@ namespace Editor
144
117
  return DragAndDropVisualMode.Move;
145
118
  }
146
119
 
147
- private static void AddAllScriptBindings(GameObject target, Dictionary<string, AirshipScript> binaryFiles)
148
- {
149
- foreach (var pair in binaryFiles)
150
- {
120
+ private static void AddAllScriptBindings(GameObject target, Dictionary<string, AirshipScript> binaryFiles) {
121
+ foreach (var pair in binaryFiles) {
151
122
  AddScriptBinding(target, pair.Value, pair.Key);
152
123
  }
153
124
  }
154
125
 
155
- private static void AddScriptBinding(GameObject target, AirshipScript airshipScript, string path)
156
- {
126
+ private static void AddScriptBinding(GameObject target, AirshipScript airshipScript, string path) {
157
127
  if (HasScriptBinding(target, path)) return;
158
128
 
159
- var scriptBinding = target.AddComponent<AirshipComponent>();
160
- scriptBinding.SetScript(airshipScript);
161
- EditorUtility.SetDirty(scriptBinding);
129
+ var component = target.AddComponent<AirshipComponent>();
130
+ component.script = airshipScript;
131
+ component.scriptPath = airshipScript.m_path;
132
+ EditorUtility.SetDirty(component);
162
133
  }
163
134
 
164
- private static bool HasScriptBinding(GameObject target, string path)
165
- {
166
- var scriptBindings = target.GetComponents<AirshipComponent>();
167
- foreach (var binding in scriptBindings)
168
- {
169
- if (binding.m_fileFullPath == path)
170
- {
135
+ private static bool HasScriptBinding(GameObject target, string path) {
136
+ var components = target.GetComponents<AirshipComponent>();
137
+ foreach (var component in components) {
138
+ if (component.scriptPath == path) {
171
139
  return true;
172
140
  }
173
141
  }