gg.easy.airship 0.1.2103 → 0.1.2104
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/AirAsset/AirAssetBundleEditor.cs +225 -0
- package/Editor/AirAsset/AirAssetBundleEditor.cs.meta +3 -0
- package/Editor/AirAsset.meta +3 -0
- package/Resources/Fonts/Roboto/Roboto-Regular SDF.asset +779 -17
- package/Runtime/Code/Accessories/Clothing/PlatformGear.cs +1 -1
- package/Runtime/Code/AirAssetBundle/AirAssetBundle.cs +91 -0
- package/Runtime/Code/AirAssetBundle/AirAssetBundle.cs.meta +3 -0
- package/Runtime/Code/AirAssetBundle.meta +3 -0
- package/Runtime/Code/LuauAPI/MinMaxGradientAPI.cs +9 -0
- package/Runtime/Code/LuauAPI/MinMaxGradientAPI.cs.meta +3 -0
- package/Runtime/Code/Player/Accessories/AccessoryBuilder.cs +1 -1
- package/Runtime/Code/VoxelWorld/ChunkSerializer.cs +1 -0
- package/Runtime/Code/VoxelWorld/VoxelWorld.cs +10 -0
- package/Runtime/Code/VoxelWorld/VoxelWorldChunk.cs +103 -5
- package/Runtime/Code/VoxelWorld/WorldSaveFile.cs +2 -0
- package/URP/AirshipURPAssetBaked.asset +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
using System.Collections.Generic;
|
|
2
|
+
using System.Diagnostics;
|
|
3
|
+
using System.IO;
|
|
4
|
+
using System.Linq;
|
|
5
|
+
using System.Threading.Tasks;
|
|
6
|
+
using Code.Accessories.Clothing;
|
|
7
|
+
using Code.AirAsset;
|
|
8
|
+
using Code.Bootstrap;
|
|
9
|
+
using Code.Http.Internal;
|
|
10
|
+
using Code.Platform.Shared;
|
|
11
|
+
using Editor.Accessories.Clothing;
|
|
12
|
+
using Editor.Packages;
|
|
13
|
+
using UnityEditor;
|
|
14
|
+
using UnityEditor.Build.Pipeline;
|
|
15
|
+
using UnityEngine;
|
|
16
|
+
using UnityEngine.Networking;
|
|
17
|
+
using Debug = UnityEngine.Debug;
|
|
18
|
+
|
|
19
|
+
namespace Editor.AirAsset {
|
|
20
|
+
[CustomEditor(typeof(AirAssetBundle))]
|
|
21
|
+
[CanEditMultipleObjects]
|
|
22
|
+
public class AirAssetBundleEditor : UnityEditor.Editor {
|
|
23
|
+
private static string easyOrgId = "6b62d6e3-9d74-449c-aeac-b4feed2012b1";
|
|
24
|
+
private bool skipBuild = false;
|
|
25
|
+
|
|
26
|
+
private void OnEnable() {
|
|
27
|
+
skipBuild = false;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public override void OnInspectorGUI() {
|
|
31
|
+
base.DrawDefaultInspector();
|
|
32
|
+
|
|
33
|
+
GUILayout.Space(20);
|
|
34
|
+
AirshipEditorGUI.HorizontalLine();
|
|
35
|
+
GUILayout.Space(20);
|
|
36
|
+
|
|
37
|
+
if (GUILayout.Button("Publish")) {
|
|
38
|
+
this.BuildAllPlatforms();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
GUILayout.Space(10);
|
|
42
|
+
this.skipBuild = EditorGUILayout.Toggle("Skip Build", this.skipBuild);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
private async void BuildAllPlatforms() {
|
|
46
|
+
var st = Stopwatch.StartNew();
|
|
47
|
+
bool success = true;
|
|
48
|
+
|
|
49
|
+
List<AirshipPlatform> platforms = new();
|
|
50
|
+
platforms.AddRange(AirshipPlatformUtil.livePlatforms);
|
|
51
|
+
// platforms.Add(AirshipPlatform.Mac); // debug
|
|
52
|
+
|
|
53
|
+
// ********************************* //
|
|
54
|
+
var airAssetBundle = (AirAssetBundle)this.target;
|
|
55
|
+
|
|
56
|
+
if (!CreateAssetBundles.PrePublishChecks()) return;
|
|
57
|
+
|
|
58
|
+
string airId = airAssetBundle.airId;
|
|
59
|
+
|
|
60
|
+
var contentName = airAssetBundle.name;
|
|
61
|
+
var contentDescription = "Air Asset Bundle";
|
|
62
|
+
|
|
63
|
+
if (string.IsNullOrEmpty(airId)) {
|
|
64
|
+
// Create new air asset
|
|
65
|
+
var req = UnityWebRequest.PostWwwForm(
|
|
66
|
+
AirshipPlatformUrl.deploymentService + $"/air-assets/owner-type/ORGANIZATION/owner-id/{easyOrgId}",
|
|
67
|
+
JsonUtility.ToJson(new AirAssetCreateRequest() {
|
|
68
|
+
contentType = "application/airasset",
|
|
69
|
+
contentLength = 1,
|
|
70
|
+
name = contentName,
|
|
71
|
+
description = contentDescription,
|
|
72
|
+
platforms = platforms.Select((p) => AirshipPlatformUtil.GetStringName(p)).ToArray(),
|
|
73
|
+
}));
|
|
74
|
+
req.SetRequestHeader("Authorization", "Bearer " + InternalHttpManager.editorAuthToken);
|
|
75
|
+
await req.SendWebRequest();
|
|
76
|
+
Debug.Log("create response: " + req.downloadHandler.text);
|
|
77
|
+
var data = JsonUtility.FromJson<AirAssetCreateResponse>(req.downloadHandler.text);
|
|
78
|
+
airAssetBundle.airId = data.airAssetId;
|
|
79
|
+
EditorUtility.SetDirty(this.target);
|
|
80
|
+
this.SaveChanges();
|
|
81
|
+
airId = data.airAssetId;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
List<string> bundlePaths = new();
|
|
85
|
+
foreach (var platform in platforms) {
|
|
86
|
+
var path = await this.BuildPlatform(platform, airId);
|
|
87
|
+
if (string.IsNullOrEmpty(path)) {
|
|
88
|
+
success = false;
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
bundlePaths.Add(path);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (!success) return;
|
|
96
|
+
|
|
97
|
+
// ******************** //
|
|
98
|
+
|
|
99
|
+
int bytesCount = 0;
|
|
100
|
+
for (int i = 0; i < platforms.Count; i++) {
|
|
101
|
+
var platform = platforms[i];
|
|
102
|
+
var buildOutputFile = bundlePaths[i];
|
|
103
|
+
|
|
104
|
+
// Update air asset
|
|
105
|
+
var bytes = await File.ReadAllBytesAsync(buildOutputFile);
|
|
106
|
+
Debug.Log("bytes length: " + bytes.Length + ", path: " + buildOutputFile);
|
|
107
|
+
bytesCount = bytes.Length;
|
|
108
|
+
var updateReq = UnityWebRequest.Put(AirshipPlatformUrl.deploymentService + $"/air-assets/{airId}",
|
|
109
|
+
JsonUtility.ToJson(new AirAssetCreateRequest() {
|
|
110
|
+
contentType = "application/airasset",
|
|
111
|
+
contentLength = bytes.Length,
|
|
112
|
+
name = contentName,
|
|
113
|
+
description = contentDescription,
|
|
114
|
+
platforms = platforms.Select((p) => AirshipPlatformUtil.GetStringName(p)).ToArray(),
|
|
115
|
+
}));
|
|
116
|
+
updateReq.SetRequestHeader("Content-Type", "application/json");
|
|
117
|
+
updateReq.SetRequestHeader("Authorization", "Bearer " + InternalHttpManager.editorAuthToken);
|
|
118
|
+
updateReq.SetRequestHeader("x-airship-ignore-rate-limit", "true");
|
|
119
|
+
await updateReq.SendWebRequest();
|
|
120
|
+
if (updateReq.result != UnityWebRequest.Result.Success) {
|
|
121
|
+
Debug.LogError("Failed to update air asset: " + updateReq.downloadHandler.text);
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
var updateData = JsonUtility.FromJson<AirAssetCreateResponse>(updateReq.downloadHandler.text);
|
|
125
|
+
var uploadUrl = updateData.urls.UrlFromPlatform(platform);
|
|
126
|
+
|
|
127
|
+
// Upload asset bundle
|
|
128
|
+
{
|
|
129
|
+
UnityWebRequest putReq = UnityWebRequest.Put(uploadUrl, bytes);
|
|
130
|
+
foreach (var pair in updateData.headers) {
|
|
131
|
+
putReq.SetRequestHeader(pair.key, pair.value);
|
|
132
|
+
}
|
|
133
|
+
putReq.SetRequestHeader("x-airship-ignore-rate-limit", "true");
|
|
134
|
+
|
|
135
|
+
Debug.Log("Uploading asset bundle...");
|
|
136
|
+
await putReq.SendWebRequest();
|
|
137
|
+
if (putReq.result != UnityWebRequest.Result.Success) {
|
|
138
|
+
Debug.LogError(putReq.error);
|
|
139
|
+
Debug.LogError(putReq.downloadHandler.text);
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
Debug.Log($"<color=green>Finished building {bundlePaths.Count} asset bundles for all platforms in {st.Elapsed.Seconds} seconds.</color> File size: " + AirshipEditorUtil.GetFileSizeText(bytesCount));
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/// <summary>
|
|
149
|
+
///
|
|
150
|
+
/// </summary>
|
|
151
|
+
/// <param name="platform"></param>
|
|
152
|
+
/// <returns>Path to built bundle. Empty string if it failed.</returns>
|
|
153
|
+
private async Task<string> BuildPlatform(AirshipPlatform platform, string airId) {
|
|
154
|
+
var st = Stopwatch.StartNew();
|
|
155
|
+
var airAssetBundle = (AirAssetBundle)this.target;
|
|
156
|
+
|
|
157
|
+
var buildOutputFolder = "bundles/airassetbundle/";
|
|
158
|
+
var buildOutputFile = $"bundles/airassetbundle/{airId}_{AirshipPlatformUtil.GetStringName(platform)}.bundle";
|
|
159
|
+
var sourceFolderPath = Path.GetRelativePath(".", Directory.GetParent(AssetDatabase.GetAssetPath(airAssetBundle))!.FullName);
|
|
160
|
+
|
|
161
|
+
List<AssetBundleBuild> builds = CreateAssetBundles.GetPackageAssetBundleBuilds();
|
|
162
|
+
|
|
163
|
+
var assetGuids = AssetDatabase.FindAssets("*", new string[] {sourceFolderPath}).ToList();
|
|
164
|
+
var assetPaths = assetGuids
|
|
165
|
+
.Select((guid) => AssetDatabase.GUIDToAssetPath(guid))
|
|
166
|
+
.Where((path) => !path.ToLower().Contains("editor/"))
|
|
167
|
+
.Where((path) => !path.ToLower().Contains("exclude/"))
|
|
168
|
+
.Where((p) => !AssetDatabase.IsValidFolder(p))
|
|
169
|
+
.ToArray();
|
|
170
|
+
Debug.Log("Resources:");
|
|
171
|
+
foreach (var path in assetPaths) {
|
|
172
|
+
Debug.Log(" - " + path);
|
|
173
|
+
}
|
|
174
|
+
var addressableNames = assetPaths
|
|
175
|
+
.Select((p) => p.ToLower())
|
|
176
|
+
.Select((p) => {
|
|
177
|
+
if (p.Contains(target.name + ".asset")) {
|
|
178
|
+
// custom name so it's easier to find when loading
|
|
179
|
+
return "_AirAssetBundle";
|
|
180
|
+
}
|
|
181
|
+
return p;
|
|
182
|
+
})
|
|
183
|
+
.ToArray();
|
|
184
|
+
builds.Add(new AssetBundleBuild() {
|
|
185
|
+
assetBundleName = airId + $"_{AirshipPlatformUtil.GetStringName(platform)}.bundle",
|
|
186
|
+
assetNames = assetPaths,
|
|
187
|
+
addressableNames = addressableNames
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
// --------------------- //
|
|
191
|
+
// Build
|
|
192
|
+
if (!this.skipBuild) {
|
|
193
|
+
var buildTarget = AirshipPlatformUtil.ToBuildTarget(platform);
|
|
194
|
+
var buildTargetGroup = BuildPipeline.GetBuildTargetGroup(buildTarget);
|
|
195
|
+
if (platform is AirshipPlatform.Windows or AirshipPlatform.Mac or AirshipPlatform.Linux) {
|
|
196
|
+
buildTargetGroup = BuildTargetGroup.Standalone;
|
|
197
|
+
}
|
|
198
|
+
EditorUserBuildSettings.SwitchActiveBuildTarget(buildTargetGroup, buildTarget);
|
|
199
|
+
var buildParams = new BundleBuildParameters(
|
|
200
|
+
buildTarget,
|
|
201
|
+
buildTargetGroup,
|
|
202
|
+
buildOutputFolder
|
|
203
|
+
);
|
|
204
|
+
buildParams.UseCache = true;
|
|
205
|
+
EditorUserBuildSettings.switchRomCompressionType = SwitchRomCompressionType.Lz4;
|
|
206
|
+
buildParams.BundleCompression = BuildCompression.LZ4;
|
|
207
|
+
var buildContent = new BundleBuildContent(builds);
|
|
208
|
+
|
|
209
|
+
AirshipPackagesWindow.buildingPackageId = "game";
|
|
210
|
+
CreateAssetBundles.buildingBundles = true;
|
|
211
|
+
AirshipScriptableBuildPipelineConfig.buildingGameBundles = true;
|
|
212
|
+
ReturnCode returnCode = ContentPipeline.BuildAssetBundles(buildParams, buildContent, out var result);
|
|
213
|
+
CreateAssetBundles.buildingBundles = false;
|
|
214
|
+
AirshipScriptableBuildPipelineConfig.buildingGameBundles = false;
|
|
215
|
+
if (returnCode != ReturnCode.Success) {
|
|
216
|
+
Debug.LogError("Failed to build asset bundles. ReturnCode=" + returnCode);
|
|
217
|
+
return null;
|
|
218
|
+
}
|
|
219
|
+
Debug.Log($"Finished building {platform} in {st.Elapsed.TotalSeconds} seconds.");
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
return buildOutputFile;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|