gg.easy.airship 0.1.2189 → 0.1.2191
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.
- package/Editor/Accessories/Clothing/PlatformGearBundleManifestEditor.cs +5 -0
- package/Editor/AirshipComponentBuildImporter.cs +13 -1
- package/Editor/AirshipComponentEditor.cs +106 -14
- package/Editor/AirshipEditors/AirshipCustomEditors.cs +319 -0
- package/Editor/AirshipEditors/AirshipCustomEditors.cs.meta +3 -0
- package/Editor/AirshipEditors/AirshipEditor.cs +257 -0
- package/Editor/AirshipEditors/AirshipEditor.cs.meta +3 -0
- package/Editor/AirshipEditors/AirshipPropertyDecorator.cs +75 -0
- package/Editor/AirshipEditors/AirshipPropertyDecorator.cs.meta +3 -0
- package/Editor/AirshipEditors/AirshipSerializedObject.cs +107 -0
- package/Editor/AirshipEditors/AirshipSerializedObject.cs.meta +3 -0
- package/Editor/AirshipEditors/CustomAirshipDecoratorAttribute.cs +20 -0
- package/Editor/AirshipEditors/CustomAirshipDecoratorAttribute.cs.meta +3 -0
- package/Editor/AirshipEditors/CustomAirshipEditorAttribute.cs +23 -0
- package/Editor/AirshipEditors/CustomAirshipEditorAttribute.cs.meta +3 -0
- package/Editor/AirshipEditors/DefaultAirshipComponentEditor.cs +15 -0
- package/Editor/AirshipEditors/DefaultAirshipComponentEditor.cs.meta +3 -0
- package/Editor/AirshipEditors/Properties/AirshipPropertyExtensions.cs +97 -0
- package/Editor/AirshipEditors/Properties/AirshipPropertyExtensions.cs.meta +3 -0
- package/Editor/AirshipEditors/Properties/AirshipSerializedArray.cs +143 -0
- package/Editor/AirshipEditors/Properties/AirshipSerializedArray.cs.meta +3 -0
- package/Editor/AirshipEditors/Properties/AirshipSerializedArrayValue.cs +21 -0
- package/Editor/AirshipEditors/Properties/AirshipSerializedArrayValue.cs.meta +3 -0
- package/Editor/AirshipEditors/Properties/AirshipSerializedProperty.cs +108 -0
- package/Editor/AirshipEditors/Properties/AirshipSerializedProperty.cs.meta +3 -0
- package/Editor/AirshipEditors/Properties/AirshipSerializedValue.cs +296 -0
- package/Editor/AirshipEditors/Properties/AirshipSerializedValue.cs.meta +3 -0
- package/Editor/AirshipEditors/Properties.meta +3 -0
- package/Editor/AirshipEditors.meta +3 -0
- package/Editor/AirshipScriptGUI.cs +4 -0
- package/Editor/Artifacts/AirshipReconciliationService.cs +5 -5
- package/Editor/AssemblyInfo.cs +4 -0
- package/Editor/AssemblyInfo.cs.meta +3 -0
- package/Editor/BuildMenu.cs +79 -2
- package/Editor/EditorIntegrationsConfig.cs +12 -3
- package/Editor/EditorInternal/AirshipObjectGUIInternal.cs +5 -3
- package/Editor/Quality/QualityConfig.cs +37 -5
- package/Editor/Settings/AirshipBetaSettingsProvider.cs +151 -0
- package/Editor/Settings/AirshipBetaSettingsProvider.cs.meta +3 -0
- package/Editor/Settings/AirshipLocalProjectEditorSettings.cs +59 -0
- package/Editor/Settings/AirshipLocalProjectEditorSettings.cs.meta +3 -0
- package/Editor/Settings/AirshipSettingsProvider.cs +7 -25
- package/Editor/TypescriptAst/TsArrayTypeNode.cs +87 -0
- package/Editor/TypescriptAst/TsArrayTypeNode.cs.meta +3 -0
- package/Editor/TypescriptAst/TsBlock.cs +20 -0
- package/Editor/TypescriptAst/TsBlock.cs.meta +3 -0
- package/Editor/TypescriptAst/TsComment.cs +43 -0
- package/Editor/TypescriptAst/TsComment.cs.meta +2 -0
- package/Editor/TypescriptAst/TsEnumDeclaration.cs +51 -0
- package/Editor/TypescriptAst/TsEnumDeclaration.cs.meta +2 -0
- package/Editor/TypescriptAst/TsEnumMember.cs +46 -0
- package/Editor/TypescriptAst/TsEnumMember.cs.meta +2 -0
- package/Editor/TypescriptAst/TsExpressionStatement.cs +12 -0
- package/Editor/TypescriptAst/TsExpressionStatement.cs.meta +3 -0
- package/Editor/TypescriptAst/TsExtensions.cs +15 -0
- package/Editor/TypescriptAst/TsExtensions.cs.meta +3 -0
- package/Editor/TypescriptAst/TsFunctionDeclaration.cs +80 -0
- package/Editor/TypescriptAst/TsFunctionDeclaration.cs.meta +3 -0
- package/Editor/TypescriptAst/TsIdentifier.cs +20 -0
- package/Editor/TypescriptAst/TsIdentifier.cs.meta +2 -0
- package/Editor/TypescriptAst/TsKeyOfOperator.cs +20 -0
- package/Editor/TypescriptAst/TsKeyOfOperator.cs.meta +2 -0
- package/Editor/TypescriptAst/TsKeywordModifier.cs +27 -0
- package/Editor/TypescriptAst/TsKeywordModifier.cs.meta +3 -0
- package/Editor/TypescriptAst/TsKeywordTypeNode.cs +48 -0
- package/Editor/TypescriptAst/TsKeywordTypeNode.cs.meta +3 -0
- package/Editor/TypescriptAst/TsNumericLiteral.cs +41 -0
- package/Editor/TypescriptAst/TsNumericLiteral.cs.meta +2 -0
- package/Editor/TypescriptAst/TsParameter.cs +48 -0
- package/Editor/TypescriptAst/TsParameter.cs.meta +3 -0
- package/Editor/TypescriptAst/TsPropertyName.cs +42 -0
- package/Editor/TypescriptAst/TsPropertyName.cs.meta +2 -0
- package/Editor/TypescriptAst/TsStatementBlock.cs +14 -0
- package/Editor/TypescriptAst/TsStatementBlock.cs.meta +3 -0
- package/Editor/TypescriptAst/TsStringLiteral.cs +22 -0
- package/Editor/TypescriptAst/TsStringLiteral.cs.meta +2 -0
- package/Editor/TypescriptAst/TsTypeDeclaration.cs +29 -0
- package/Editor/TypescriptAst/TsTypeDeclaration.cs.meta +2 -0
- package/Editor/TypescriptAst/TsTypeQuery.cs +20 -0
- package/Editor/TypescriptAst/TsTypeQuery.cs.meta +2 -0
- package/Editor/TypescriptAst/TypescriptCodeGen.cs +81 -0
- package/Editor/TypescriptAst/TypescriptCodeGen.cs.meta +2 -0
- package/Editor/TypescriptAst.meta +3 -0
- package/Editor/TypescriptCompiler~/utsc.js +145 -145
- package/Editor/TypescriptImporter.cs +12 -4
- package/Editor/TypescriptServices/Compiler/TypescriptCompilationService.cs +27 -24
- package/Editor/TypescriptServices/Editor/TypescriptImporterEditor.cs +15 -3
- package/Editor/TypescriptServices/Projects/TypescriptProject.cs +8 -0
- package/Editor/TypescriptServices/TypescriptServices.cs +10 -9
- package/Editor/Util/AirshipBehaviourSelector.cs +38 -0
- package/Editor/Util/AirshipBehaviourSelector.cs.meta +3 -0
- package/Editor/Util/AirshipClipboardUtility.cs +46 -0
- package/Editor/Util/AirshipClipboardUtility.cs.meta +3 -0
- package/Editor/Util/AirshipEditorGUI.cs +678 -146
- package/Editor/Util/AirshipEditorGUI.cs.meta +2 -2
- package/Editor/Util/AirshipEditorGUI.internal.cs +693 -0
- package/Editor/Util/AirshipEditorGUI.internal.cs.meta +3 -0
- package/Editor/Util/AirshipGUI.cs +21 -0
- package/Editor/Util/AirshipGUI.cs.meta +3 -0
- package/Generator/LuauDirectCallbackGenerator.dll +0 -0
- package/Resources/AirshipEmptyMaterial.mat +1 -1
- package/Runtime/Code/Accessories/Clothing/PlatformGear.cs +29 -7
- package/Runtime/Code/Airship/Resources/Scripts/MaterialColorURP.cs +23 -1
- package/Runtime/Code/CoreUI/Components/ForceClose.cs +27 -1
- package/Runtime/Code/CoreUI/CoreLoadingScreen.prefab +15 -0
- package/Runtime/Code/Luau/AirshipEditorInfo.cs +121 -26
- package/Runtime/Code/Luau/LuauCoreCallbacks.cs +26 -4
- package/Runtime/Code/Luau/LuauCoreReflection.cs +20 -1
- package/Runtime/Code/Luau/LuauMetadata.cs +25 -5
- package/Runtime/Code/LuauAPI/ApplicationAPI.cs +70 -5
- package/Runtime/Code/LuauAPI/RectTransformUtilityAPI.cs +49 -0
- package/Runtime/Code/LuauAPI/StaticBatchingUtilityAPI.cs +9 -0
- package/Runtime/Code/LuauAPI/StaticBatchingUtilityAPI.cs.meta +3 -0
- package/Runtime/Code/Misc/AirshipBuildInfo.cs +71 -2
- package/Runtime/Code/Misc/AirshipType.cs +67 -0
- package/Runtime/Code/Misc/AirshipType.cs.meta +3 -0
- package/Runtime/Code/VoxelWorld/Airship.VoxelWorld.asmdef +1 -1
- package/Runtime/Code/VoxelWorld/VoxelMeshProcessor.cs +36 -29
- package/Runtime/Code/VoxelWorld/VoxelQuarterBlock.cs +2 -2
- package/Runtime/Code/VoxelWorld/VoxelWorld.cs +436 -295
- package/Runtime/Code/VoxelWorld/VoxelWorldChunk.cs +17 -17
- package/Runtime/Code/VoxelWorld/VoxelWorldCollision.cs +8 -6
- package/Runtime/Code/VoxelWorld/VoxelWorldNetworker.cs +38 -31
- package/Runtime/Plugins/Android/libLuauPlugin.so +0 -0
- package/Runtime/Plugins/Linux/libLuauPlugin.so +0 -0
- package/Runtime/Plugins/Mac/LuauPlugin.bundle/Contents/Info.plist +1 -1
- package/Runtime/Plugins/Mac/LuauPlugin.bundle/Contents/MacOS/LuauPlugin +0 -0
- package/Runtime/Plugins/Mac/LuauPlugin.bundle/Contents/MacOS/LuauPlugin.meta +7 -0
- package/Runtime/Plugins/Mac/Titlebar.bundle/Contents/Info.plist.meta +7 -0
- package/Runtime/Plugins/Mac/Titlebar.bundle/Contents/MacOS/Titlebar.meta +7 -0
- package/Runtime/Plugins/Mac/Titlebar.bundle/Contents/MacOS.meta +8 -0
- package/Runtime/Plugins/Mac/Titlebar.bundle/Contents/_CodeSignature/CodeResources.meta +7 -0
- package/Runtime/Plugins/Mac/Titlebar.bundle/Contents/_CodeSignature.meta +8 -0
- package/Runtime/Plugins/Mac/Titlebar.bundle/Contents.meta +8 -0
- package/Runtime/Plugins/Mac/UnityInterfacePlugin.bundle/Contents/Info.plist.meta +7 -0
- package/Runtime/Plugins/Mac/UnityInterfacePlugin.bundle/Contents/MacOS/UnityInterfacePlugin.meta +7 -0
- package/Runtime/Plugins/Mac/UnityInterfacePlugin.bundle/Contents/MacOS.meta +8 -0
- package/Runtime/Plugins/Mac/UnityInterfacePlugin.bundle/Contents.meta +8 -0
- package/Runtime/Plugins/Windows/x64/LuauPlugin.dll +0 -0
- package/Runtime/Plugins/iOS/LuauPluginIos.a +0 -0
- package/ThirdParty/UiRoundedCorners/ImageWithRoundedCorners.cs +77 -22
- package/ThirdParty/UiRoundedCorners/RoundedCorners.mat +142 -0
- package/ThirdParty/UiRoundedCorners/RoundedCorners.mat.meta +8 -0
- package/ThirdParty/UiRoundedCorners/RoundedCorners.shader +1 -10
- package/ThirdParty/UiRoundedCorners/ShaderSetup.cginc +8 -0
- package/ThirdParty/UnityMeshSimplifier-3.1.0/Runtime/LODGenerator.cs +3 -2
- package/URP/AirshipMobileURPAsset.asset +5 -5
- package/package.json +1 -1
|
@@ -236,6 +236,7 @@ namespace Editor.Accessories.Clothing {
|
|
|
236
236
|
await updateReq.SendWebRequest();
|
|
237
237
|
if (updateReq.result != UnityWebRequest.Result.Success) {
|
|
238
238
|
Debug.LogError("Failed to update air asset: " + updateReq.downloadHandler.text);
|
|
239
|
+
EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Standalone, BuildTarget.StandaloneWindows);
|
|
239
240
|
return;
|
|
240
241
|
}
|
|
241
242
|
var updateData = JsonUtility.FromJson<AirAssetCreateResponse>(updateReq.downloadHandler.text);
|
|
@@ -256,6 +257,7 @@ namespace Editor.Accessories.Clothing {
|
|
|
256
257
|
if (putReq.result != UnityWebRequest.Result.Success) {
|
|
257
258
|
Debug.LogError(putReq.error);
|
|
258
259
|
Debug.LogError(putReq.downloadHandler.text);
|
|
260
|
+
EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Standalone, BuildTarget.StandaloneWindows);
|
|
259
261
|
return;
|
|
260
262
|
}
|
|
261
263
|
}
|
|
@@ -280,10 +282,13 @@ namespace Editor.Accessories.Clothing {
|
|
|
280
282
|
await req.SendWebRequest();
|
|
281
283
|
if (req.result != UnityWebRequest.Result.Success) {
|
|
282
284
|
Debug.LogError($"patch classId. url: {url}, response: {req.downloadHandler.text}, authToken: {InternalHttpManager.editorAuthToken}");
|
|
285
|
+
EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Standalone, BuildTarget.StandaloneWindows);
|
|
283
286
|
return;
|
|
284
287
|
}
|
|
285
288
|
}
|
|
286
289
|
|
|
290
|
+
EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Standalone, BuildTarget.StandaloneWindows);
|
|
291
|
+
|
|
287
292
|
Debug.Log($"<color=green>Finished building {bundlePaths.Count} asset bundles for all platforms in {st.Elapsed.Seconds} seconds.</color> File size: " + AirshipEditorUtil.GetFileSizeText(bytesCount));
|
|
288
293
|
}
|
|
289
294
|
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
using System
|
|
1
|
+
using System;
|
|
2
|
+
using System.IO;
|
|
3
|
+
using System.Linq;
|
|
2
4
|
using Luau;
|
|
5
|
+
using UnityEditor;
|
|
3
6
|
using UnityEditor.AssetImporters;
|
|
4
7
|
using UnityEngine;
|
|
5
8
|
|
|
@@ -18,4 +21,13 @@ namespace Editor {
|
|
|
18
21
|
ctx.SetMainObject(airshipBuild);
|
|
19
22
|
}
|
|
20
23
|
}
|
|
24
|
+
|
|
25
|
+
public class AirshipTypePostProcessor : AssetPostprocessor {
|
|
26
|
+
private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets,
|
|
27
|
+
string[] movedFromAssetPaths) {
|
|
28
|
+
if (importedAssets.Contains(AirshipBuildInfo.PrimaryAssetPath)) {
|
|
29
|
+
AirshipCustomEditors.RegisterEditorsForRegisteredTypes();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
21
33
|
}
|
|
@@ -39,6 +39,8 @@ public class ScriptBindingEditor : UnityEditor.Editor {
|
|
|
39
39
|
/** Maps (game object id, prop name) to ArrayDisplayInfo object (for Array properties) */
|
|
40
40
|
private Dictionary<(int componentInstanceId, string propertyName), ArrayDisplayInfo> _reorderableLists = new();
|
|
41
41
|
|
|
42
|
+
private AirshipEditor editor;
|
|
43
|
+
|
|
42
44
|
public void OnEnable() {
|
|
43
45
|
var comp = (Component)serializedObject.targetObject;
|
|
44
46
|
var metadata = serializedObject.FindProperty("metadata");
|
|
@@ -50,6 +52,16 @@ public class ScriptBindingEditor : UnityEditor.Editor {
|
|
|
50
52
|
var listPropType = LuauMetadataPropertySerializer.GetAirshipComponentPropertyTypeFromString(arrayType, false);
|
|
51
53
|
GetOrCreateArrayDisplayInfo(comp.GetInstanceID(), serializedProperty, serializedProperty.FindPropertyRelative("name").stringValue, listPropType, itemInfo);
|
|
52
54
|
}
|
|
55
|
+
|
|
56
|
+
AirshipComponent binding = (AirshipComponent)target;
|
|
57
|
+
if (binding.script != null && binding.metadata != null) {
|
|
58
|
+
var customEditorType = AirshipCustomEditors.GetEditorTypeForTypeName(binding.metadata.name);
|
|
59
|
+
|
|
60
|
+
if (customEditorType != null && AirshipCustomEditors.TryGetEditorForComponent(binding, customEditorType, out var editor)) {
|
|
61
|
+
editor.OnEnable();
|
|
62
|
+
this.editor = editor;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
53
65
|
}
|
|
54
66
|
|
|
55
67
|
private void OnDisable() {
|
|
@@ -58,24 +70,89 @@ public class ScriptBindingEditor : UnityEditor.Editor {
|
|
|
58
70
|
|
|
59
71
|
var componentInstanceId = comp.GetInstanceID();
|
|
60
72
|
_componentSeenArrayProps.Remove(componentInstanceId);
|
|
73
|
+
|
|
74
|
+
AirshipComponent binding = (AirshipComponent)target;
|
|
75
|
+
if (binding.script != null && binding.metadata != null) {
|
|
76
|
+
var customEditorType = AirshipCustomEditors.GetEditorTypeForTypeName(binding.metadata.name);
|
|
77
|
+
if (customEditorType != null) {
|
|
78
|
+
var editor = AirshipCustomEditors.GetEditorForComponent(binding, customEditorType, serializedObject);
|
|
79
|
+
editor.OnDisable();
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
this.editor = null;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
private void OnDestroy() {
|
|
87
|
+
AirshipComponent binding = (AirshipComponent)target;
|
|
88
|
+
AirshipCustomEditors.DestroyEditor(binding);
|
|
61
89
|
}
|
|
62
90
|
|
|
63
91
|
private bool debugging = false;
|
|
64
|
-
|
|
65
|
-
public override void OnInspectorGUI() {
|
|
66
|
-
serializedObject.Update();
|
|
67
92
|
|
|
68
|
-
|
|
93
|
+
private void OnSceneGUI() {
|
|
94
|
+
if (!AirshipCustomEditors.UseNewInspector) return;
|
|
95
|
+
if (!this.editor) return;
|
|
96
|
+
this.editor.OnSceneGUI();
|
|
97
|
+
}
|
|
69
98
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
99
|
+
public override void OnPreviewGUI(Rect r, GUIStyle background) {
|
|
100
|
+
if (!AirshipCustomEditors.UseNewInspector) return;
|
|
101
|
+
if (!this.editor) return;
|
|
102
|
+
this.editor.OnPreviewGUI(r, background);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
public override bool HasPreviewGUI() {
|
|
106
|
+
if (!AirshipCustomEditors.UseNewInspector) return false;
|
|
107
|
+
return this.editor != null ? this.editor.HasPreviewGUI() : false;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
private bool OnAirshipInspectorGUI() {
|
|
111
|
+
if (!AirshipCustomEditors.UseNewInspector) return false;
|
|
112
|
+
|
|
113
|
+
AirshipComponent binding = (AirshipComponent)target;
|
|
114
|
+
|
|
115
|
+
Type customEditorType = null;
|
|
116
|
+
if (binding.script != null && binding.metadata != null) {
|
|
117
|
+
customEditorType = AirshipCustomEditors.GetEditorTypeForTypeName(binding.metadata.name);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (customEditorType != null && binding.script != null) {
|
|
121
|
+
var metadata = serializedObject.FindProperty("metadata");
|
|
122
|
+
var metadataName = metadata.FindPropertyRelative("name");
|
|
123
|
+
|
|
124
|
+
if (binding.script != null && binding.script.m_metadata != null) {
|
|
125
|
+
if (ShouldReconcile(binding)) {
|
|
126
|
+
binding.ReconcileMetadata(ReconcileSource.Inspector);
|
|
127
|
+
serializedObject.ApplyModifiedProperties();
|
|
128
|
+
serializedObject.Update();
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
CheckDefaults(binding);
|
|
76
132
|
}
|
|
133
|
+
|
|
134
|
+
if (!string.IsNullOrEmpty(metadataName.stringValue)) {
|
|
135
|
+
var componentEditor = AirshipCustomEditors.GetEditorForComponent(binding, customEditorType, serializedObject);
|
|
136
|
+
if (this.editor == null) this.editor = componentEditor;
|
|
137
|
+
componentEditor.script = binding.script;
|
|
138
|
+
componentEditor.target = binding;
|
|
139
|
+
componentEditor.OnInspectorGUI();
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
serializedObject.ApplyModifiedProperties();
|
|
143
|
+
|
|
144
|
+
if (Application.isPlaying) {
|
|
145
|
+
var component = (AirshipComponent)target;
|
|
146
|
+
component.WriteChangedComponentProperties();
|
|
147
|
+
}
|
|
148
|
+
return true;
|
|
77
149
|
}
|
|
78
150
|
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
private void OnAirshipLegacyInspectorGUI() {
|
|
155
|
+
AirshipComponent binding = (AirshipComponent)target;
|
|
79
156
|
DrawScriptBindingProperties(binding);
|
|
80
157
|
|
|
81
158
|
if (binding.script != null && binding.script.m_metadata != null) {
|
|
@@ -115,6 +192,23 @@ public class ScriptBindingEditor : UnityEditor.Editor {
|
|
|
115
192
|
serializedObject.ApplyModifiedProperties();
|
|
116
193
|
}
|
|
117
194
|
|
|
195
|
+
public override void OnInspectorGUI() {
|
|
196
|
+
serializedObject.Update();
|
|
197
|
+
|
|
198
|
+
AirshipComponent binding = (AirshipComponent)target;
|
|
199
|
+
|
|
200
|
+
if (binding.script == null && !string.IsNullOrEmpty(binding.scriptPath)) {
|
|
201
|
+
if (binding.script == null) {
|
|
202
|
+
Debug.LogWarning($"Failed to load script asset: {binding.scriptPath}");
|
|
203
|
+
EditorGUILayout.HelpBox("Missing reference. This is likely from renaming a script.\n\nOld path: " + binding.scriptPath.Replace("Assets/Bundles/", ""), MessageType.Warning);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
if (!OnAirshipInspectorGUI()) {
|
|
208
|
+
OnAirshipLegacyInspectorGUI();
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
118
212
|
|
|
119
213
|
private Dictionary<int, HashSet<string>> _componentSeenArrayProps = new();
|
|
120
214
|
private void CleanupOrphanedArrayDisplayInfos(int componentInstanceId) {
|
|
@@ -145,8 +239,6 @@ public class ScriptBindingEditor : UnityEditor.Editor {
|
|
|
145
239
|
}
|
|
146
240
|
|
|
147
241
|
private ArrayDisplayInfo GetOrCreateArrayDisplayInfo(int componentInstanceId, SerializedProperty arraySerializedProperty, string propName, AirshipComponentPropertyType listType, SerializedProperty itemInfo) {
|
|
148
|
-
|
|
149
|
-
|
|
150
242
|
Type objType = null;
|
|
151
243
|
if (listType == AirshipComponentPropertyType.AirshipObject || listType == AirshipComponentPropertyType.AirshipComponent) {
|
|
152
244
|
objType = TypeReflection.GetTypeFromString(itemInfo.FindPropertyRelative("objectType").stringValue);
|
|
@@ -861,7 +953,7 @@ public class ScriptBindingEditor : UnityEditor.Editor {
|
|
|
861
953
|
var objOld = objectRefs.arraySize > index ? objectRefs.GetArrayElementAtIndex(index).objectReferenceValue : null;
|
|
862
954
|
|
|
863
955
|
if (objectType == typeof(Sprite) || objectType == typeof(Texture2D)) {
|
|
864
|
-
var objNew = AirshipEditorGUI.ObjectField(rect, new GUIContent(label), objOld, objectType, true);
|
|
956
|
+
var objNew = AirshipEditorGUI.ObjectField(rect, new GUIContent(label), objOld, objectType, true, false);
|
|
865
957
|
if (objOld != objNew) {
|
|
866
958
|
objectRefs.GetArrayElementAtIndex(index).objectReferenceValue = objNew;
|
|
867
959
|
arrayModified.boolValue = true;
|
|
@@ -1286,7 +1378,7 @@ public class ScriptBindingEditor : UnityEditor.Editor {
|
|
|
1286
1378
|
|
|
1287
1379
|
UnityEngine.Object newObject;
|
|
1288
1380
|
if (t == typeof(Sprite) || t == typeof(Texture2D)) {
|
|
1289
|
-
newObject = AirshipEditorGUI.ObjectFieldLayout(guiContent, currentObject, t, true);
|
|
1381
|
+
newObject = AirshipEditorGUI.ObjectFieldLayout(guiContent, currentObject, t, true, false);
|
|
1290
1382
|
} else {
|
|
1291
1383
|
newObject = EditorGUILayout.ObjectField(guiContent, currentObject, t, true);
|
|
1292
1384
|
}
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using System.IO;
|
|
4
|
+
using System.Reflection;
|
|
5
|
+
using TypescriptAst;
|
|
6
|
+
using Luau;
|
|
7
|
+
using UnityEditor;
|
|
8
|
+
using UnityEngine;
|
|
9
|
+
using Object = UnityEngine.Object;
|
|
10
|
+
|
|
11
|
+
/// <summary>
|
|
12
|
+
/// The custom editor namespace for the Airship Editor
|
|
13
|
+
/// </summary>
|
|
14
|
+
public static class AirshipCustomEditors {
|
|
15
|
+
/// <summary>
|
|
16
|
+
/// Contains information about the custom Airship editor
|
|
17
|
+
/// </summary>
|
|
18
|
+
internal class CustomEditorInfo {
|
|
19
|
+
public Type EditorType { get; }
|
|
20
|
+
public AirshipType AirshipType { get; }
|
|
21
|
+
public CustomAirshipEditorAttribute EditorAttribute { get; }
|
|
22
|
+
public CustomEditorInfo(Type editorType, AirshipType airshipType, CustomAirshipEditorAttribute editorAttribute) {
|
|
23
|
+
EditorType = editorType;
|
|
24
|
+
EditorAttribute = editorAttribute;
|
|
25
|
+
AirshipType = airshipType;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
#region Fields
|
|
30
|
+
private static Dictionary<AirshipType, CustomEditorInfo> airshipTypeToCustomEditor = new();
|
|
31
|
+
private static Dictionary<int, AirshipEditor> instanceToAirshipEditor = new();
|
|
32
|
+
|
|
33
|
+
private static Dictionary<Type, AirshipPropertyDecorator> typeToEditorPropertyDecorator = new();
|
|
34
|
+
private static Dictionary<string, Type> decoratorNameToEditorType = new();
|
|
35
|
+
|
|
36
|
+
internal const string inspectorModeKey = "AirshipBetaInspectorMode";
|
|
37
|
+
internal const EditorInspectorMode DefaultInspectorMode = EditorInspectorMode.UseLegacyInspector;
|
|
38
|
+
#endregion
|
|
39
|
+
|
|
40
|
+
#region Properties
|
|
41
|
+
/// <summary>
|
|
42
|
+
/// A list of the active custom editors
|
|
43
|
+
/// </summary>
|
|
44
|
+
internal static IEnumerable<CustomEditorInfo> CustomEditors {
|
|
45
|
+
get => airshipTypeToCustomEditor.Values;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/// <summary>
|
|
49
|
+
/// A list of all the active airship editors (includes the default inspectors)
|
|
50
|
+
/// </summary>
|
|
51
|
+
internal static IEnumerable<AirshipEditor> AllEditors {
|
|
52
|
+
get => instanceToAirshipEditor.Values;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
internal static EditorInspectorMode UserInspectorMode {
|
|
56
|
+
get {
|
|
57
|
+
var value = (EditorInspectorMode) EditorPrefs.GetInt(inspectorModeKey, (int) EditorInspectorMode.Default);
|
|
58
|
+
return value;
|
|
59
|
+
}
|
|
60
|
+
set {
|
|
61
|
+
var current = (EditorInspectorMode) EditorPrefs.GetInt(inspectorModeKey, (int) EditorInspectorMode.Default);
|
|
62
|
+
if (value == current) return;
|
|
63
|
+
|
|
64
|
+
if (value == EditorInspectorMode.UseLegacyInspector) {
|
|
65
|
+
instanceToAirshipEditor.Clear();
|
|
66
|
+
airshipTypeToCustomEditor.Clear();
|
|
67
|
+
} else if (value == EditorInspectorMode.UseNewInspector || (value == EditorInspectorMode.Default &&
|
|
68
|
+
DefaultInspectorMode ==
|
|
69
|
+
EditorInspectorMode.UseNewInspector)) {
|
|
70
|
+
RegisterEditorsForRegisteredTypes();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
EditorPrefs.SetInt(inspectorModeKey, (int) value);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
internal static bool UseNewInspector {
|
|
78
|
+
get {
|
|
79
|
+
var inspector = UserInspectorMode;
|
|
80
|
+
if (inspector == EditorInspectorMode.Default) inspector = DefaultInspectorMode;
|
|
81
|
+
return inspector == EditorInspectorMode.UseNewInspector;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
#endregion
|
|
86
|
+
|
|
87
|
+
#region Editor Registration Methods
|
|
88
|
+
|
|
89
|
+
private static bool RegisterEditor(Type editorType, CustomAirshipEditorAttribute editorAttribute) {
|
|
90
|
+
var typeName = editorAttribute.TypeName;
|
|
91
|
+
var filePath = editorAttribute.FilePath;
|
|
92
|
+
|
|
93
|
+
var pathType = string.IsNullOrEmpty(filePath) ?
|
|
94
|
+
AirshipBuildInfo.Instance.GetTypeByName(typeName) :
|
|
95
|
+
AirshipBuildInfo.Instance.GetTypeByPathAndName(filePath, typeName);
|
|
96
|
+
|
|
97
|
+
if (pathType == null) {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (!AirshipCustomEditors.airshipTypeToCustomEditor.TryGetValue(pathType, out var _)) {
|
|
102
|
+
AirshipCustomEditors.airshipTypeToCustomEditor.Add(pathType, new CustomEditorInfo(editorType, pathType, editorAttribute));
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
internal static void RegisterEditorsForRegisteredTypes() {
|
|
109
|
+
airshipTypeToCustomEditor.Clear();
|
|
110
|
+
decoratorNameToEditorType.Clear();
|
|
111
|
+
typeToEditorPropertyDecorator.Clear();
|
|
112
|
+
instanceToAirshipEditor.Clear();
|
|
113
|
+
|
|
114
|
+
var typeEditorAttributes = TypeCache.GetTypesWithAttribute<CustomAirshipEditorAttribute>();
|
|
115
|
+
|
|
116
|
+
foreach (var editorType in typeEditorAttributes) {
|
|
117
|
+
var internalAttr = editorType.GetCustomAttribute<CustomAirshipCoreEditorAttribute>();
|
|
118
|
+
if (internalAttr != null) {
|
|
119
|
+
RegisterEditor(editorType, internalAttr);
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
var attr = editorType.GetCustomAttribute<CustomAirshipEditorAttribute>();
|
|
124
|
+
RegisterEditor(editorType, attr);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
var decoratorStatements = new List<IStatement>();
|
|
128
|
+
|
|
129
|
+
var decoratorAttributes = TypeCache.GetTypesWithAttribute<CustomAirshipDecoratorAttribute>();
|
|
130
|
+
foreach (var decoratorAttributeType in decoratorAttributes) {
|
|
131
|
+
var attr = decoratorAttributeType.GetCustomAttribute<CustomAirshipDecoratorAttribute>();
|
|
132
|
+
decoratorNameToEditorType.Add(attr.Name, decoratorAttributeType);
|
|
133
|
+
|
|
134
|
+
var propertyDecorator = (AirshipPropertyDecorator)ScriptableObject.CreateInstance(decoratorAttributeType);
|
|
135
|
+
propertyDecorator.attribute = attr;
|
|
136
|
+
typeToEditorPropertyDecorator.Add(decoratorAttributeType, propertyDecorator);
|
|
137
|
+
|
|
138
|
+
var decoratorParams = propertyDecorator.GetFunctionDeclaration();
|
|
139
|
+
if (decoratorParams != null) {
|
|
140
|
+
decoratorStatements.Add(new TsComment() { IsJsDoc = true, Text = $"Generated editor decorator '{attr.Name}' from {decoratorAttributeType.FullName}" });
|
|
141
|
+
decoratorStatements.Add(decoratorParams);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (decoratorStatements.Count > 0) {
|
|
146
|
+
var sourceFile = new TsSourceFile() {
|
|
147
|
+
Statements = decoratorStatements.ToArray(),
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
File.WriteAllText("Assets/decorators.d.ts", sourceFile.ToString());
|
|
151
|
+
} else if (File.Exists("Assets/decorators.d.ts")) {
|
|
152
|
+
File.Delete("Assets/decorators.d.ts");
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
#if AIRSHIP_INTERNAL
|
|
156
|
+
Debug.Log($"Registered {airshipTypeToCustomEditor.Count} custom editors, {decoratorNameToEditorType.Count} decorators.");
|
|
157
|
+
#endif
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
[InitializeOnLoadMethod]
|
|
161
|
+
internal static void InitializeEditorSymbols() {
|
|
162
|
+
string currentDefines = PlayerSettings.GetScriptingDefineSymbols(
|
|
163
|
+
UnityEditor.Build.NamedBuildTarget.FromBuildTargetGroup(EditorUserBuildSettings.selectedBuildTargetGroup));
|
|
164
|
+
|
|
165
|
+
HashSet<string> defines = new HashSet<string>(currentDefines.Split(';')) {
|
|
166
|
+
"AIRSHIP_EDITOR_API"
|
|
167
|
+
};
|
|
168
|
+
string newDefines = string.Join(";", defines);
|
|
169
|
+
|
|
170
|
+
if (newDefines != currentDefines) {
|
|
171
|
+
PlayerSettings.SetScriptingDefineSymbols(
|
|
172
|
+
UnityEditor.Build.NamedBuildTarget.FromBuildTargetGroup(EditorUserBuildSettings.selectedBuildTargetGroup), newDefines);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
[InitializeOnLoadMethod]
|
|
177
|
+
internal static void RegisterCustomEditors() {
|
|
178
|
+
RegisterEditorsForRegisteredTypes();
|
|
179
|
+
|
|
180
|
+
EditorApplication.playModeStateChanged += change => {
|
|
181
|
+
if (change == PlayModeStateChange.ExitingEditMode || change == PlayModeStateChange.EnteredPlayMode) {
|
|
182
|
+
RegisterEditorsForRegisteredTypes();
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
#endregion
|
|
188
|
+
|
|
189
|
+
#region Custom Editor Query Methods
|
|
190
|
+
|
|
191
|
+
/// <summary>
|
|
192
|
+
/// Gets all editors of the given custom editor info
|
|
193
|
+
/// </summary>
|
|
194
|
+
/// <param name="editorInfo">The custom editor to grab the editors from</param>
|
|
195
|
+
/// <returns>A list of Airship editors that match the given custom editor</returns>
|
|
196
|
+
internal static IEnumerable<AirshipEditor> GetEditors(CustomEditorInfo editorInfo) {
|
|
197
|
+
var instances = new List<AirshipEditor>();
|
|
198
|
+
foreach (var instance in instanceToAirshipEditor) {
|
|
199
|
+
if (instance.Value.GetType() == editorInfo.EditorType) instances.Add(instance.Value);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
return instances;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
internal static Type GetEditorTypeForTypeName(string typeName) {
|
|
206
|
+
if (!UseNewInspector) return null;
|
|
207
|
+
|
|
208
|
+
var pathType = AirshipBuildInfo.Instance.GetTypeByName(typeName);
|
|
209
|
+
if (pathType == null) return null;
|
|
210
|
+
|
|
211
|
+
if (airshipTypeToCustomEditor.TryGetValue(pathType, out var editorType)) {
|
|
212
|
+
return editorType.EditorType;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
return typeof(DefaultAirshipComponentEditor);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
internal static bool TryGetEditorForComponent(AirshipComponent component, Type type, out AirshipEditor editor) {
|
|
219
|
+
return instanceToAirshipEditor.TryGetValue(component.GetInstanceID(), out editor);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
internal static AirshipEditor GetEditorForComponent(AirshipComponent component, Type type, SerializedObject serializedObject) {
|
|
223
|
+
if (instanceToAirshipEditor.TryGetValue(component.GetInstanceID(), out var editor)) {
|
|
224
|
+
editor.serializedObject ??= new AirshipSerializedObject();
|
|
225
|
+
editor.serializedObject.Update(editor, serializedObject, component.script.m_metadata);
|
|
226
|
+
return editor;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
editor = (AirshipEditor) ScriptableObject.CreateInstance(type);
|
|
230
|
+
editor.serializedObject ??= new AirshipSerializedObject();
|
|
231
|
+
editor.serializedObject.Update(editor, serializedObject, component.script.m_metadata);
|
|
232
|
+
instanceToAirshipEditor.Add(component.GetInstanceID(), editor);
|
|
233
|
+
return editor;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
internal static AirshipEditor GetComponentEditorForType(AirshipType airshipType, AirshipComponent component, AirshipSerializedObject serializedObject) {
|
|
238
|
+
if (!airshipType.AirshipBehaviour) return null;
|
|
239
|
+
var editorType = AirshipCustomEditors.GetEditorTypeForTypeName(airshipType.Name);
|
|
240
|
+
var editor = AirshipCustomEditors.GetEditorForComponent(component, editorType, serializedObject);
|
|
241
|
+
return editor;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/// <summary>
|
|
245
|
+
/// Get an AirshipEditor for the given serialized property - can be used to embed inline
|
|
246
|
+
/// </summary>
|
|
247
|
+
/// <param name="value"></param>
|
|
248
|
+
/// <returns></returns>
|
|
249
|
+
internal static AirshipEditor GetEditor(AirshipSerializedProperty value) {
|
|
250
|
+
if (!value.isAirshipType) return null;
|
|
251
|
+
|
|
252
|
+
var component = value.objectReferenceValue;
|
|
253
|
+
if (component == null) return null;
|
|
254
|
+
|
|
255
|
+
if (component is AirshipComponent airshipComponent) {
|
|
256
|
+
return GetEditor(airshipComponent);
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
// TODO: In future we'll support Serializable objects & ScriptableObjects through here too.
|
|
260
|
+
return null;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/// <summary>
|
|
264
|
+
/// Gets the editor's property decorator for the given luau property decorator
|
|
265
|
+
/// </summary>
|
|
266
|
+
/// <param name="decorator"></param>
|
|
267
|
+
/// <param name="propertyDecorator"></param>
|
|
268
|
+
/// <returns></returns>
|
|
269
|
+
internal static bool TryGetDecorator(LuauMetadataDecoratorElement decorator, out AirshipPropertyDecorator propertyDecorator) {
|
|
270
|
+
if (decoratorNameToEditorType.TryGetValue(decorator.name, out var decoratorType)) {
|
|
271
|
+
if (!typeToEditorPropertyDecorator.TryGetValue(decoratorType, out propertyDecorator)) {
|
|
272
|
+
propertyDecorator = (AirshipPropertyDecorator)ScriptableObject.CreateInstance(decoratorType);
|
|
273
|
+
typeToEditorPropertyDecorator.Add(decoratorType, propertyDecorator);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
return true;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
propertyDecorator = default;
|
|
280
|
+
return false;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/// <summary>
|
|
284
|
+
/// Get the editor for the given AirshipComponent
|
|
285
|
+
/// </summary>
|
|
286
|
+
/// <param name="component">The component to get the editor for</param>
|
|
287
|
+
/// <returns>The editor, if it exists otherwise null</returns>
|
|
288
|
+
public static AirshipEditor GetEditor(AirshipComponent component) {
|
|
289
|
+
if (component != null && component.script != null) {
|
|
290
|
+
var airshipType = component.GetAirshipType();
|
|
291
|
+
|
|
292
|
+
var serializedObject = new AirshipSerializedObject();
|
|
293
|
+
serializedObject.Update(null, new SerializedObject(component), component.metadata);
|
|
294
|
+
|
|
295
|
+
return GetComponentEditorForType(airshipType, component, serializedObject);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
return null;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
#endregion
|
|
302
|
+
|
|
303
|
+
private static void DestroyEditor(int editorId) {
|
|
304
|
+
if (instanceToAirshipEditor.TryGetValue(editorId, out var editor)) {
|
|
305
|
+
instanceToAirshipEditor.Remove(editorId);
|
|
306
|
+
Object.DestroyImmediate(editor);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/// <summary>
|
|
311
|
+
/// Destroy the editor for the given airship component
|
|
312
|
+
/// </summary>
|
|
313
|
+
/// <param name="component">The airship component</param>
|
|
314
|
+
internal static void DestroyEditor(AirshipComponent component) {
|
|
315
|
+
if (component.script != null && component.metadata != null && !component) {
|
|
316
|
+
DestroyEditor(component.GetInstanceID());
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|