gg.easy.airship 0.1.2195 → 0.1.2196
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/AirshipBuildInfo.png +0 -0
- package/Editor/AirshipBuildInfoEditor.cs +151 -0
- package/Editor/AirshipBuildInfoEditor.cs.meta +3 -0
- package/Editor/AirshipComponents/AirshipComponentHeaderHandler.cs +2 -0
- package/Editor/AirshipEditorInfo.png +0 -0
- package/Editor/AirshipEditors/AirshipCustomEditors.cs +74 -5
- package/Editor/AirshipEditors/AirshipCustomMenus.cs +47 -0
- package/Editor/AirshipEditors/AirshipCustomMenus.cs.meta +3 -0
- package/Editor/AirshipEditors/AirshipEditor.cs +27 -13
- package/Editor/AirshipEditors/AirshipSerializedObject.cs +13 -5
- package/Editor/AirshipEditors/CustomAirshipEditorAttribute.cs +6 -1
- package/Editor/AirshipEditors/DefaultAirshipComponentEditor.cs +35 -0
- package/Editor/AirshipEditors/Properties/AirshipEditorExtensions.cs +30 -2
- package/Editor/AirshipEditors/Properties/AirshipSerializedArray.cs +22 -18
- package/Editor/AirshipEditors/Properties/AirshipSerializedProperty.cs +19 -4
- package/Editor/AirshipEditors/Properties/AirshipSerializedValue.cs +24 -2
- package/Editor/AirshipScriptGUI.cs +217 -2
- package/Editor/AirshipScriptableObject.png +0 -0
- package/Editor/AirshipScriptableObject.png.meta +156 -0
- package/Editor/AirshipScriptableObjectEditor.cs +136 -0
- package/Editor/AirshipScriptableObjectEditor.cs.meta +3 -0
- package/Editor/AirshipScriptableObjects/AirshipScriptableObjectsHandler.cs +19 -0
- package/Editor/AirshipScriptableObjects/AirshipScriptableObjectsHandler.cs.meta +3 -0
- package/Editor/AirshipScriptableObjects.meta +3 -0
- package/Editor/AirshipSerializable.png +0 -0
- package/Editor/AirshipSerializable.png.meta +156 -0
- package/Editor/AirshipSerializedLuauObjectEditor.cs +29 -0
- package/Editor/AirshipSerializedLuauObjectEditor.cs.meta +3 -0
- package/Editor/Artifacts/AirshipReconciliationService.cs +74 -27
- package/Editor/AssetIcons.svg +74 -26
- package/Editor/EditorInternal/AirshipEditorInternals.cs +8 -0
- package/Editor/EditorInternal/AirshipObjectGUIInternal.cs +25 -8
- package/Editor/LuauImporter.cs +43 -9
- package/Editor/Settings/AirshipBetaSettingsProvider.cs +3 -4
- package/Editor/Templates/AirshipScriptableObject.asset.txt +0 -0
- package/Editor/Templates/AirshipScriptableObject.asset.txt.meta +7 -0
- package/Editor/TypescriptCompiler~/utsc.js +157 -157
- package/Editor/TypescriptImporter.cs +23 -2
- package/Editor/TypescriptServices/Compiler/TypescriptCompilationService.cs +4 -1
- package/Editor/TypescriptServices/Editor/AirshipScriptFileEditor.cs +30 -7
- package/Editor/TypescriptServices/Editor/TypescriptImporterEditor.cs +11 -11
- package/Editor/Util/AirshipEditorGUI.cs +103 -0
- package/Editor/Util/AirshipEditorGUI.internal.cs +138 -0
- package/Editor/Util/AirshipScriptSelectorWindow.cs +262 -0
- package/Editor/Util/AirshipScriptSelectorWindow.cs.meta +3 -0
- package/Editor/Util/AirshipScriptableObjectSelector.cs +69 -0
- package/Editor/Util/AirshipScriptableObjectSelector.cs.meta +3 -0
- package/Editor/Util/AirshipSelectorWindow.cs +332 -0
- package/Editor/Util/AirshipSelectorWindow.cs.meta +3 -0
- package/Runtime/Code/Bundles/SystemRoot.cs +2 -0
- package/Runtime/Code/Luau/AirshipComponent.cs +20 -28
- package/Runtime/Code/Luau/AirshipScript.cs +17 -0
- package/Runtime/Code/Luau/AirshipScriptableObject.cs +374 -0
- package/Runtime/Code/Luau/AirshipScriptableObject.cs.meta +11 -0
- package/Runtime/Code/Luau/AirshipScriptableObjectRoot.cs +82 -0
- package/Runtime/Code/Luau/AirshipScriptableObjectRoot.cs.meta +3 -0
- package/Runtime/Code/Luau/AirshipSerializableClassObject.cs +12 -0
- package/Runtime/Code/Luau/AirshipSerializableClassObject.cs.meta +11 -0
- package/Runtime/Code/Luau/IAirshipRuntimeReferenceDependency.cs +9 -0
- package/Runtime/Code/Luau/IAirshipRuntimeReferenceDependency.cs.meta +3 -0
- package/Runtime/Code/Luau/LuauAssembly/BinaryBlob.cs +1 -1
- package/Runtime/Code/Luau/LuauAssembly/PodType.cs +1 -0
- package/Runtime/Code/Luau/LuauCoreReflection.cs +21 -0
- package/Runtime/Code/Luau/LuauMetadata.cs +231 -24
- package/Runtime/Code/Luau/LuauMetadataPropertySerializer.cs +4 -0
- package/Runtime/Code/Luau/LuauPlugin.cs +32 -0
- package/Runtime/Code/Luau/LuauPluginNative.cs +50 -0
- package/Runtime/Code/Luau/LuauScript.cs +5 -4
- package/Runtime/Code/Luau/ScriptingEntryPoint.cs +3 -0
- package/Runtime/Code/Misc/AirshipBuildInfo.cs +93 -1
- package/Runtime/Code/Misc/AirshipType.cs +26 -4
- package/Runtime/Code/Transfer/TransferManager.cs +4 -2
- package/Runtime/Plugins/Android/libLuauPlugin.so +0 -0
- package/Runtime/Plugins/Linux/libLuauPlugin.so +0 -0
- package/Runtime/Plugins/Mac/LuauPlugin.bundle/Contents/MacOS/LuauPlugin +0 -0
- package/Runtime/Plugins/Windows/x64/LuauPlugin.dll +0 -0
- package/Runtime/Plugins/iOS/LuauPluginIos.a +0 -0
- package/package.json +1 -1
|
Binary file
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
#if UNITY_EDITOR
|
|
2
|
+
using System;
|
|
3
|
+
using System.Collections.Generic;
|
|
4
|
+
using System.Linq;
|
|
5
|
+
using Airship.Editor;
|
|
6
|
+
using Code.Luau;
|
|
7
|
+
using Editor.Packages;
|
|
8
|
+
using Luau;
|
|
9
|
+
using UnityEditor;
|
|
10
|
+
using UnityEngine;
|
|
11
|
+
|
|
12
|
+
[CustomEditor(typeof(AirshipBuildInfo))]
|
|
13
|
+
|
|
14
|
+
public class AirshipBuildInfoEditor : UnityEditor.Editor {
|
|
15
|
+
private Vector2 pos = default;
|
|
16
|
+
private string searchText = "";
|
|
17
|
+
|
|
18
|
+
private Dictionary<string, bool> typeToExpandState = new();
|
|
19
|
+
|
|
20
|
+
public void OnBehaviourMeta(AirshipBehaviourMeta airshipBehaviourMeta) {
|
|
21
|
+
var type = AirshipBuildInfo.Instance.GetTypeByPathAndName(airshipBehaviourMeta.assetPath, airshipBehaviourMeta.className);
|
|
22
|
+
if (type == null) return;
|
|
23
|
+
{
|
|
24
|
+
typeToExpandState.TryGetValue(type.UniqueId, out var toggleState);
|
|
25
|
+
|
|
26
|
+
var rect = EditorGUILayout.GetControlRect(false, EditorGUIUtility.singleLineHeight);
|
|
27
|
+
var nextToggleState = EditorGUI.BeginFoldoutHeaderGroup(rect, toggleState, new GUIContent(ObjectNames.NicifyVariableName(type.Name)));
|
|
28
|
+
|
|
29
|
+
EditorGUI.LabelField(new Rect(rect) { width = 200, x = rect.xMin + rect.width - 200 }, type.DeclarationType.ToString(),new GUIStyle(EditorStyles.label) {
|
|
30
|
+
alignment = TextAnchor.MiddleRight
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
if (nextToggleState) {
|
|
34
|
+
EditorGUILayout.BeginVertical(new GUIStyle() {
|
|
35
|
+
margin = new RectOffset(2, 2, 2, 2),
|
|
36
|
+
// padding = new RectOffset(5,5,5,5),
|
|
37
|
+
fixedWidth = 0,
|
|
38
|
+
});
|
|
39
|
+
{
|
|
40
|
+
GUI.enabled = false;
|
|
41
|
+
EditorGUILayout.EnumPopup("Declaration Type", type.DeclarationType);
|
|
42
|
+
EditorGUILayout.LabelField("Asset Path", type.AssetPath);
|
|
43
|
+
EditorGUILayout.LabelField("Runtime Path", type.RuntimePath.ToLower());
|
|
44
|
+
EditorGUILayout.ObjectField("Script", type.Script, typeof(AirshipScript));
|
|
45
|
+
|
|
46
|
+
if (airshipBehaviourMeta.extends.Count > 0) {
|
|
47
|
+
AirshipEditorGUI.Heading(new GUIContent("Inherits"));
|
|
48
|
+
foreach (var inheritance in airshipBehaviourMeta.extends) {
|
|
49
|
+
EditorGUILayout.LabelField(inheritance);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
GUI.enabled = true;
|
|
53
|
+
}
|
|
54
|
+
EditorGUILayout.EndVertical();
|
|
55
|
+
}
|
|
56
|
+
EditorGUILayout.EndFoldoutHeaderGroup();
|
|
57
|
+
if (nextToggleState != toggleState) {
|
|
58
|
+
if (!typeToExpandState.TryAdd(type.UniqueId, nextToggleState)) {
|
|
59
|
+
typeToExpandState[type.UniqueId] = nextToggleState;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
}
|
|
65
|
+
//
|
|
66
|
+
// public void OnType(AirshipType airshipType) {
|
|
67
|
+
// EditorGUILayout.BeginHorizontal();
|
|
68
|
+
// {
|
|
69
|
+
//
|
|
70
|
+
// EditorGUILayout.LabelField(ObjectNames.NicifyVariableName(airshipType.Name), airshipType.DeclarationType.ToString());
|
|
71
|
+
// }
|
|
72
|
+
// EditorGUILayout.EndHorizontal();
|
|
73
|
+
// }
|
|
74
|
+
|
|
75
|
+
private int packageId = 0;
|
|
76
|
+
public override void OnInspectorGUI() {
|
|
77
|
+
var buildInfo = (AirshipBuildInfo)target;
|
|
78
|
+
|
|
79
|
+
List<AirshipBehaviourMeta> gameMetas = new List<AirshipBehaviourMeta>();
|
|
80
|
+
List<AirshipBehaviourMeta> packageMetas = new List<AirshipBehaviourMeta>();
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
foreach (var info in buildInfo.data.airshipBehaviourMetas) {
|
|
85
|
+
if (searchText != "" && !info.className.StartsWith(searchText, StringComparison.OrdinalIgnoreCase)) continue;
|
|
86
|
+
|
|
87
|
+
if (info.assetPath.StartsWith("Assets/AirshipPackages/@Easy/Core")) {
|
|
88
|
+
packageMetas.Add(info);
|
|
89
|
+
} else {
|
|
90
|
+
gameMetas.Add(info);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
foreach (var info in buildInfo.data.airshipScriptableObjectMetas) {
|
|
95
|
+
if (searchText != "" && !info.className.StartsWith(searchText, StringComparison.OrdinalIgnoreCase)) continue;
|
|
96
|
+
|
|
97
|
+
if (info.assetPath.StartsWith("Assets/AirshipPackages/@Easy/Core")) {
|
|
98
|
+
packageMetas.Add(info);
|
|
99
|
+
} else {
|
|
100
|
+
gameMetas.Add(info);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
var prevEnabled = GUI.enabled;
|
|
105
|
+
GUI.enabled = true;
|
|
106
|
+
|
|
107
|
+
List<string> items = new List<string>();
|
|
108
|
+
items.Add("Game");
|
|
109
|
+
|
|
110
|
+
foreach (var package in GameConfig.Load().packages) {
|
|
111
|
+
items.Add(package.id);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
EditorGUILayout.BeginHorizontal();
|
|
115
|
+
searchText = EditorGUILayout.TextField(searchText, EditorStyles.toolbarSearchField);
|
|
116
|
+
EditorGUILayout.LabelField("Scope", GUILayout.Width(50));
|
|
117
|
+
packageId = EditorGUILayout.Popup(packageId, items.ToArray(), GUILayout.Width(150));
|
|
118
|
+
EditorGUILayout.EndHorizontal();
|
|
119
|
+
|
|
120
|
+
var selectedItem = items[packageId];
|
|
121
|
+
|
|
122
|
+
// pos = EditorGUILayout.BeginScrollView(pos);
|
|
123
|
+
// {
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
if (selectedItem.StartsWith("@")) {
|
|
127
|
+
if (packageMetas.Count > 0) {
|
|
128
|
+
foreach (var info in packageMetas) {
|
|
129
|
+
if (info.assetPath.StartsWith("Assets/AirshipPackages/" + selectedItem)) OnBehaviourMeta(info);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
} else {
|
|
133
|
+
if (gameMetas.Count > 0) {
|
|
134
|
+
foreach (var info in gameMetas) {
|
|
135
|
+
OnBehaviourMeta(info);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
// AirshipEditorGUI.Heading(new GUIContent("Airship Scriptable Objects"));
|
|
142
|
+
// foreach (var info in buildInfo.data.airshipScriptableObjectMetas) {
|
|
143
|
+
// OnBehaviourMeta(info);
|
|
144
|
+
// }
|
|
145
|
+
// }
|
|
146
|
+
// EditorGUILayout.EndScrollView();
|
|
147
|
+
|
|
148
|
+
GUI.enabled = prevEnabled;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
#endif
|
|
@@ -7,8 +7,10 @@ using UnityEngine.UIElements;
|
|
|
7
7
|
[InitializeOnLoad]
|
|
8
8
|
public class AirshipComponentHeaderHandler {
|
|
9
9
|
static AirshipComponentHeaderHandler() {
|
|
10
|
+
#if !AIRSHIP_PLAYER
|
|
10
11
|
UnityEditor.Editor.finishedDefaultHeaderGUI -= AfterInspectorRootEditorHeaderGUI;
|
|
11
12
|
UnityEditor.Editor.finishedDefaultHeaderGUI += AfterInspectorRootEditorHeaderGUI;
|
|
13
|
+
#endif
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
private static void AfterGameObjectHeaderGUI(UnityEditor.Editor gameObjectEditor) {
|
|
Binary file
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
using System.Collections.Generic;
|
|
3
3
|
using System.IO;
|
|
4
4
|
using System.Reflection;
|
|
5
|
+
using HandlebarsDotNet.PathStructure;
|
|
5
6
|
using TypescriptAst;
|
|
6
7
|
using Luau;
|
|
7
8
|
using UnityEditor;
|
|
@@ -34,7 +35,7 @@ public static class AirshipCustomEditors {
|
|
|
34
35
|
private static Dictionary<string, Type> decoratorNameToEditorType = new();
|
|
35
36
|
|
|
36
37
|
internal const string inspectorModeKey = "AirshipBetaInspectorMode";
|
|
37
|
-
internal const EditorInspectorMode DefaultInspectorMode = EditorInspectorMode.
|
|
38
|
+
internal const EditorInspectorMode DefaultInspectorMode = EditorInspectorMode.UseNewInspector;
|
|
38
39
|
#endregion
|
|
39
40
|
|
|
40
41
|
#region Properties
|
|
@@ -88,7 +89,7 @@ public static class AirshipCustomEditors {
|
|
|
88
89
|
|
|
89
90
|
private static bool RegisterEditor(Type editorType, CustomAirshipEditorAttribute editorAttribute) {
|
|
90
91
|
var typeName = editorAttribute.TypeName;
|
|
91
|
-
var filePath = editorAttribute.
|
|
92
|
+
var filePath = editorAttribute.AssetPath;
|
|
92
93
|
|
|
93
94
|
var pathType = string.IsNullOrEmpty(filePath) ?
|
|
94
95
|
AirshipBuildInfo.Instance.GetTypeByName(typeName) :
|
|
@@ -202,22 +203,37 @@ public static class AirshipCustomEditors {
|
|
|
202
203
|
return instances;
|
|
203
204
|
}
|
|
204
205
|
|
|
205
|
-
internal static Type GetEditorTypeForTypeName(string typeName) {
|
|
206
|
+
internal static Type GetEditorTypeForTypeName(string typeName, AirshipDeclarationType? airshipDeclarationType = null) {
|
|
206
207
|
if (!UseNewInspector) return null;
|
|
208
|
+
|
|
207
209
|
|
|
208
210
|
var pathType = AirshipBuildInfo.Instance.GetTypeByName(typeName);
|
|
209
211
|
if (pathType == null) return null;
|
|
212
|
+
|
|
213
|
+
airshipDeclarationType ??= pathType.DeclarationType;
|
|
210
214
|
|
|
211
215
|
if (airshipTypeToCustomEditor.TryGetValue(pathType, out var editorType)) {
|
|
212
216
|
return editorType.EditorType;
|
|
213
217
|
}
|
|
214
|
-
|
|
215
|
-
return
|
|
218
|
+
|
|
219
|
+
return airshipDeclarationType switch {
|
|
220
|
+
AirshipDeclarationType.Unknown => null,
|
|
221
|
+
AirshipDeclarationType.AirshipBehaviour => typeof(DefaultAirshipComponentEditor),
|
|
222
|
+
AirshipDeclarationType.Enum => null,
|
|
223
|
+
AirshipDeclarationType.AirshipScriptableObject => typeof(DefaultAirshipScriptableObjectEditor),
|
|
224
|
+
AirshipDeclarationType.SerializableClass => typeof(DefaultAirshipSerializableObjectEditor),
|
|
225
|
+
_ => null
|
|
226
|
+
};
|
|
216
227
|
}
|
|
217
228
|
|
|
218
229
|
internal static bool TryGetEditorForComponent(AirshipComponent component, Type type, out AirshipEditor editor) {
|
|
219
230
|
return instanceToAirshipEditor.TryGetValue(component.GetInstanceID(), out editor);
|
|
220
231
|
}
|
|
232
|
+
|
|
233
|
+
internal static bool TryGetEditorForScriptableObject(AirshipScriptableObject scriptableObject, Type type,
|
|
234
|
+
out AirshipEditor editor) {
|
|
235
|
+
return instanceToAirshipEditor.TryGetValue(scriptableObject.GetInstanceID(), out editor);
|
|
236
|
+
}
|
|
221
237
|
|
|
222
238
|
internal static AirshipEditor GetEditorForComponent(AirshipComponent component, Type type, SerializedObject serializedObject) {
|
|
223
239
|
if (instanceToAirshipEditor.TryGetValue(component.GetInstanceID(), out var editor)) {
|
|
@@ -232,8 +248,44 @@ public static class AirshipCustomEditors {
|
|
|
232
248
|
instanceToAirshipEditor.Add(component.GetInstanceID(), editor);
|
|
233
249
|
return editor;
|
|
234
250
|
}
|
|
251
|
+
|
|
252
|
+
#if AIRSHIPEX_CLASS_OBJECT
|
|
253
|
+
internal static AirshipEditor GetEditorForClass(AirshipSerializableClassObject component, Type type, SerializedObject serializedObject) {
|
|
254
|
+
if (instanceToAirshipEditor.TryGetValue(component.GetInstanceID(), out var editor)) {
|
|
255
|
+
editor.serializedObject ??= new AirshipSerializedObject();
|
|
256
|
+
editor.serializedObject.Update(editor, serializedObject, component.metadata);
|
|
257
|
+
return editor;
|
|
258
|
+
}
|
|
235
259
|
|
|
260
|
+
editor = (AirshipEditor) ScriptableObject.CreateInstance(type);
|
|
261
|
+
editor.serializedObject ??= new AirshipSerializedObject();
|
|
262
|
+
editor.serializedObject.Update(editor, serializedObject, component.metadata);
|
|
263
|
+
instanceToAirshipEditor.Add(component.GetInstanceID(), editor);
|
|
264
|
+
return editor;
|
|
265
|
+
}
|
|
266
|
+
#endif
|
|
267
|
+
|
|
268
|
+
internal static AirshipEditor GetEditorForScriptableObject(AirshipScriptableObject scriptableObject, Type type, SerializedObject serializedObject) {
|
|
269
|
+
if (instanceToAirshipEditor.TryGetValue(scriptableObject.GetInstanceID(), out var editor)) {
|
|
270
|
+
editor.serializedObject ??= new AirshipSerializedObject(scriptableObject);
|
|
271
|
+
editor.serializedObject.Update(editor, serializedObject, scriptableObject.script.m_metadata);
|
|
272
|
+
return editor;
|
|
273
|
+
}
|
|
236
274
|
|
|
275
|
+
editor = (AirshipEditor) ScriptableObject.CreateInstance(type);
|
|
276
|
+
editor.serializedObject ??= new AirshipSerializedObject();
|
|
277
|
+
editor.serializedObject.Update(editor, serializedObject, scriptableObject.script.m_metadata);
|
|
278
|
+
instanceToAirshipEditor.Add(scriptableObject.GetInstanceID(), editor);
|
|
279
|
+
return editor;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
internal static AirshipEditor GetScriptableObjectEditorForType(AirshipType airshipType, AirshipScriptableObject scriptableObject, AirshipSerializedObject serializedObject) {
|
|
283
|
+
if (airshipType.DeclarationType != AirshipDeclarationType.AirshipScriptableObject) return null;
|
|
284
|
+
var editorType = AirshipCustomEditors.GetEditorTypeForTypeName(airshipType.Name);
|
|
285
|
+
var editor = AirshipCustomEditors.GetEditorForScriptableObject(scriptableObject, editorType, serializedObject);
|
|
286
|
+
return editor;
|
|
287
|
+
}
|
|
288
|
+
|
|
237
289
|
internal static AirshipEditor GetComponentEditorForType(AirshipType airshipType, AirshipComponent component, AirshipSerializedObject serializedObject) {
|
|
238
290
|
if (airshipType.DeclarationType != AirshipDeclarationType.AirshipBehaviour) return null;
|
|
239
291
|
var editorType = AirshipCustomEditors.GetEditorTypeForTypeName(airshipType.Name);
|
|
@@ -298,6 +350,23 @@ public static class AirshipCustomEditors {
|
|
|
298
350
|
return null;
|
|
299
351
|
}
|
|
300
352
|
|
|
353
|
+
/// <summary>
|
|
354
|
+
/// Get the editor for the given AirshipScriptableObject
|
|
355
|
+
/// </summary>
|
|
356
|
+
/// <param name="scriptableObject">The scriptable object to get the editor for</param>
|
|
357
|
+
/// <returns>The editor, if it exists otherwise null</returns>
|
|
358
|
+
public static AirshipEditor GetEditor(AirshipScriptableObject scriptableObject) {
|
|
359
|
+
if (scriptableObject != null && scriptableObject.script != null) {
|
|
360
|
+
var airshipType = scriptableObject.GetAirshipType();
|
|
361
|
+
|
|
362
|
+
var serializedObject = new AirshipSerializedObject();
|
|
363
|
+
serializedObject.Update(null, new SerializedObject(scriptableObject), serializedObject.metadata);
|
|
364
|
+
return GetScriptableObjectEditorForType(airshipType, scriptableObject, serializedObject);
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
return null;
|
|
368
|
+
}
|
|
369
|
+
|
|
301
370
|
#endregion
|
|
302
371
|
|
|
303
372
|
private static void DestroyEditor(int editorId) {
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
using System.Collections.Generic;
|
|
2
|
+
using Editor.EditorInternal;
|
|
3
|
+
using Luau;
|
|
4
|
+
using UnityEditor;
|
|
5
|
+
|
|
6
|
+
[FilePath("Temp/AirshipCustomMenuState", FilePathAttribute.Location.ProjectFolder)]
|
|
7
|
+
internal class AirshipCustomMenus : ScriptableSingleton<AirshipCustomMenus> {
|
|
8
|
+
public Dictionary<string, string> assetPathToMenuItemPaths = new ();
|
|
9
|
+
|
|
10
|
+
internal void AddCreateAssetMenu(string scriptPath, string fileName, string menuItem, int priority = 0) {
|
|
11
|
+
if (AirshipEditorInternals.HasUnityMenuItem(menuItem)) return;
|
|
12
|
+
|
|
13
|
+
if (assetPathToMenuItemPaths.TryGetValue(scriptPath, out var existingMenuItem)) {
|
|
14
|
+
if (existingMenuItem != menuItem) {
|
|
15
|
+
AirshipEditorInternals.RemoveUnityMenuItem(existingMenuItem);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
AirshipEditorInternals.AddUnityMenuItem(menuItem, "", false, priority, () => {
|
|
20
|
+
var asset = AssetDatabase.LoadAssetAtPath<AirshipScript>(scriptPath);
|
|
21
|
+
AirshipScriptableObjectEditor.CreateAirshipScriptableObject(asset, fileName);
|
|
22
|
+
}, () => true);
|
|
23
|
+
assetPathToMenuItemPaths.TryAdd(scriptPath, menuItem);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
internal void RegisterMenus() {
|
|
27
|
+
List<string> assetPathsToRemove = new List<string>();
|
|
28
|
+
foreach (var assetPathToMenuItemPath in assetPathToMenuItemPaths) {
|
|
29
|
+
var asset = AssetDatabase.LoadAssetAtPath<AirshipScript>(assetPathToMenuItemPath.Key);
|
|
30
|
+
if (asset == null) {
|
|
31
|
+
assetPathsToRemove.Add(assetPathToMenuItemPath.Key);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
foreach (var assetPath in assetPathsToRemove) {
|
|
36
|
+
if (assetPathToMenuItemPaths.TryGetValue(assetPath, out var existingMenuItem)) {
|
|
37
|
+
AirshipEditorInternals.RemoveUnityMenuItem(existingMenuItem);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
assetPathToMenuItemPaths.Remove(assetPath);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
internal void Save() {
|
|
45
|
+
Save(false);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -37,6 +37,7 @@ public abstract class AirshipEditor : ScriptableObject {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
public AirshipSerializedObject serializedObject { get; internal set; }
|
|
40
|
+
internal SerializedObject unitySerializedObject => serializedObject.serializedObject;
|
|
40
41
|
public UnityEngine.Object target { get; internal set; }
|
|
41
42
|
public AirshipScript script { get; internal set; }
|
|
42
43
|
|
|
@@ -121,7 +122,7 @@ public abstract class AirshipEditor : ScriptableObject {
|
|
|
121
122
|
/// <summary>
|
|
122
123
|
/// Draw the default properties for this inspector
|
|
123
124
|
/// </summary>
|
|
124
|
-
|
|
125
|
+
protected void DrawDefaultProperties() {
|
|
125
126
|
// Draw each property
|
|
126
127
|
foreach (var property in serializedObject.GetProperties()) {
|
|
127
128
|
var shouldHideProperty = false;
|
|
@@ -141,7 +142,16 @@ public abstract class AirshipEditor : ScriptableObject {
|
|
|
141
142
|
}
|
|
142
143
|
|
|
143
144
|
if (shouldHideProperty) continue;
|
|
145
|
+
|
|
144
146
|
AirshipEditorGUI.PropertyField(property);
|
|
147
|
+
|
|
148
|
+
#if AIRSHIP_DEBUG
|
|
149
|
+
var propertyMetadata = property.scriptPropertyMetadata;
|
|
150
|
+
if (propertyMetadata.defaultValue != null) {
|
|
151
|
+
EditorGUILayout.LabelField(LuauMetadataPropertySerializer.SerializeAirshipProperty(propertyMetadata.defaultValue, propertyMetadata.ComponentType));
|
|
152
|
+
}
|
|
153
|
+
AirshipEditorGUI.HorizontalLine();
|
|
154
|
+
#endif
|
|
145
155
|
}
|
|
146
156
|
}
|
|
147
157
|
|
|
@@ -159,20 +169,24 @@ public abstract class AirshipEditor : ScriptableObject {
|
|
|
159
169
|
#if AIRSHIP_INTERNAL
|
|
160
170
|
private void DrawInternalDebug() {
|
|
161
171
|
if (Application.isPlaying) {
|
|
162
|
-
|
|
163
|
-
|
|
172
|
+
if (target is AirshipComponent component) {
|
|
173
|
+
AirshipEditorGUI.HorizontalLine();
|
|
174
|
+
EditorGUILayout.BeginHorizontal();
|
|
175
|
+
{
|
|
176
|
+
EditorGUILayout.LabelField("GameObject Id", AirshipBehaviourRootV2.GetId(component.gameObject).ToString());
|
|
177
|
+
EditorGUILayout.LabelField("Component Id", component.GetAirshipComponentId().ToString());
|
|
178
|
+
}
|
|
179
|
+
EditorGUILayout.EndHorizontal();
|
|
164
180
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
181
|
+
EditorGUILayout.BeginHorizontal();
|
|
182
|
+
EditorGUILayout.LabelField("Context", component.context.ToString());
|
|
183
|
+
EditorGUILayout.EndHorizontal();
|
|
184
|
+
} else if (target is AirshipScriptableObject scriptableObject) {
|
|
185
|
+
if (AirshipScriptableObjectRoot.ContainsScriptableObject(scriptableObject)) {
|
|
186
|
+
AirshipEditorGUI.HorizontalLine();
|
|
187
|
+
EditorGUILayout.LabelField("Scriptable Id", AirshipScriptableObjectRoot.GetIdFromScriptableObject(scriptableObject).ToString());
|
|
188
|
+
}
|
|
170
189
|
}
|
|
171
|
-
EditorGUILayout.EndHorizontal();
|
|
172
|
-
|
|
173
|
-
EditorGUILayout.BeginHorizontal();
|
|
174
|
-
EditorGUILayout.LabelField("Context", binding.context.ToString());
|
|
175
|
-
EditorGUILayout.EndHorizontal();
|
|
176
190
|
}
|
|
177
191
|
}
|
|
178
192
|
#endif
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
using System
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using System.Linq;
|
|
2
4
|
using JetBrains.Annotations;
|
|
3
5
|
using Luau;
|
|
4
6
|
using UnityEditor;
|
|
@@ -31,15 +33,23 @@ public class AirshipSerializedObject {
|
|
|
31
33
|
internal SerializedProperty serializedProperties => serializedMetadata.FindPropertyRelative("properties");
|
|
32
34
|
internal SerializedProperty serializedName => serializedObject.FindProperty("name");
|
|
33
35
|
internal LuauMetadata metadata { get; private set; }
|
|
34
|
-
internal AirshipEditor editor { get;
|
|
36
|
+
internal AirshipEditor editor { get; set; }
|
|
35
37
|
|
|
36
38
|
public AirshipType airshipType => AirshipBuildInfo.Instance.GetTypeByName(serializedName.stringValue);
|
|
39
|
+
[Obsolete]
|
|
37
40
|
public AirshipComponent airshipComponent => (AirshipComponent)serializedObject.targetObject;
|
|
38
41
|
public UnityEngine.Object targetObject => serializedObject.targetObject;
|
|
39
42
|
|
|
40
43
|
internal AirshipSerializedObject() {}
|
|
41
44
|
public AirshipSerializedObject(AirshipComponent component) => Update(null, new SerializedObject(component), component.metadata);
|
|
42
|
-
|
|
45
|
+
public AirshipSerializedObject(AirshipScriptableObject scriptableObject) =>
|
|
46
|
+
Update(null, new SerializedObject(scriptableObject), scriptableObject.metadata);
|
|
47
|
+
|
|
48
|
+
#if AIRSHIPEX_CLASS_OBJECT
|
|
49
|
+
public AirshipSerializedObject(AirshipSerializableClassObject luauObject) =>
|
|
50
|
+
Update(null, new SerializedObject(luauObject), luauObject.metadata);
|
|
51
|
+
#endif
|
|
52
|
+
|
|
43
53
|
[CanBeNull]
|
|
44
54
|
internal AirshipSerializedObject prefabAsset {
|
|
45
55
|
get {
|
|
@@ -79,9 +89,7 @@ public class AirshipSerializedObject {
|
|
|
79
89
|
var propertyName = property.FindPropertyRelative("name").stringValue;
|
|
80
90
|
if (propertyName == targetPropertyName) {
|
|
81
91
|
var propertyMetadata = metadata.FindProperty(targetPropertyName);
|
|
82
|
-
|
|
83
92
|
var airshipProperty = new AirshipSerializedProperty(this, property, propertyMetadata, this.editor);
|
|
84
|
-
// _propertyCache.Add(targetPropertyName, airshipProperty);
|
|
85
93
|
return airshipProperty;
|
|
86
94
|
}
|
|
87
95
|
}
|
|
@@ -8,12 +8,17 @@ using NUnit.Framework.Internal;
|
|
|
8
8
|
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
|
|
9
9
|
public class CustomAirshipEditorAttribute : Attribute {
|
|
10
10
|
public string TypeName { get; }
|
|
11
|
-
public string
|
|
11
|
+
public string AssetPath { get; set; }
|
|
12
12
|
public int Priority { get; set; } = 0;
|
|
13
13
|
|
|
14
14
|
public CustomAirshipEditorAttribute(string className) {
|
|
15
15
|
TypeName = className;
|
|
16
16
|
}
|
|
17
|
+
|
|
18
|
+
public CustomAirshipEditorAttribute(string className, string assetPath) {
|
|
19
|
+
TypeName = className;
|
|
20
|
+
AssetPath = assetPath;
|
|
21
|
+
}
|
|
17
22
|
}
|
|
18
23
|
|
|
19
24
|
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
|
|
@@ -12,4 +12,39 @@ public class DefaultAirshipComponentEditor : AirshipEditor {
|
|
|
12
12
|
// By default we just draw the default inspector here.
|
|
13
13
|
DrawDefaultInspector();
|
|
14
14
|
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/// <summary>
|
|
18
|
+
/// The default editor for airship components
|
|
19
|
+
/// </summary>
|
|
20
|
+
public class DefaultAirshipScriptableObjectEditor : AirshipEditor {
|
|
21
|
+
private void OnScriptSelectionChanged(AirshipScript targetScript) {
|
|
22
|
+
unitySerializedObject.FindProperty("script").objectReferenceValue = targetScript;
|
|
23
|
+
unitySerializedObject.ApplyModifiedProperties();
|
|
24
|
+
unitySerializedObject.Update();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
public override void OnInspectorGUI() {
|
|
28
|
+
EditorGUILayout.Space(5);
|
|
29
|
+
|
|
30
|
+
if (script != null) {
|
|
31
|
+
GUI.enabled = script == null;
|
|
32
|
+
EditorGUILayout.ObjectField(new GUIContent("Script"), script, typeof(AirshipScript), false);
|
|
33
|
+
GUI.enabled = true;
|
|
34
|
+
} else {
|
|
35
|
+
var rect = EditorGUILayout.GetControlRect(false, EditorGUIUtility.singleLineHeight);
|
|
36
|
+
AirshipEditorGUI.AirshipScriptField(rect, new GUIContent("Script"), script, OnScriptSelectionChanged, AirshipEditorGUI.ScriptExportType.ScriptableObject);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
EditorGUILayout.Space(5);
|
|
40
|
+
|
|
41
|
+
DrawDefaultProperties();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public class DefaultAirshipSerializableObjectEditor : AirshipEditor {
|
|
46
|
+
public override void OnInspectorGUI() {
|
|
47
|
+
EditorGUILayout.HelpBox("Serializable Class Objects are not yet supported at Runtime", MessageType.Error);
|
|
48
|
+
DrawDefaultProperties();
|
|
49
|
+
}
|
|
15
50
|
}
|
|
@@ -16,7 +16,7 @@ public static class AirshipEditorExtensions {
|
|
|
16
16
|
public static T GetObject<T>(this AirshipSerializedValue value) where T : UnityEngine.Object {
|
|
17
17
|
return (T) GetObject(value);
|
|
18
18
|
}
|
|
19
|
-
|
|
19
|
+
|
|
20
20
|
/// <summary>
|
|
21
21
|
/// Grab the type of the given AirshipComponent
|
|
22
22
|
/// </summary>
|
|
@@ -28,6 +28,34 @@ public static class AirshipEditorExtensions {
|
|
|
28
28
|
return AirshipBuildInfo.Instance.GetTypeByName(component.script.m_metadata.name);
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
#if AIRSHIPEX_CLASS_OBJECT
|
|
32
|
+
public static AirshipType GetAirshipType(this AirshipSerializableClassObject luauObject) {
|
|
33
|
+
if (luauObject.metadata == null) return null;
|
|
34
|
+
return AirshipBuildInfo.Instance.GetTypeByName(luauObject.metadata.name);
|
|
35
|
+
}
|
|
36
|
+
#endif
|
|
37
|
+
|
|
38
|
+
public static LuauMetadata GetMetadataForType(this AirshipType type) {
|
|
39
|
+
var script = type.Script;
|
|
40
|
+
if (script == null) return null;
|
|
41
|
+
if (script.m_metadata != null && script.m_metadata.name == type.Name) return script.m_metadata;
|
|
42
|
+
if (script.m_serializables != null) {
|
|
43
|
+
foreach (var serializable in script.m_serializables) {
|
|
44
|
+
if (serializable.name == type.Name) {
|
|
45
|
+
return serializable;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
public static AirshipType GetAirshipType(this AirshipScriptableObject scriptableObject) {
|
|
54
|
+
if (scriptableObject.script == null) return null;
|
|
55
|
+
if (scriptableObject.script.m_metadata == null) return null;
|
|
56
|
+
return AirshipBuildInfo.Instance.GetTypeByName(scriptableObject.script.m_metadata.name);
|
|
57
|
+
}
|
|
58
|
+
|
|
31
59
|
private static IEnumerable<string> GetPathParts(Transform transform) {
|
|
32
60
|
var parent = transform;
|
|
33
61
|
while (parent != null) {
|
|
@@ -56,7 +84,7 @@ public static class AirshipEditorExtensions {
|
|
|
56
84
|
public static AirshipType GetComponentType(this AirshipScript script) {
|
|
57
85
|
// TODO: Get types by path
|
|
58
86
|
if (script.m_metadata != null) {
|
|
59
|
-
return AirshipBuildInfo.Instance.GetTypeByPathAndName(script.assetPath, script.m_metadata.name);
|
|
87
|
+
return AirshipBuildInfo.Instance.GetTypeByPathAndName(script.assetPath, script.m_metadata.name) ?? AirshipBuildInfo.Instance.GetTypeByName(script.m_metadata.name);
|
|
60
88
|
}
|
|
61
89
|
|
|
62
90
|
return null;
|
|
@@ -6,19 +6,19 @@ using UnityEditor;
|
|
|
6
6
|
using Object = UnityEngine.Object;
|
|
7
7
|
|
|
8
8
|
public class AirshipSerializedArray {
|
|
9
|
+
private readonly SerializedProperty serializedItems;
|
|
10
|
+
private readonly SerializedProperty serializedObjects;
|
|
9
11
|
public AirshipSerializedProperty property { get; }
|
|
10
12
|
public AirshipSerializedType elementType =>
|
|
11
13
|
AirshipSerializedValue.GetTypeFromTypeString(property.serializedItems.FindPropertyRelative("type").stringValue);
|
|
12
|
-
|
|
14
|
+
public bool isObjectArray => elementType is AirshipSerializedType.Object or AirshipSerializedType.AirshipBehaviour
|
|
15
|
+
or AirshipSerializedType.AirshipScriptableObject;
|
|
13
16
|
public string elementObjectTypeString => property.serializedItems.FindPropertyRelative("objectType").stringValue;
|
|
14
17
|
|
|
15
18
|
[CanBeNull]
|
|
16
19
|
public Type elementObjectType => TypeReflection.GetTypeFromString(property.serializedItems.FindPropertyRelative("objectType").stringValue);
|
|
17
20
|
[CanBeNull]
|
|
18
21
|
public AirshipType elementAirshipType => AirshipBuildInfo.Instance.GetTypeByName(property.serializedItems.FindPropertyRelative("objectType").stringValue);
|
|
19
|
-
|
|
20
|
-
private readonly SerializedProperty serializedItems;
|
|
21
|
-
private readonly SerializedProperty serializedObjects;
|
|
22
22
|
|
|
23
23
|
public bool prefabOverride => serializedItems.prefabOverride || serializedObjects.prefabOverride;
|
|
24
24
|
|
|
@@ -70,9 +70,7 @@ public class AirshipSerializedArray {
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
public int size {
|
|
73
|
-
get
|
|
74
|
-
return this.serializedItems.arraySize;
|
|
75
|
-
}
|
|
73
|
+
get => isObjectArray ? this.serializedObjects.arraySize : this.serializedItems.arraySize;
|
|
76
74
|
}
|
|
77
75
|
|
|
78
76
|
public AirshipSerializedArrayValue PushElement() {
|
|
@@ -83,17 +81,23 @@ public class AirshipSerializedArray {
|
|
|
83
81
|
}
|
|
84
82
|
|
|
85
83
|
public AirshipSerializedArrayValue InsertLastElement(Object obj) {
|
|
86
|
-
if (
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
84
|
+
if (!isObjectArray) throw new ArgumentException("Cannot insert object into non-object array", nameof(obj));
|
|
85
|
+
var element = PushElement();
|
|
86
|
+
if (obj == null) return element;
|
|
87
|
+
|
|
88
|
+
var (isExpectedType, expectedTypeName) = elementType switch {
|
|
89
|
+
AirshipSerializedType.Object => (obj.GetType() == elementObjectType, obj.GetType().Name),
|
|
90
|
+
AirshipSerializedType.AirshipBehaviour => (obj is AirshipComponent ac && ac.GetAirshipType() == elementAirshipType, elementAirshipType!.Name),
|
|
91
|
+
AirshipSerializedType.AirshipScriptableObject => (obj is AirshipScriptableObject aso && aso.GetAirshipType() == elementAirshipType, elementAirshipType!.Name),
|
|
92
|
+
_ => (false, elementType.ToString()),
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
if (!isExpectedType) {
|
|
96
|
+
throw new ArgumentException($"Inserted value is not a {expectedTypeName}");
|
|
94
97
|
}
|
|
95
|
-
|
|
96
|
-
|
|
98
|
+
|
|
99
|
+
element.objectReferenceValue = obj;
|
|
100
|
+
return element;
|
|
97
101
|
}
|
|
98
102
|
|
|
99
103
|
public AirshipSerializedArrayValue GetElementAtIndex(int index) {
|
|
@@ -134,7 +138,7 @@ public class AirshipSerializedArray {
|
|
|
134
138
|
}
|
|
135
139
|
|
|
136
140
|
public static implicit operator SerializedProperty(AirshipSerializedArray array) {
|
|
137
|
-
if (array.
|
|
141
|
+
if (array.isObjectArray) {
|
|
138
142
|
return array.serializedObjects;
|
|
139
143
|
} else {
|
|
140
144
|
return array.serializedItems;
|