@nice2dev/game-engine 1.3.14 → 1.3.16
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/CHANGELOG.md +13 -0
- package/dist/cjs/accessibility/Accessibility.js +152 -165
- package/dist/cjs/ai/AI.js +292 -294
- package/dist/cjs/ai/BehaviorTree.js +1029 -1113
- package/dist/cjs/ai/StateMachine.js +694 -756
- package/dist/cjs/animation/Animation.js +232 -241
- package/dist/cjs/audio/AudioAdvanced.js +221 -236
- package/dist/cjs/audio/AudioBridge.js +441 -435
- package/dist/cjs/audio/AudioManager.js +242 -259
- package/dist/cjs/build-cloud/BuildOrchestration.js +1059 -1098
- package/dist/cjs/build-cloud/GodotBuildCloud.js +641 -670
- package/dist/cjs/build-cloud/UnityBuildCloud.js +563 -610
- package/dist/cjs/build-cloud/UnrealBuildCloud.js +610 -635
- package/dist/cjs/core/EventBus.js +51 -56
- package/dist/cjs/core/GameClock.js +62 -66
- package/dist/cjs/core/GameConfig.js +72 -79
- package/dist/cjs/core/GameLoop.js +80 -89
- package/dist/cjs/core/ServiceLocator.js +61 -65
- package/dist/cjs/core/Validation.js +72 -82
- package/dist/cjs/core/math.js +108 -112
- package/dist/cjs/devtools/DevTools.js +542 -563
- package/dist/cjs/devtools/DeveloperExperience.js +521 -559
- package/dist/cjs/devtools/GameplayAnalytics.js +636 -646
- package/dist/cjs/dialogue/DialogueSystem.js +984 -986
- package/dist/cjs/docs/DocGenerator.js +339 -364
- package/dist/cjs/ecs/World.js +355 -371
- package/dist/cjs/editor/AchievementEditor.js +580 -636
- package/dist/cjs/editor/AdvancedEditor.js +184 -191
- package/dist/cjs/editor/AnimationRetargeting.js +696 -741
- package/dist/cjs/editor/AssetBrowser.js +1072 -1160
- package/dist/cjs/editor/AssetManager.js +187 -192
- package/dist/cjs/editor/ConsolePro.js +971 -1061
- package/dist/cjs/editor/CraftingEditor.js +680 -730
- package/dist/cjs/editor/DebugTools.js +187 -185
- package/dist/cjs/editor/DialogueSystem.js +844 -901
- package/dist/cjs/editor/LeaderboardSystem.js +429 -483
- package/dist/cjs/editor/NiceGameEditor.js +1903 -1201
- package/dist/cjs/editor/PrefabSystem.js +772 -838
- package/dist/cjs/editor/ProfilerPanel.js +649 -700
- package/dist/cjs/editor/QuestEditor.js +792 -839
- package/dist/cjs/editor/ReplaySystem.js +585 -634
- package/dist/cjs/editor/SceneEditor.js +176 -200
- package/dist/cjs/editor/ScreenshotMode.js +621 -688
- package/dist/cjs/editor/ShaderGraph.js +1556 -1582
- package/dist/cjs/editor/TimelineEditor.js +715 -778
- package/dist/cjs/editor/UndoRedoPro.js +830 -904
- package/dist/cjs/editor/VRARMode.js +582 -645
- package/dist/cjs/engine/NiceGameEngine.js +141 -164
- package/dist/cjs/engine/SaveSystem.js +441 -495
- package/dist/cjs/enterprise/Enterprise.js +254 -261
- package/dist/cjs/export/BevyExporter.js +927 -967
- package/dist/cjs/export/CocosExporter.js +644 -673
- package/dist/cjs/export/Construct3Exporter.js +783 -794
- package/dist/cjs/export/DefoldExporter.js +1028 -1069
- package/dist/cjs/export/GDevelopExporter.js +674 -708
- package/dist/cjs/export/GameMakerExporter.js +791 -805
- package/dist/cjs/export/GodotExporter.js +1003 -1045
- package/dist/cjs/export/MinecraftBedrockExporter.js +573 -578
- package/dist/cjs/export/MonoGameExporter.js +1265 -1293
- package/dist/cjs/export/Pico8Exporter.js +766 -812
- package/dist/cjs/export/PlatformExporter.js +188 -206
- package/dist/cjs/export/RPGMakerExporter.js +860 -879
- package/dist/cjs/export/RobloxExporter.js +883 -919
- package/dist/cjs/export/Solar2DExporter.js +1218 -1256
- package/dist/cjs/export/ThreeJSExporter.js +1006 -1073
- package/dist/cjs/export/Tic80Exporter.js +1210 -1267
- package/dist/cjs/export/UnityExporter.js +1116 -1131
- package/dist/cjs/export/UnrealExporter.js +889 -919
- package/dist/cjs/export/WebExporter.js +931 -970
- package/dist/cjs/export/index.js +42 -65
- package/dist/cjs/godot-integration/GodotAssetLibrary.js +659 -692
- package/dist/cjs/godot-integration/GodotImport.js +929 -1027
- package/dist/cjs/godot-integration/GodotLiveLink.js +915 -945
- package/dist/cjs/godot-integration/components/GodotProjectBrowser.js +911 -611
- package/dist/cjs/i18n/I18n.js +860 -900
- package/dist/cjs/i18n/useTranslation.js +84 -89
- package/dist/cjs/import/AsepriteImporter.js +658 -716
- package/dist/cjs/import/DragonBonesImporter.js +437 -461
- package/dist/cjs/import/GameMakerImporter.js +511 -521
- package/dist/cjs/import/GodotSceneImporter.js +788 -822
- package/dist/cjs/import/LDtkImporter.js +436 -454
- package/dist/cjs/import/Live2DImporter.js +497 -518
- package/dist/cjs/import/NdgFormat.js +424 -457
- package/dist/cjs/import/OgmoImporter.js +466 -493
- package/dist/cjs/import/RPGMakerImporter.js +451 -477
- package/dist/cjs/import/SceneImporter.js +378 -423
- package/dist/cjs/import/SpineImporter.js +511 -546
- package/dist/cjs/import/SpriterImporter.js +590 -613
- package/dist/cjs/import/TiledMapImporter.js +811 -846
- package/dist/cjs/import/UnitySceneImporter.js +687 -703
- package/dist/cjs/import/index.js +206 -251
- package/dist/cjs/index.js +275 -278
- package/dist/cjs/input/GamepadNavigation.js +185 -205
- package/dist/cjs/input/InputManager.js +397 -421
- package/dist/cjs/input/useGamepads.js +70 -81
- package/dist/cjs/integration/IconSprite.js +129 -256
- package/dist/cjs/inventory/InventorySystem.js +920 -995
- package/dist/cjs/kids/KidMode.js +997 -1022
- package/dist/cjs/kids/KidTools.js +570 -594
- package/dist/cjs/monetization/Monetization.js +170 -177
- package/dist/cjs/multiplayer/LocalMultiplayer.js +287 -287
- package/dist/cjs/multiplayer/MiniGameTypes.js +49 -59
- package/dist/cjs/native-engine/AnimationSystem.js +731 -806
- package/dist/cjs/native-engine/AssetPipeline.js +454 -515
- package/dist/cjs/native-engine/AudioEngine.js +763 -804
- package/dist/cjs/native-engine/InputSystem.js +1075 -1145
- package/dist/cjs/native-engine/NetworkingSystem.js +733 -793
- package/dist/cjs/native-engine/PhysicsEngine.js +583 -607
- package/dist/cjs/native-engine/RenderingEngine.js +302 -350
- package/dist/cjs/native-engine/SceneGraph.js +769 -808
- package/dist/cjs/network/MultiplayerTransport.js +97 -132
- package/dist/cjs/network/Networking.js +549 -564
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/AbortController.js +21 -29
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/AccessTokenHttpClient.js +40 -48
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/DefaultHttpClient.js +35 -43
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/DefaultReconnectPolicy.js +10 -15
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/Errors.js +103 -135
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/FetchHttpClient.js +131 -158
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HandshakeProtocol.js +39 -53
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HeaderNames.js +5 -8
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HttpClient.js +40 -48
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HttpConnection.js +494 -572
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HubConnection.js +826 -953
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HubConnectionBuilder.js +125 -146
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/IHubProtocol.js +13 -23
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/ILogger.js +11 -25
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/ITransport.js +13 -24
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/JsonHubProtocol.js +108 -121
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/Loggers.js +10 -14
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/LongPollingTransport.js +150 -185
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/MessageBuffer.js +158 -196
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/ServerSentEventsTransport.js +90 -105
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/Subject.js +30 -35
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/TextMessageFormat.js +16 -21
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/Utils.js +215 -248
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/WebSocketTransport.js +135 -157
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/XhrHttpClient.js +76 -85
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/index.js +24 -27
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/pkg-version.js +3 -4
- package/dist/cjs/pathfinding/Pathfinding.js +245 -263
- package/dist/cjs/performance/AssetStreaming.js +561 -635
- package/dist/cjs/performance/BenchmarkSuite.js +283 -311
- package/dist/cjs/performance/DeltaCompression.js +467 -526
- package/dist/cjs/performance/DeterministicPhysics.js +450 -498
- package/dist/cjs/performance/ECSOptimization.js +644 -695
- package/dist/cjs/performance/GameSaveSystem.js +509 -556
- package/dist/cjs/performance/HotReload.js +447 -500
- package/dist/cjs/performance/InputRecording.js +511 -561
- package/dist/cjs/performance/InterestManagement.js +453 -500
- package/dist/cjs/performance/LocalizationRuntime.js +376 -423
- package/dist/cjs/performance/MemoryManagement.js +410 -470
- package/dist/cjs/performance/ModSupport.js +445 -496
- package/dist/cjs/performance/MultiThreadedPhysics.js +400 -443
- package/dist/cjs/performance/NetworkPrediction.js +424 -482
- package/dist/cjs/performance/ObjectPooling.js +569 -617
- package/dist/cjs/performance/Performance.js +174 -190
- package/dist/cjs/performance/PerformanceAdvanced.js +614 -637
- package/dist/cjs/performance/WebGPURenderer.js +656 -683
- package/dist/cjs/physics/PhysicsAdvanced.js +345 -379
- package/dist/cjs/physics/PhysicsEngine2D.js +391 -427
- package/dist/cjs/plugins/PluginSDK.js +432 -466
- package/dist/cjs/plugins/PluginTestKit.js +307 -330
- package/dist/cjs/procedural/Procedural.js +243 -254
- package/dist/cjs/procedural/WorldBuilding.js +297 -314
- package/dist/cjs/quest/QuestSystem.js +975 -932
- package/dist/cjs/release/MobileExport.js +157 -163
- package/dist/cjs/release/Release.js +225 -238
- package/dist/cjs/rendering/Camera2D.js +121 -124
- package/dist/cjs/rendering/Renderer2D.js +321 -335
- package/dist/cjs/rendering/WebGPURenderPipeline.js +632 -651
- package/dist/cjs/runtime3d/Runtime3D.js +359 -378
- package/dist/cjs/runtime3d/SceneEditor3D.js +252 -263
- package/dist/cjs/scene/SceneManager.js +177 -193
- package/dist/cjs/scripting/GraphToAST.js +574 -547
- package/dist/cjs/scripting/LanguageExporter.js +254 -279
- package/dist/cjs/scripting/NodeGraph.js +546 -570
- package/dist/cjs/scripting/ScriptAST.js +31 -39
- package/dist/cjs/scripting/VisualScripting2.js +1016 -1065
- package/dist/cjs/scripting/exporters/CSharpExporter.js +464 -496
- package/dist/cjs/scripting/exporters/GDScriptExporter.js +390 -442
- package/dist/cjs/scripting/exporters/LuaExporter.js +406 -447
- package/dist/cjs/scripting/exporters/PythonExporter.js +484 -549
- package/dist/cjs/scripting/exporters/RustExporter.js +459 -512
- package/dist/cjs/scripting/exporters/TypeScriptExporter.js +505 -556
- package/dist/cjs/social/Social.js +72 -80
- package/dist/cjs/systems/LightingSystem.js +844 -931
- package/dist/cjs/systems/ParticleSystem2.js +1447 -1451
- package/dist/cjs/systems/PhysicsDebugSystem.js +1070 -1141
- package/dist/cjs/systems/TerrainSystem.js +985 -1098
- package/dist/cjs/templates/ActionTemplates.js +296 -309
- package/dist/cjs/templates/FightingTemplate.js +417 -463
- package/dist/cjs/templates/MetroidvaniaTemplate.js +353 -405
- package/dist/cjs/templates/PartyTemplates.js +190 -202
- package/dist/cjs/templates/PuzzleTemplates.js +245 -261
- package/dist/cjs/templates/RPGTemplates.js +160 -178
- package/dist/cjs/templates/SportsTemplates.js +237 -250
- package/dist/cjs/templates/StrategyTemplates.js +143 -153
- package/dist/cjs/templates/SurvivalTemplate.js +336 -380
- package/dist/cjs/templates/WaveDefense.js +499 -526
- package/dist/cjs/tilemap/Tilemap.js +207 -214
- package/dist/cjs/tutorials/TutorialBranching.js +396 -417
- package/dist/cjs/tutorials/TutorialEngine.js +888 -931
- package/dist/cjs/tutorials/TutorialOverlay.js +602 -640
- package/dist/cjs/tutorials/content/Tutorials_T05_T08.js +787 -809
- package/dist/cjs/tutorials/content/Tutorials_T09_T11.js +736 -756
- package/dist/cjs/tutorials/content/Tutorials_T12_T15.js +754 -778
- package/dist/cjs/ui/GameUI.js +295 -312
- package/dist/cjs/unity-integration/UnityAssetStore.js +700 -741
- package/dist/cjs/unity-integration/UnityImport.js +1066 -1176
- package/dist/cjs/unity-integration/UnityLiveLink.js +934 -981
- package/dist/cjs/unity-integration/components/UnityAssetStoreBrowser.js +1233 -757
- package/dist/cjs/unity-integration/components/UnityProjectBrowser.js +1240 -768
- package/dist/cjs/unreal-integration/UnrealImport.js +391 -412
- package/dist/cjs/unreal-integration/UnrealLiveLink.js +1102 -1137
- package/dist/cjs/unreal-integration/UnrealMarketplace.js +436 -473
- package/dist/cjs/unreal-integration/components/UnrealProjectBrowser.js +1150 -767
- package/dist/cjs/xr/ARVR.js +167 -175
- package/dist/esm/accessibility/Accessibility.js +160 -164
- package/dist/esm/ai/AI.js +310 -293
- package/dist/esm/ai/BehaviorTree.js +1057 -1112
- package/dist/esm/ai/StateMachine.js +709 -755
- package/dist/esm/animation/Animation.js +237 -240
- package/dist/esm/audio/AudioAdvanced.js +239 -235
- package/dist/esm/audio/AudioBridge.js +448 -434
- package/dist/esm/audio/AudioManager.js +243 -258
- package/dist/esm/build-cloud/BuildOrchestration.js +1071 -1097
- package/dist/esm/build-cloud/GodotBuildCloud.js +647 -669
- package/dist/esm/build-cloud/UnityBuildCloud.js +571 -609
- package/dist/esm/build-cloud/UnrealBuildCloud.js +615 -634
- package/dist/esm/core/EventBus.js +52 -55
- package/dist/esm/core/GameClock.js +63 -65
- package/dist/esm/core/GameConfig.js +77 -78
- package/dist/esm/core/GameLoop.js +81 -88
- package/dist/esm/core/ServiceLocator.js +63 -64
- package/dist/esm/core/Validation.js +82 -81
- package/dist/esm/core/math.js +109 -111
- package/dist/esm/devtools/DevTools.js +546 -562
- package/dist/esm/devtools/DeveloperExperience.js +535 -558
- package/dist/esm/devtools/GameplayAnalytics.js +647 -645
- package/dist/esm/dialogue/DialogueSystem.js +998 -985
- package/dist/esm/docs/DocGenerator.js +342 -363
- package/dist/esm/ecs/World.js +358 -370
- package/dist/esm/editor/AchievementEditor.js +584 -635
- package/dist/esm/editor/AdvancedEditor.js +191 -190
- package/dist/esm/editor/AnimationRetargeting.js +700 -740
- package/dist/esm/editor/AssetBrowser.js +1078 -1159
- package/dist/esm/editor/AssetManager.js +188 -191
- package/dist/esm/editor/ConsolePro.js +977 -1060
- package/dist/esm/editor/CraftingEditor.js +684 -729
- package/dist/esm/editor/DebugTools.js +194 -184
- package/dist/esm/editor/DialogueSystem.js +849 -900
- package/dist/esm/editor/LeaderboardSystem.js +433 -482
- package/dist/esm/editor/NiceGameEditor.js +1908 -1200
- package/dist/esm/editor/PrefabSystem.js +777 -837
- package/dist/esm/editor/ProfilerPanel.js +654 -699
- package/dist/esm/editor/QuestEditor.js +795 -838
- package/dist/esm/editor/ReplaySystem.js +591 -633
- package/dist/esm/editor/SceneEditor.js +189 -199
- package/dist/esm/editor/ScreenshotMode.js +628 -687
- package/dist/esm/editor/ShaderGraph.js +1565 -1581
- package/dist/esm/editor/TimelineEditor.js +733 -777
- package/dist/esm/editor/UndoRedoPro.js +835 -903
- package/dist/esm/editor/VRARMode.js +586 -644
- package/dist/esm/engine/NiceGameEngine.js +142 -163
- package/dist/esm/engine/SaveSystem.js +447 -494
- package/dist/esm/enterprise/Enterprise.js +265 -260
- package/dist/esm/export/BevyExporter.js +929 -966
- package/dist/esm/export/CocosExporter.js +646 -672
- package/dist/esm/export/Construct3Exporter.js +785 -793
- package/dist/esm/export/DefoldExporter.js +1030 -1068
- package/dist/esm/export/GDevelopExporter.js +676 -707
- package/dist/esm/export/GameMakerExporter.js +793 -804
- package/dist/esm/export/GodotExporter.js +1004 -1044
- package/dist/esm/export/MinecraftBedrockExporter.js +575 -577
- package/dist/esm/export/MonoGameExporter.js +1267 -1292
- package/dist/esm/export/Pico8Exporter.js +768 -811
- package/dist/esm/export/PlatformExporter.js +193 -205
- package/dist/esm/export/RPGMakerExporter.js +862 -878
- package/dist/esm/export/RobloxExporter.js +885 -918
- package/dist/esm/export/Solar2DExporter.js +1220 -1255
- package/dist/esm/export/ThreeJSExporter.js +1007 -1072
- package/dist/esm/export/Tic80Exporter.js +1212 -1266
- package/dist/esm/export/UnityExporter.js +1117 -1130
- package/dist/esm/export/UnrealExporter.js +891 -918
- package/dist/esm/export/WebExporter.js +933 -969
- package/dist/esm/export/index.js +86 -71
- package/dist/esm/godot-integration/GodotAssetLibrary.js +663 -691
- package/dist/esm/godot-integration/GodotImport.js +935 -1026
- package/dist/esm/godot-integration/GodotLiveLink.js +918 -944
- package/dist/esm/godot-integration/components/GodotProjectBrowser.js +912 -610
- package/dist/esm/i18n/I18n.js +871 -899
- package/dist/esm/i18n/useTranslation.js +88 -88
- package/dist/esm/import/AsepriteImporter.js +637 -715
- package/dist/esm/import/DragonBonesImporter.js +417 -460
- package/dist/esm/import/GameMakerImporter.js +491 -520
- package/dist/esm/import/GodotSceneImporter.js +767 -821
- package/dist/esm/import/LDtkImporter.js +415 -453
- package/dist/esm/import/Live2DImporter.js +477 -517
- package/dist/esm/import/NdgFormat.js +410 -456
- package/dist/esm/import/OgmoImporter.js +446 -492
- package/dist/esm/import/RPGMakerImporter.js +431 -476
- package/dist/esm/import/SceneImporter.js +385 -422
- package/dist/esm/import/SpineImporter.js +491 -545
- package/dist/esm/import/SpriterImporter.js +570 -612
- package/dist/esm/import/TiledMapImporter.js +790 -845
- package/dist/esm/import/UnitySceneImporter.js +666 -702
- package/dist/esm/import/index.js +247 -258
- package/dist/esm/index.js +1332 -188
- package/dist/esm/input/GamepadNavigation.js +187 -204
- package/dist/esm/input/InputManager.js +401 -420
- package/dist/esm/input/useGamepads.js +72 -80
- package/dist/esm/integration/IconSprite.js +143 -255
- package/dist/esm/inventory/InventorySystem.js +925 -994
- package/dist/esm/kids/KidMode.js +1003 -1021
- package/dist/esm/kids/KidTools.js +573 -593
- package/dist/esm/monetization/Monetization.js +180 -176
- package/dist/esm/multiplayer/LocalMultiplayer.js +290 -286
- package/dist/esm/multiplayer/MiniGameTypes.js +58 -58
- package/dist/esm/native-engine/AnimationSystem.js +735 -805
- package/dist/esm/native-engine/AssetPipeline.js +456 -514
- package/dist/esm/native-engine/AudioEngine.js +765 -803
- package/dist/esm/native-engine/InputSystem.js +1079 -1144
- package/dist/esm/native-engine/NetworkingSystem.js +740 -792
- package/dist/esm/native-engine/PhysicsEngine.js +585 -606
- package/dist/esm/native-engine/RenderingEngine.js +304 -349
- package/dist/esm/native-engine/SceneGraph.js +773 -807
- package/dist/esm/network/MultiplayerTransport.js +99 -131
- package/dist/esm/network/Networking.js +556 -563
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/AbortController.js +22 -28
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/AccessTokenHttpClient.js +41 -47
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/DefaultHttpClient.js +36 -42
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/DefaultReconnectPolicy.js +11 -14
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/Errors.js +111 -134
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/FetchHttpClient.js +132 -157
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HandshakeProtocol.js +40 -52
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HeaderNames.js +6 -7
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HttpClient.js +42 -47
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HttpConnection.js +496 -571
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HubConnection.js +828 -952
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HubConnectionBuilder.js +126 -145
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/IHubProtocol.js +14 -23
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/ILogger.js +12 -25
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/ITransport.js +15 -24
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/JsonHubProtocol.js +109 -120
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/Loggers.js +11 -13
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/LongPollingTransport.js +151 -184
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/MessageBuffer.js +159 -195
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/ServerSentEventsTransport.js +91 -104
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/Subject.js +31 -34
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/TextMessageFormat.js +17 -20
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/Utils.js +230 -248
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/WebSocketTransport.js +136 -156
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/XhrHttpClient.js +77 -84
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/index.js +31 -12
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/pkg-version.js +4 -3
- package/dist/esm/pathfinding/Pathfinding.js +249 -262
- package/dist/esm/performance/AssetStreaming.js +567 -634
- package/dist/esm/performance/BenchmarkSuite.js +285 -310
- package/dist/esm/performance/DeltaCompression.js +478 -525
- package/dist/esm/performance/DeterministicPhysics.js +479 -497
- package/dist/esm/performance/ECSOptimization.js +653 -694
- package/dist/esm/performance/GameSaveSystem.js +515 -555
- package/dist/esm/performance/HotReload.js +454 -499
- package/dist/esm/performance/InputRecording.js +520 -560
- package/dist/esm/performance/InterestManagement.js +460 -499
- package/dist/esm/performance/LocalizationRuntime.js +382 -422
- package/dist/esm/performance/MemoryManagement.js +415 -469
- package/dist/esm/performance/ModSupport.js +455 -495
- package/dist/esm/performance/MultiThreadedPhysics.js +408 -442
- package/dist/esm/performance/NetworkPrediction.js +436 -481
- package/dist/esm/performance/ObjectPooling.js +582 -616
- package/dist/esm/performance/Performance.js +182 -189
- package/dist/esm/performance/PerformanceAdvanced.js +621 -636
- package/dist/esm/performance/WebGPURenderer.js +660 -682
- package/dist/esm/physics/PhysicsAdvanced.js +359 -378
- package/dist/esm/physics/PhysicsEngine2D.js +393 -426
- package/dist/esm/plugins/PluginSDK.js +435 -465
- package/dist/esm/plugins/PluginTestKit.js +315 -329
- package/dist/esm/procedural/Procedural.js +248 -253
- package/dist/esm/procedural/WorldBuilding.js +316 -313
- package/dist/esm/quest/QuestSystem.js +982 -931
- package/dist/esm/release/MobileExport.js +163 -162
- package/dist/esm/release/Release.js +234 -237
- package/dist/esm/rendering/Camera2D.js +122 -123
- package/dist/esm/rendering/Renderer2D.js +323 -334
- package/dist/esm/rendering/WebGPURenderPipeline.js +647 -650
- package/dist/esm/runtime3d/Runtime3D.js +368 -377
- package/dist/esm/runtime3d/SceneEditor3D.js +268 -262
- package/dist/esm/scene/SceneManager.js +178 -192
- package/dist/esm/scripting/GraphToAST.js +576 -546
- package/dist/esm/scripting/LanguageExporter.js +263 -278
- package/dist/esm/scripting/NodeGraph.js +550 -569
- package/dist/esm/scripting/ScriptAST.js +45 -38
- package/dist/esm/scripting/VisualScripting2.js +1025 -1064
- package/dist/esm/scripting/exporters/CSharpExporter.js +465 -495
- package/dist/esm/scripting/exporters/GDScriptExporter.js +391 -441
- package/dist/esm/scripting/exporters/LuaExporter.js +407 -446
- package/dist/esm/scripting/exporters/PythonExporter.js +485 -548
- package/dist/esm/scripting/exporters/RustExporter.js +460 -511
- package/dist/esm/scripting/exporters/TypeScriptExporter.js +506 -555
- package/dist/esm/social/Social.js +77 -79
- package/dist/esm/systems/LightingSystem.js +855 -930
- package/dist/esm/systems/ParticleSystem2.js +1453 -1450
- package/dist/esm/systems/PhysicsDebugSystem.js +1078 -1140
- package/dist/esm/systems/TerrainSystem.js +996 -1097
- package/dist/esm/templates/ActionTemplates.js +307 -308
- package/dist/esm/templates/FightingTemplate.js +439 -462
- package/dist/esm/templates/MetroidvaniaTemplate.js +391 -404
- package/dist/esm/templates/PartyTemplates.js +206 -201
- package/dist/esm/templates/PuzzleTemplates.js +260 -260
- package/dist/esm/templates/RPGTemplates.js +172 -177
- package/dist/esm/templates/SportsTemplates.js +251 -249
- package/dist/esm/templates/StrategyTemplates.js +158 -152
- package/dist/esm/templates/SurvivalTemplate.js +367 -379
- package/dist/esm/templates/WaveDefense.js +501 -525
- package/dist/esm/tilemap/Tilemap.js +209 -213
- package/dist/esm/tutorials/TutorialBranching.js +399 -416
- package/dist/esm/tutorials/TutorialEngine.js +893 -930
- package/dist/esm/tutorials/TutorialOverlay.js +603 -639
- package/dist/esm/tutorials/content/Tutorials_T05_T08.js +792 -808
- package/dist/esm/tutorials/content/Tutorials_T09_T11.js +740 -755
- package/dist/esm/tutorials/content/Tutorials_T12_T15.js +759 -777
- package/dist/esm/ui/GameUI.js +296 -311
- package/dist/esm/unity-integration/UnityAssetStore.js +704 -740
- package/dist/esm/unity-integration/UnityImport.js +1071 -1175
- package/dist/esm/unity-integration/UnityLiveLink.js +938 -980
- package/dist/esm/unity-integration/components/UnityAssetStoreBrowser.js +1234 -756
- package/dist/esm/unity-integration/components/UnityProjectBrowser.js +1241 -767
- package/dist/esm/unreal-integration/UnrealImport.js +395 -411
- package/dist/esm/unreal-integration/UnrealLiveLink.js +1105 -1136
- package/dist/esm/unreal-integration/UnrealMarketplace.js +442 -472
- package/dist/esm/unreal-integration/components/UnrealProjectBrowser.js +1151 -766
- package/dist/esm/xr/ARVR.js +181 -174
- package/package.json +7 -12
|
@@ -1,1177 +1,1162 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
/* ────────────────────────────────────────────────────────────────
|
|
8
|
-
Unity Package Exporter
|
|
9
|
-
|
|
10
|
-
Exports Nice2Dev projects to Unity .unitypackage format.
|
|
11
|
-
Generates C# scripts, prefabs, scenes, and materials.
|
|
12
|
-
──────────────────────────────────────────────────────────────── */
|
|
13
|
-
/* ── Unity Exporter Class ─────────────────────────────────────── */
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const CSharpExporter = require("../scripting/exporters/CSharpExporter.js");
|
|
4
|
+
const GraphToAST = require("../scripting/GraphToAST.js");
|
|
5
|
+
const PlatformExporter = require("./PlatformExporter.js");
|
|
14
6
|
class UnityExporter extends PlatformExporter.PlatformExporter {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
this.platformId = "unity";
|
|
10
|
+
this.platformInfo = {
|
|
11
|
+
id: "unity",
|
|
12
|
+
name: "Unity",
|
|
13
|
+
description: "Professional game engine for 2D and 3D games",
|
|
14
|
+
website: "https://unity.com",
|
|
15
|
+
features: [
|
|
16
|
+
"2d-rendering",
|
|
17
|
+
"3d-rendering",
|
|
18
|
+
"physics-2d",
|
|
19
|
+
"physics-3d",
|
|
20
|
+
"audio",
|
|
21
|
+
"networking",
|
|
22
|
+
"ui-system",
|
|
23
|
+
"visual-scripting",
|
|
24
|
+
"particles",
|
|
25
|
+
"animation",
|
|
26
|
+
"vr-ar"
|
|
27
|
+
],
|
|
28
|
+
supportedAssets: [
|
|
29
|
+
"sprite",
|
|
30
|
+
"tileset",
|
|
31
|
+
"audio",
|
|
32
|
+
"font",
|
|
33
|
+
"script",
|
|
34
|
+
"scene",
|
|
35
|
+
"prefab",
|
|
36
|
+
"material",
|
|
37
|
+
"shader",
|
|
38
|
+
"animation",
|
|
39
|
+
"particleSystem"
|
|
40
|
+
],
|
|
41
|
+
exportFormats: [".unitypackage", ".prefab", ".unity", ".cs"]
|
|
42
|
+
};
|
|
43
|
+
this.csharpExporter = new CSharpExporter.CSharpExporter();
|
|
44
|
+
this.graphToAST = new GraphToAST.GraphToAST();
|
|
45
|
+
this.guidMap = /* @__PURE__ */ new Map();
|
|
46
|
+
this.fileIdCounter = 1e5;
|
|
47
|
+
}
|
|
48
|
+
async doExport(project, options) {
|
|
49
|
+
const unity = options.platformOptions;
|
|
50
|
+
const projectName = options.projectName || project.name;
|
|
51
|
+
const ns = unity?.namespace || this.toValidNamespace(projectName);
|
|
52
|
+
this.generateGuids(project);
|
|
53
|
+
await this.exportProjectSettings(project, options, unity);
|
|
54
|
+
await this.exportScripts(project, options, ns);
|
|
55
|
+
await this.exportPrefabs(project, options);
|
|
56
|
+
await this.exportScenes(project, options);
|
|
57
|
+
await this.exportMaterials(project, options, unity);
|
|
58
|
+
await this.exportAssets(project, options);
|
|
59
|
+
if (unity?.generateAsmdef !== false) {
|
|
60
|
+
this.exportAssemblyDefinition(projectName, ns);
|
|
55
61
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const projectName = options.projectName || project.name;
|
|
59
|
-
const ns = unity?.namespace || this.toValidNamespace(projectName);
|
|
60
|
-
// Generate GUIDs for all assets
|
|
61
|
-
this.generateGuids(project);
|
|
62
|
-
// 1. Generate project structure
|
|
63
|
-
await this.exportProjectSettings(project, options, unity);
|
|
64
|
-
// 2. Export scripts
|
|
65
|
-
await this.exportScripts(project, options, ns);
|
|
66
|
-
// 3. Export prefabs
|
|
67
|
-
await this.exportPrefabs(project, options);
|
|
68
|
-
// 4. Export scenes
|
|
69
|
-
await this.exportScenes(project, options);
|
|
70
|
-
// 5. Export materials
|
|
71
|
-
await this.exportMaterials(project, options, unity);
|
|
72
|
-
// 6. Export assets (sprites, audio, etc.)
|
|
73
|
-
await this.exportAssets(project, options);
|
|
74
|
-
// 7. Generate assembly definition
|
|
75
|
-
if (unity?.generateAsmdef !== false) {
|
|
76
|
-
this.exportAssemblyDefinition(projectName, ns);
|
|
77
|
-
}
|
|
78
|
-
// 8. Generate Nice2Dev runtime bridge
|
|
79
|
-
if (unity?.includeRuntime !== false) {
|
|
80
|
-
this.exportRuntimeBridge(ns);
|
|
81
|
-
}
|
|
82
|
-
// 9. Generate manifest for .unitypackage
|
|
83
|
-
this.exportPackageManifest(project);
|
|
62
|
+
if (unity?.includeRuntime !== false) {
|
|
63
|
+
this.exportRuntimeBridge(ns);
|
|
84
64
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
65
|
+
this.exportPackageManifest(project);
|
|
66
|
+
}
|
|
67
|
+
/* ── Project Settings ───────────────────────────────────────── */
|
|
68
|
+
async exportProjectSettings(project, _options, _unity) {
|
|
69
|
+
const settings = `%YAML 1.1
|
|
70
|
+
%TAG !u! tag:unity3d.com,2011:
|
|
71
|
+
--- !u!129 &1
|
|
72
|
+
PlayerSettings:
|
|
73
|
+
productName: ${project.name}
|
|
74
|
+
companyName: ${project.author || "Nice2Dev"}
|
|
75
|
+
defaultScreenWidth: ${project.settings.resolution.width}
|
|
76
|
+
defaultScreenHeight: ${project.settings.resolution.height}
|
|
77
|
+
runInBackground: 1
|
|
78
|
+
colorSpace: 1
|
|
79
|
+
activeInputHandler: 2
|
|
99
80
|
targetGpuSkinning: 1`;
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
81
|
+
this.addTextFile(`ProjectSettings/ProjectSettings.asset`, settings);
|
|
82
|
+
this.addTextFile(
|
|
83
|
+
`ProjectSettings/ProjectSettings.asset.meta`,
|
|
84
|
+
this.createMetaFile("project-settings")
|
|
85
|
+
);
|
|
86
|
+
if (project.settings.physics?.enabled) {
|
|
87
|
+
const gravity = project.settings.physics.gravity;
|
|
88
|
+
const physics2d = `%YAML 1.1
|
|
89
|
+
%TAG !u! tag:unity3d.com,2011:
|
|
90
|
+
--- !u!19 &1
|
|
91
|
+
Physics2DSettings:
|
|
92
|
+
m_Gravity: {x: ${gravity.x}, y: ${gravity.y}}
|
|
93
|
+
m_DefaultMaterial: {fileID: 0}
|
|
94
|
+
m_VelocityIterations: 8
|
|
112
95
|
m_PositionIterations: 3`;
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
/* ── Scripts ────────────────────────────────────────────────── */
|
|
117
|
-
async exportScripts(project, options, namespace) {
|
|
118
|
-
for (const script of project.scripts) {
|
|
119
|
-
try {
|
|
120
|
-
const ast = this.graphToAST.convert(script);
|
|
121
|
-
const result = this.csharpExporter.export(ast, {
|
|
122
|
-
namespace,
|
|
123
|
-
includeDebugComments: options.debug,
|
|
124
|
-
});
|
|
125
|
-
for (const file of result.files) {
|
|
126
|
-
const path = `Assets/Scripts/${file.path}`;
|
|
127
|
-
this.addTextFile(path, file.content);
|
|
128
|
-
this.addTextFile(`${path}.meta`, this.createScriptMetaFile(script.id));
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
catch (error) {
|
|
132
|
-
this.addWarning('SCRIPT_EXPORT_ERROR', `Failed to export script "${script.name}": ${error}`, 'Check visual script for errors');
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
/* ── Prefabs ────────────────────────────────────────────────── */
|
|
137
|
-
async exportPrefabs(project, _options) {
|
|
138
|
-
for (const prefab of project.prefabs) {
|
|
139
|
-
const yaml = this.createPrefabYAML(prefab, project);
|
|
140
|
-
const path = `Assets/Prefabs/${this.sanitizeFileName(prefab.name)}.prefab`;
|
|
141
|
-
this.addTextFile(path, yaml);
|
|
142
|
-
this.addTextFile(`${path}.meta`, this.createMetaFile(prefab.id));
|
|
143
|
-
}
|
|
96
|
+
this.addTextFile(`ProjectSettings/Physics2DSettings.asset`, physics2d);
|
|
144
97
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
type: 'PrefabInstance',
|
|
155
|
-
properties: {
|
|
156
|
-
m_ObjectHideFlags: 0,
|
|
157
|
-
m_CorrespondingSourceObject: { fileID: 0 },
|
|
158
|
-
m_PrefabInstance: { fileID: 0 },
|
|
159
|
-
m_PrefabAsset: { fileID: 0 },
|
|
160
|
-
},
|
|
161
|
-
});
|
|
162
|
-
// Root GameObject
|
|
163
|
-
objects.push({
|
|
164
|
-
fileID: gameObjectId,
|
|
165
|
-
classID: 1, // GameObject
|
|
166
|
-
type: 'GameObject',
|
|
167
|
-
properties: {
|
|
168
|
-
m_ObjectHideFlags: 0,
|
|
169
|
-
m_Name: prefab.name,
|
|
170
|
-
m_IsActive: 1,
|
|
171
|
-
m_Layer: 0,
|
|
172
|
-
m_Tag: 'Untagged',
|
|
173
|
-
},
|
|
98
|
+
}
|
|
99
|
+
/* ── Scripts ────────────────────────────────────────────────── */
|
|
100
|
+
async exportScripts(project, options, namespace) {
|
|
101
|
+
for (const script of project.scripts) {
|
|
102
|
+
try {
|
|
103
|
+
const ast = this.graphToAST.convert(script);
|
|
104
|
+
const result = this.csharpExporter.export(ast, {
|
|
105
|
+
namespace,
|
|
106
|
+
includeDebugComments: options.debug
|
|
174
107
|
});
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
type: 'Transform',
|
|
180
|
-
properties: {
|
|
181
|
-
m_LocalRotation: { x: 0, y: 0, z: 0, w: 1 },
|
|
182
|
-
m_LocalPosition: {
|
|
183
|
-
x: prefab.entity.position?.x ?? 0,
|
|
184
|
-
y: prefab.entity.position?.y ?? 0,
|
|
185
|
-
z: 0,
|
|
186
|
-
},
|
|
187
|
-
m_LocalScale: { x: prefab.entity.scale?.x ?? 1, y: prefab.entity.scale?.y ?? 1, z: 1 },
|
|
188
|
-
m_Children: [],
|
|
189
|
-
m_Father: { fileID: 0 },
|
|
190
|
-
m_RootOrder: 0,
|
|
191
|
-
},
|
|
192
|
-
});
|
|
193
|
-
// Add components based on entity type
|
|
194
|
-
this.addEntityComponents(prefab.entity, objects, gameObjectId, project);
|
|
195
|
-
return this.serializeUnityYAML({ objects });
|
|
196
|
-
}
|
|
197
|
-
/* ── Scenes ─────────────────────────────────────────────────── */
|
|
198
|
-
async exportScenes(project, _options) {
|
|
199
|
-
for (const scene of project.scenes) {
|
|
200
|
-
const yaml = this.createSceneYAML(scene, project);
|
|
201
|
-
const path = `Assets/Scenes/${this.sanitizeFileName(scene.name)}.unity`;
|
|
202
|
-
this.addTextFile(path, yaml);
|
|
203
|
-
this.addTextFile(`${path}.meta`, this.createMetaFile(scene.id));
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
createSceneYAML(scene, project) {
|
|
207
|
-
const objects = [];
|
|
208
|
-
// Scene settings (OcclusionCullingSettings, RenderSettings, etc.)
|
|
209
|
-
this.addSceneSettings(objects, project);
|
|
210
|
-
// Create hierarchy of GameObjects
|
|
211
|
-
for (const entity of scene.entities) {
|
|
212
|
-
this.createGameObjectHierarchy(entity, objects, project, null);
|
|
213
|
-
}
|
|
214
|
-
// Handle tilemaps
|
|
215
|
-
for (const tilemap of scene.tilemaps ?? []) {
|
|
216
|
-
this.createTilemapGameObject(tilemap, objects, project);
|
|
217
|
-
}
|
|
218
|
-
return this.serializeUnityYAML({ objects });
|
|
219
|
-
}
|
|
220
|
-
addSceneSettings(objects, project) {
|
|
221
|
-
// OcclusionCullingSettings
|
|
222
|
-
objects.push({
|
|
223
|
-
fileID: 1,
|
|
224
|
-
classID: 29,
|
|
225
|
-
type: 'OcclusionCullingSettings',
|
|
226
|
-
properties: {},
|
|
227
|
-
});
|
|
228
|
-
// RenderSettings
|
|
229
|
-
const bgColor = this.parseColor(project.settings.backgroundColor);
|
|
230
|
-
objects.push({
|
|
231
|
-
fileID: 2,
|
|
232
|
-
classID: 104,
|
|
233
|
-
type: 'RenderSettings',
|
|
234
|
-
properties: {
|
|
235
|
-
m_AmbientSkyColor: bgColor,
|
|
236
|
-
m_AmbientEquatorColor: bgColor,
|
|
237
|
-
m_AmbientGroundColor: bgColor,
|
|
238
|
-
},
|
|
239
|
-
});
|
|
240
|
-
// LightmapSettings
|
|
241
|
-
objects.push({
|
|
242
|
-
fileID: 3,
|
|
243
|
-
classID: 157,
|
|
244
|
-
type: 'LightmapSettings',
|
|
245
|
-
properties: {},
|
|
246
|
-
});
|
|
247
|
-
// NavMeshSettings
|
|
248
|
-
objects.push({
|
|
249
|
-
fileID: 4,
|
|
250
|
-
classID: 196,
|
|
251
|
-
type: 'NavMeshSettings',
|
|
252
|
-
properties: {},
|
|
253
|
-
});
|
|
254
|
-
}
|
|
255
|
-
createGameObjectHierarchy(entity, objects, project, parentTransformId) {
|
|
256
|
-
const gameObjectId = this.nextFileId();
|
|
257
|
-
const transformId = this.nextFileId();
|
|
258
|
-
// GameObject
|
|
259
|
-
objects.push({
|
|
260
|
-
fileID: gameObjectId,
|
|
261
|
-
classID: 1,
|
|
262
|
-
type: 'GameObject',
|
|
263
|
-
properties: {
|
|
264
|
-
m_ObjectHideFlags: 0,
|
|
265
|
-
m_Name: entity.name,
|
|
266
|
-
m_IsActive: 1,
|
|
267
|
-
m_Layer: 0,
|
|
268
|
-
m_Tag: 'Untagged',
|
|
269
|
-
},
|
|
270
|
-
});
|
|
271
|
-
// Process children for transform hierarchy
|
|
272
|
-
const childTransformIds = [];
|
|
273
|
-
if (entity.children) {
|
|
274
|
-
for (const child of entity.children) {
|
|
275
|
-
const childTransformId = this.createGameObjectHierarchy(child, objects, project, transformId);
|
|
276
|
-
childTransformIds.push(childTransformId);
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
// Transform component
|
|
280
|
-
const isRectTransform = entity.components.some((c) => c.type === 'ui-text' || c.type === 'ui-button' || c.type === 'ui-image');
|
|
281
|
-
objects.push({
|
|
282
|
-
fileID: transformId,
|
|
283
|
-
classID: isRectTransform ? 224 : 4, // RectTransform or Transform
|
|
284
|
-
type: isRectTransform ? 'RectTransform' : 'Transform',
|
|
285
|
-
properties: {
|
|
286
|
-
m_GameObject: { fileID: gameObjectId },
|
|
287
|
-
m_LocalRotation: {
|
|
288
|
-
x: 0,
|
|
289
|
-
y: 0,
|
|
290
|
-
z: Math.sin((entity.rotation ?? 0) / 2),
|
|
291
|
-
w: Math.cos((entity.rotation ?? 0) / 2),
|
|
292
|
-
},
|
|
293
|
-
m_LocalPosition: { x: entity.position?.x ?? 0, y: entity.position?.y ?? 0, z: 0 },
|
|
294
|
-
m_LocalScale: { x: entity.scale?.x ?? 1, y: entity.scale?.y ?? 1, z: 1 },
|
|
295
|
-
m_Children: childTransformIds.map((id) => ({ fileID: id })),
|
|
296
|
-
m_Father: parentTransformId ? { fileID: parentTransformId } : { fileID: 0 },
|
|
297
|
-
m_RootOrder: 0,
|
|
298
|
-
},
|
|
299
|
-
});
|
|
300
|
-
// Add other components
|
|
301
|
-
this.addEntityComponents(entity, objects, gameObjectId, project);
|
|
302
|
-
return transformId;
|
|
303
|
-
}
|
|
304
|
-
addEntityComponents(entity, objects, gameObjectId, _project) {
|
|
305
|
-
for (const component of entity.components) {
|
|
306
|
-
const props = component.properties ?? {};
|
|
307
|
-
switch (component.type) {
|
|
308
|
-
case 'sprite':
|
|
309
|
-
this.addSpriteRenderer(objects, gameObjectId, props);
|
|
310
|
-
break;
|
|
311
|
-
case 'rigidbody-2d':
|
|
312
|
-
this.addRigidbody2D(objects, gameObjectId, props);
|
|
313
|
-
break;
|
|
314
|
-
case 'box-collider-2d':
|
|
315
|
-
this.addBoxCollider2D(objects, gameObjectId, props);
|
|
316
|
-
break;
|
|
317
|
-
case 'circle-collider-2d':
|
|
318
|
-
this.addCircleCollider2D(objects, gameObjectId, props);
|
|
319
|
-
break;
|
|
320
|
-
case 'audio-source':
|
|
321
|
-
this.addAudioSource(objects, gameObjectId, props);
|
|
322
|
-
break;
|
|
323
|
-
case 'animator':
|
|
324
|
-
this.addAnimator(objects, gameObjectId, props);
|
|
325
|
-
break;
|
|
326
|
-
case 'ui-text':
|
|
327
|
-
this.addUIText(objects, gameObjectId, props);
|
|
328
|
-
break;
|
|
329
|
-
case 'ui-image':
|
|
330
|
-
this.addUIImage(objects, gameObjectId, props);
|
|
331
|
-
break;
|
|
332
|
-
case 'ui-button':
|
|
333
|
-
this.addUIButton(objects, gameObjectId, props);
|
|
334
|
-
break;
|
|
335
|
-
case 'particle-system':
|
|
336
|
-
this.addParticleSystem(objects, gameObjectId, props);
|
|
337
|
-
break;
|
|
338
|
-
default:
|
|
339
|
-
this.addWarning('UNKNOWN_COMPONENT', `Unknown component type "${component.type}" on entity "${entity.name}"`, 'Component will be skipped');
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
// Add script component if entity has one
|
|
343
|
-
if (entity.scriptId) {
|
|
344
|
-
this.addScriptComponent(objects, gameObjectId, entity.scriptId);
|
|
108
|
+
for (const file of result.files) {
|
|
109
|
+
const path = `Assets/Scripts/${file.path}`;
|
|
110
|
+
this.addTextFile(path, file.content);
|
|
111
|
+
this.addTextFile(`${path}.meta`, this.createScriptMetaFile(script.id));
|
|
345
112
|
}
|
|
113
|
+
} catch (error) {
|
|
114
|
+
this.addWarning(
|
|
115
|
+
"SCRIPT_EXPORT_ERROR",
|
|
116
|
+
`Failed to export script "${script.name}": ${error}`,
|
|
117
|
+
"Check visual script for errors"
|
|
118
|
+
);
|
|
119
|
+
}
|
|
346
120
|
}
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
properties: {
|
|
356
|
-
m_GameObject: { fileID: gameObjectId },
|
|
357
|
-
m_Enabled: 1,
|
|
358
|
-
m_Sprite: spriteId
|
|
359
|
-
? { fileID: 21300000, guid: this.guidMap.get(spriteId) || '', type: 3 }
|
|
360
|
-
: { fileID: 0 },
|
|
361
|
-
m_Color: this.parseColor(props.color ?? '#ffffff'),
|
|
362
|
-
m_FlipX: props.flipX ? 1 : 0,
|
|
363
|
-
m_FlipY: props.flipY ? 1 : 0,
|
|
364
|
-
m_SortingLayerID: 0,
|
|
365
|
-
m_SortingOrder: props.sortingOrder ?? 0,
|
|
366
|
-
},
|
|
367
|
-
});
|
|
368
|
-
}
|
|
369
|
-
addRigidbody2D(objects, gameObjectId, props) {
|
|
370
|
-
const componentId = this.nextFileId();
|
|
371
|
-
objects.push({
|
|
372
|
-
fileID: componentId,
|
|
373
|
-
classID: 50, // Rigidbody2D
|
|
374
|
-
type: 'Rigidbody2D',
|
|
375
|
-
properties: {
|
|
376
|
-
m_GameObject: { fileID: gameObjectId },
|
|
377
|
-
m_BodyType: props.type === 'static' ? 2 : props.type === 'kinematic' ? 1 : 0,
|
|
378
|
-
m_Mass: props.mass ?? 1,
|
|
379
|
-
m_LinearDrag: props.linearDrag ?? 0,
|
|
380
|
-
m_AngularDrag: props.angularDrag ?? 0.05,
|
|
381
|
-
m_GravityScale: props.gravityScale ?? 1,
|
|
382
|
-
m_FreezeRotation: props.freezeRotation ? 1 : 0,
|
|
383
|
-
m_Interpolate: 0,
|
|
384
|
-
m_SleepingMode: 1,
|
|
385
|
-
m_CollisionDetection: 0,
|
|
386
|
-
},
|
|
387
|
-
});
|
|
121
|
+
}
|
|
122
|
+
/* ── Prefabs ────────────────────────────────────────────────── */
|
|
123
|
+
async exportPrefabs(project, _options) {
|
|
124
|
+
for (const prefab of project.prefabs) {
|
|
125
|
+
const yaml = this.createPrefabYAML(prefab, project);
|
|
126
|
+
const path = `Assets/Prefabs/${this.sanitizeFileName(prefab.name)}.prefab`;
|
|
127
|
+
this.addTextFile(path, yaml);
|
|
128
|
+
this.addTextFile(`${path}.meta`, this.createMetaFile(prefab.id));
|
|
388
129
|
}
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
130
|
+
}
|
|
131
|
+
createPrefabYAML(prefab, project) {
|
|
132
|
+
const objects = [];
|
|
133
|
+
const rootId = this.nextFileId();
|
|
134
|
+
const transformId = this.nextFileId();
|
|
135
|
+
const gameObjectId = this.nextFileId();
|
|
136
|
+
objects.push({
|
|
137
|
+
fileID: rootId,
|
|
138
|
+
classID: 1001,
|
|
139
|
+
// PrefabInstance
|
|
140
|
+
type: "PrefabInstance",
|
|
141
|
+
properties: {
|
|
142
|
+
m_ObjectHideFlags: 0,
|
|
143
|
+
m_CorrespondingSourceObject: { fileID: 0 },
|
|
144
|
+
m_PrefabInstance: { fileID: 0 },
|
|
145
|
+
m_PrefabAsset: { fileID: 0 }
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
objects.push({
|
|
149
|
+
fileID: gameObjectId,
|
|
150
|
+
classID: 1,
|
|
151
|
+
// GameObject
|
|
152
|
+
type: "GameObject",
|
|
153
|
+
properties: {
|
|
154
|
+
m_ObjectHideFlags: 0,
|
|
155
|
+
m_Name: prefab.name,
|
|
156
|
+
m_IsActive: 1,
|
|
157
|
+
m_Layer: 0,
|
|
158
|
+
m_Tag: "Untagged"
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
objects.push({
|
|
162
|
+
fileID: transformId,
|
|
163
|
+
classID: 4,
|
|
164
|
+
// Transform
|
|
165
|
+
type: "Transform",
|
|
166
|
+
properties: {
|
|
167
|
+
m_LocalRotation: { x: 0, y: 0, z: 0, w: 1 },
|
|
168
|
+
m_LocalPosition: {
|
|
169
|
+
x: prefab.entity.position?.x ?? 0,
|
|
170
|
+
y: prefab.entity.position?.y ?? 0,
|
|
171
|
+
z: 0
|
|
172
|
+
},
|
|
173
|
+
m_LocalScale: { x: prefab.entity.scale?.x ?? 1, y: prefab.entity.scale?.y ?? 1, z: 1 },
|
|
174
|
+
m_Children: [],
|
|
175
|
+
m_Father: { fileID: 0 },
|
|
176
|
+
m_RootOrder: 0
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
this.addEntityComponents(prefab.entity, objects, gameObjectId, project);
|
|
180
|
+
return this.serializeUnityYAML({ objects });
|
|
181
|
+
}
|
|
182
|
+
/* ── Scenes ─────────────────────────────────────────────────── */
|
|
183
|
+
async exportScenes(project, _options) {
|
|
184
|
+
for (const scene of project.scenes) {
|
|
185
|
+
const yaml = this.createSceneYAML(scene, project);
|
|
186
|
+
const path = `Assets/Scenes/${this.sanitizeFileName(scene.name)}.unity`;
|
|
187
|
+
this.addTextFile(path, yaml);
|
|
188
|
+
this.addTextFile(`${path}.meta`, this.createMetaFile(scene.id));
|
|
402
189
|
}
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
properties: {
|
|
410
|
-
m_GameObject: { fileID: gameObjectId },
|
|
411
|
-
m_IsTrigger: props.isTrigger ? 1 : 0,
|
|
412
|
-
m_Radius: props.radius ?? 0.5,
|
|
413
|
-
m_Offset: { x: props.offsetX ?? 0, y: props.offsetY ?? 0 },
|
|
414
|
-
},
|
|
415
|
-
});
|
|
190
|
+
}
|
|
191
|
+
createSceneYAML(scene, project) {
|
|
192
|
+
const objects = [];
|
|
193
|
+
this.addSceneSettings(objects, project);
|
|
194
|
+
for (const entity of scene.entities) {
|
|
195
|
+
this.createGameObjectHierarchy(entity, objects, project, null);
|
|
416
196
|
}
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
const audioClipId = props.clipId;
|
|
420
|
-
objects.push({
|
|
421
|
-
fileID: componentId,
|
|
422
|
-
classID: 82, // AudioSource
|
|
423
|
-
type: 'AudioSource',
|
|
424
|
-
properties: {
|
|
425
|
-
m_GameObject: { fileID: gameObjectId },
|
|
426
|
-
m_Enabled: 1,
|
|
427
|
-
m_AudioClip: audioClipId
|
|
428
|
-
? { fileID: 8300000, guid: this.guidMap.get(audioClipId) || '', type: 3 }
|
|
429
|
-
: { fileID: 0 },
|
|
430
|
-
m_PlayOnAwake: props.playOnAwake ? 1 : 0,
|
|
431
|
-
m_Loop: props.loop ? 1 : 0,
|
|
432
|
-
m_Volume: props.volume ?? 1,
|
|
433
|
-
m_Pitch: props.pitch ?? 1,
|
|
434
|
-
m_SpatialBlend: props.spatialBlend ?? 0,
|
|
435
|
-
},
|
|
436
|
-
});
|
|
197
|
+
for (const tilemap of scene.tilemaps ?? []) {
|
|
198
|
+
this.createTilemapGameObject(tilemap, objects, project);
|
|
437
199
|
}
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
200
|
+
return this.serializeUnityYAML({ objects });
|
|
201
|
+
}
|
|
202
|
+
addSceneSettings(objects, project) {
|
|
203
|
+
objects.push({
|
|
204
|
+
fileID: 1,
|
|
205
|
+
classID: 29,
|
|
206
|
+
type: "OcclusionCullingSettings",
|
|
207
|
+
properties: {}
|
|
208
|
+
});
|
|
209
|
+
const bgColor = this.parseColor(project.settings.backgroundColor);
|
|
210
|
+
objects.push({
|
|
211
|
+
fileID: 2,
|
|
212
|
+
classID: 104,
|
|
213
|
+
type: "RenderSettings",
|
|
214
|
+
properties: {
|
|
215
|
+
m_AmbientSkyColor: bgColor,
|
|
216
|
+
m_AmbientEquatorColor: bgColor,
|
|
217
|
+
m_AmbientGroundColor: bgColor
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
objects.push({
|
|
221
|
+
fileID: 3,
|
|
222
|
+
classID: 157,
|
|
223
|
+
type: "LightmapSettings",
|
|
224
|
+
properties: {}
|
|
225
|
+
});
|
|
226
|
+
objects.push({
|
|
227
|
+
fileID: 4,
|
|
228
|
+
classID: 196,
|
|
229
|
+
type: "NavMeshSettings",
|
|
230
|
+
properties: {}
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
createGameObjectHierarchy(entity, objects, project, parentTransformId) {
|
|
234
|
+
const gameObjectId = this.nextFileId();
|
|
235
|
+
const transformId = this.nextFileId();
|
|
236
|
+
objects.push({
|
|
237
|
+
fileID: gameObjectId,
|
|
238
|
+
classID: 1,
|
|
239
|
+
type: "GameObject",
|
|
240
|
+
properties: {
|
|
241
|
+
m_ObjectHideFlags: 0,
|
|
242
|
+
m_Name: entity.name,
|
|
243
|
+
m_IsActive: 1,
|
|
244
|
+
m_Layer: 0,
|
|
245
|
+
m_Tag: "Untagged"
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
const childTransformIds = [];
|
|
249
|
+
if (entity.children) {
|
|
250
|
+
for (const child of entity.children) {
|
|
251
|
+
const childTransformId = this.createGameObjectHierarchy(
|
|
252
|
+
child,
|
|
253
|
+
objects,
|
|
254
|
+
project,
|
|
255
|
+
transformId
|
|
256
|
+
);
|
|
257
|
+
childTransformIds.push(childTransformId);
|
|
258
|
+
}
|
|
456
259
|
}
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
}
|
|
260
|
+
const isRectTransform = entity.components.some(
|
|
261
|
+
(c) => c.type === "ui-text" || c.type === "ui-button" || c.type === "ui-image"
|
|
262
|
+
);
|
|
263
|
+
objects.push({
|
|
264
|
+
fileID: transformId,
|
|
265
|
+
classID: isRectTransform ? 224 : 4,
|
|
266
|
+
// RectTransform or Transform
|
|
267
|
+
type: isRectTransform ? "RectTransform" : "Transform",
|
|
268
|
+
properties: {
|
|
269
|
+
m_GameObject: { fileID: gameObjectId },
|
|
270
|
+
m_LocalRotation: {
|
|
271
|
+
x: 0,
|
|
272
|
+
y: 0,
|
|
273
|
+
z: Math.sin((entity.rotation ?? 0) / 2),
|
|
274
|
+
w: Math.cos((entity.rotation ?? 0) / 2)
|
|
275
|
+
},
|
|
276
|
+
m_LocalPosition: { x: entity.position?.x ?? 0, y: entity.position?.y ?? 0, z: 0 },
|
|
277
|
+
m_LocalScale: { x: entity.scale?.x ?? 1, y: entity.scale?.y ?? 1, z: 1 },
|
|
278
|
+
m_Children: childTransformIds.map((id) => ({ fileID: id })),
|
|
279
|
+
m_Father: parentTransformId ? { fileID: parentTransformId } : { fileID: 0 },
|
|
280
|
+
m_RootOrder: 0
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
this.addEntityComponents(entity, objects, gameObjectId, project);
|
|
284
|
+
return transformId;
|
|
285
|
+
}
|
|
286
|
+
addEntityComponents(entity, objects, gameObjectId, _project) {
|
|
287
|
+
for (const component of entity.components) {
|
|
288
|
+
const props = component.properties ?? {};
|
|
289
|
+
switch (component.type) {
|
|
290
|
+
case "sprite":
|
|
291
|
+
this.addSpriteRenderer(objects, gameObjectId, props);
|
|
292
|
+
break;
|
|
293
|
+
case "rigidbody-2d":
|
|
294
|
+
this.addRigidbody2D(objects, gameObjectId, props);
|
|
295
|
+
break;
|
|
296
|
+
case "box-collider-2d":
|
|
297
|
+
this.addBoxCollider2D(objects, gameObjectId, props);
|
|
298
|
+
break;
|
|
299
|
+
case "circle-collider-2d":
|
|
300
|
+
this.addCircleCollider2D(objects, gameObjectId, props);
|
|
301
|
+
break;
|
|
302
|
+
case "audio-source":
|
|
303
|
+
this.addAudioSource(objects, gameObjectId, props);
|
|
304
|
+
break;
|
|
305
|
+
case "animator":
|
|
306
|
+
this.addAnimator(objects, gameObjectId, props);
|
|
307
|
+
break;
|
|
308
|
+
case "ui-text":
|
|
309
|
+
this.addUIText(objects, gameObjectId, props);
|
|
310
|
+
break;
|
|
311
|
+
case "ui-image":
|
|
312
|
+
this.addUIImage(objects, gameObjectId, props);
|
|
313
|
+
break;
|
|
314
|
+
case "ui-button":
|
|
315
|
+
this.addUIButton(objects, gameObjectId, props);
|
|
316
|
+
break;
|
|
317
|
+
case "particle-system":
|
|
318
|
+
this.addParticleSystem(objects, gameObjectId, props);
|
|
319
|
+
break;
|
|
320
|
+
default:
|
|
321
|
+
this.addWarning(
|
|
322
|
+
"UNKNOWN_COMPONENT",
|
|
323
|
+
`Unknown component type "${component.type}" on entity "${entity.name}"`,
|
|
324
|
+
"Component will be skipped"
|
|
325
|
+
);
|
|
326
|
+
}
|
|
474
327
|
}
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
const spriteId = props.spriteId;
|
|
478
|
-
objects.push({
|
|
479
|
-
fileID: componentId,
|
|
480
|
-
classID: 114, // Image
|
|
481
|
-
type: 'Image',
|
|
482
|
-
properties: {
|
|
483
|
-
m_GameObject: { fileID: gameObjectId },
|
|
484
|
-
m_Enabled: 1,
|
|
485
|
-
m_Sprite: spriteId
|
|
486
|
-
? { fileID: 21300000, guid: this.guidMap.get(spriteId) || '', type: 3 }
|
|
487
|
-
: { fileID: 0 },
|
|
488
|
-
m_Color: this.parseColor(props.color ?? '#ffffff'),
|
|
489
|
-
m_RaycastTarget: props.raycastTarget !== false ? 1 : 0,
|
|
490
|
-
m_Type: props.imageType ?? 0, // Simple
|
|
491
|
-
m_FillCenter: 1,
|
|
492
|
-
m_PreserveAspect: props.preserveAspect ? 1 : 0,
|
|
493
|
-
},
|
|
494
|
-
});
|
|
328
|
+
if (entity.scriptId) {
|
|
329
|
+
this.addScriptComponent(objects, gameObjectId, entity.scriptId);
|
|
495
330
|
}
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
}
|
|
331
|
+
}
|
|
332
|
+
/* ── Component Generators ───────────────────────────────────── */
|
|
333
|
+
addSpriteRenderer(objects, gameObjectId, props) {
|
|
334
|
+
const componentId = this.nextFileId();
|
|
335
|
+
const spriteId = props.spriteId;
|
|
336
|
+
objects.push({
|
|
337
|
+
fileID: componentId,
|
|
338
|
+
classID: 212,
|
|
339
|
+
// SpriteRenderer
|
|
340
|
+
type: "SpriteRenderer",
|
|
341
|
+
properties: {
|
|
342
|
+
m_GameObject: { fileID: gameObjectId },
|
|
343
|
+
m_Enabled: 1,
|
|
344
|
+
m_Sprite: spriteId ? { fileID: 213e5, guid: this.guidMap.get(spriteId) || "", type: 3 } : { fileID: 0 },
|
|
345
|
+
m_Color: this.parseColor(props.color ?? "#ffffff"),
|
|
346
|
+
m_FlipX: props.flipX ? 1 : 0,
|
|
347
|
+
m_FlipY: props.flipY ? 1 : 0,
|
|
348
|
+
m_SortingLayerID: 0,
|
|
349
|
+
m_SortingOrder: props.sortingOrder ?? 0
|
|
350
|
+
}
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
addRigidbody2D(objects, gameObjectId, props) {
|
|
354
|
+
const componentId = this.nextFileId();
|
|
355
|
+
objects.push({
|
|
356
|
+
fileID: componentId,
|
|
357
|
+
classID: 50,
|
|
358
|
+
// Rigidbody2D
|
|
359
|
+
type: "Rigidbody2D",
|
|
360
|
+
properties: {
|
|
361
|
+
m_GameObject: { fileID: gameObjectId },
|
|
362
|
+
m_BodyType: props.type === "static" ? 2 : props.type === "kinematic" ? 1 : 0,
|
|
363
|
+
m_Mass: props.mass ?? 1,
|
|
364
|
+
m_LinearDrag: props.linearDrag ?? 0,
|
|
365
|
+
m_AngularDrag: props.angularDrag ?? 0.05,
|
|
366
|
+
m_GravityScale: props.gravityScale ?? 1,
|
|
367
|
+
m_FreezeRotation: props.freezeRotation ? 1 : 0,
|
|
368
|
+
m_Interpolate: 0,
|
|
369
|
+
m_SleepingMode: 1,
|
|
370
|
+
m_CollisionDetection: 0
|
|
371
|
+
}
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
addBoxCollider2D(objects, gameObjectId, props) {
|
|
375
|
+
const componentId = this.nextFileId();
|
|
376
|
+
objects.push({
|
|
377
|
+
fileID: componentId,
|
|
378
|
+
classID: 61,
|
|
379
|
+
// BoxCollider2D
|
|
380
|
+
type: "BoxCollider2D",
|
|
381
|
+
properties: {
|
|
382
|
+
m_GameObject: { fileID: gameObjectId },
|
|
383
|
+
m_IsTrigger: props.isTrigger ? 1 : 0,
|
|
384
|
+
m_Size: { x: props.width ?? 1, y: props.height ?? 1 },
|
|
385
|
+
m_Offset: { x: props.offsetX ?? 0, y: props.offsetY ?? 0 }
|
|
386
|
+
}
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
addCircleCollider2D(objects, gameObjectId, props) {
|
|
390
|
+
const componentId = this.nextFileId();
|
|
391
|
+
objects.push({
|
|
392
|
+
fileID: componentId,
|
|
393
|
+
classID: 58,
|
|
394
|
+
// CircleCollider2D
|
|
395
|
+
type: "CircleCollider2D",
|
|
396
|
+
properties: {
|
|
397
|
+
m_GameObject: { fileID: gameObjectId },
|
|
398
|
+
m_IsTrigger: props.isTrigger ? 1 : 0,
|
|
399
|
+
m_Radius: props.radius ?? 0.5,
|
|
400
|
+
m_Offset: { x: props.offsetX ?? 0, y: props.offsetY ?? 0 }
|
|
401
|
+
}
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
addAudioSource(objects, gameObjectId, props) {
|
|
405
|
+
const componentId = this.nextFileId();
|
|
406
|
+
const audioClipId = props.clipId;
|
|
407
|
+
objects.push({
|
|
408
|
+
fileID: componentId,
|
|
409
|
+
classID: 82,
|
|
410
|
+
// AudioSource
|
|
411
|
+
type: "AudioSource",
|
|
412
|
+
properties: {
|
|
413
|
+
m_GameObject: { fileID: gameObjectId },
|
|
414
|
+
m_Enabled: 1,
|
|
415
|
+
m_AudioClip: audioClipId ? { fileID: 83e5, guid: this.guidMap.get(audioClipId) || "", type: 3 } : { fileID: 0 },
|
|
416
|
+
m_PlayOnAwake: props.playOnAwake ? 1 : 0,
|
|
417
|
+
m_Loop: props.loop ? 1 : 0,
|
|
418
|
+
m_Volume: props.volume ?? 1,
|
|
419
|
+
m_Pitch: props.pitch ?? 1,
|
|
420
|
+
m_SpatialBlend: props.spatialBlend ?? 0
|
|
421
|
+
}
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
addAnimator(objects, gameObjectId, props) {
|
|
425
|
+
const componentId = this.nextFileId();
|
|
426
|
+
const controllerId = props.controllerId;
|
|
427
|
+
objects.push({
|
|
428
|
+
fileID: componentId,
|
|
429
|
+
classID: 95,
|
|
430
|
+
// Animator
|
|
431
|
+
type: "Animator",
|
|
432
|
+
properties: {
|
|
433
|
+
m_GameObject: { fileID: gameObjectId },
|
|
434
|
+
m_Enabled: 1,
|
|
435
|
+
m_Controller: controllerId ? { fileID: 91e5, guid: this.guidMap.get(controllerId) || "", type: 2 } : { fileID: 0 },
|
|
436
|
+
m_ApplyRootMotion: props.applyRootMotion ? 1 : 0,
|
|
437
|
+
m_UpdateMode: 0,
|
|
438
|
+
m_CullingMode: props.cullingMode ?? 0
|
|
439
|
+
}
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
addUIText(objects, gameObjectId, props) {
|
|
443
|
+
const componentId = this.nextFileId();
|
|
444
|
+
objects.push({
|
|
445
|
+
fileID: componentId,
|
|
446
|
+
classID: 114,
|
|
447
|
+
// MonoBehaviour (TextMeshProUGUI)
|
|
448
|
+
type: "MonoBehaviour",
|
|
449
|
+
properties: {
|
|
450
|
+
m_GameObject: { fileID: gameObjectId },
|
|
451
|
+
m_Enabled: 1,
|
|
452
|
+
m_Script: { fileID: 115e5, guid: "f4688fdb7df04437aeb418b961361dc5", type: 3 },
|
|
453
|
+
// TMP_Text
|
|
454
|
+
m_Text: props.text ?? "",
|
|
455
|
+
m_FontSize: props.fontSize ?? 24,
|
|
456
|
+
m_FontColor: this.parseColor(props.color ?? "#ffffff"),
|
|
457
|
+
m_TextAlignment: this.getTextAlignment(props.alignment)
|
|
458
|
+
}
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
addUIImage(objects, gameObjectId, props) {
|
|
462
|
+
const componentId = this.nextFileId();
|
|
463
|
+
const spriteId = props.spriteId;
|
|
464
|
+
objects.push({
|
|
465
|
+
fileID: componentId,
|
|
466
|
+
classID: 114,
|
|
467
|
+
// Image
|
|
468
|
+
type: "Image",
|
|
469
|
+
properties: {
|
|
470
|
+
m_GameObject: { fileID: gameObjectId },
|
|
471
|
+
m_Enabled: 1,
|
|
472
|
+
m_Sprite: spriteId ? { fileID: 213e5, guid: this.guidMap.get(spriteId) || "", type: 3 } : { fileID: 0 },
|
|
473
|
+
m_Color: this.parseColor(props.color ?? "#ffffff"),
|
|
474
|
+
m_RaycastTarget: props.raycastTarget !== false ? 1 : 0,
|
|
475
|
+
m_Type: props.imageType ?? 0,
|
|
476
|
+
// Simple
|
|
477
|
+
m_FillCenter: 1,
|
|
478
|
+
m_PreserveAspect: props.preserveAspect ? 1 : 0
|
|
479
|
+
}
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
addUIButton(objects, gameObjectId, props) {
|
|
483
|
+
const componentId = this.nextFileId();
|
|
484
|
+
objects.push({
|
|
485
|
+
fileID: componentId,
|
|
486
|
+
classID: 114,
|
|
487
|
+
// Button
|
|
488
|
+
type: "Button",
|
|
489
|
+
properties: {
|
|
490
|
+
m_GameObject: { fileID: gameObjectId },
|
|
491
|
+
m_Enabled: 1,
|
|
492
|
+
m_Interactable: props.interactable !== false ? 1 : 0,
|
|
493
|
+
m_TargetGraphic: { fileID: 0 },
|
|
494
|
+
m_OnClick: { m_PersistentCalls: { m_Calls: [] } }
|
|
495
|
+
}
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
addParticleSystem(objects, gameObjectId, props) {
|
|
499
|
+
const componentId = this.nextFileId();
|
|
500
|
+
objects.push({
|
|
501
|
+
fileID: componentId,
|
|
502
|
+
classID: 198,
|
|
503
|
+
// ParticleSystem
|
|
504
|
+
type: "ParticleSystem",
|
|
505
|
+
properties: {
|
|
506
|
+
m_GameObject: { fileID: gameObjectId },
|
|
507
|
+
m_Duration: props.duration ?? 5,
|
|
508
|
+
m_Looping: props.looping ? 1 : 0,
|
|
509
|
+
m_Prewarm: props.prewarm ? 1 : 0,
|
|
510
|
+
m_StartDelay: { value: props.startDelay ?? 0 },
|
|
511
|
+
m_PlayOnAwake: props.playOnAwake !== false ? 1 : 0,
|
|
512
|
+
m_StartSpeed: { value: props.startSpeed ?? 5 },
|
|
513
|
+
m_StartSize: { value: props.startSize ?? 1 },
|
|
514
|
+
m_StartColor: this.parseColor(props.startColor ?? "#ffffff"),
|
|
515
|
+
m_MaxParticles: props.maxParticles ?? 1e3
|
|
516
|
+
}
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
addScriptComponent(objects, gameObjectId, scriptId) {
|
|
520
|
+
const componentId = this.nextFileId();
|
|
521
|
+
const scriptGuid = this.guidMap.get(scriptId);
|
|
522
|
+
if (!scriptGuid) {
|
|
523
|
+
this.addWarning("SCRIPT_NOT_FOUND", `Script "${scriptId}" not found for entity`);
|
|
524
|
+
return;
|
|
510
525
|
}
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
526
|
+
objects.push({
|
|
527
|
+
fileID: componentId,
|
|
528
|
+
classID: 114,
|
|
529
|
+
// MonoBehaviour
|
|
530
|
+
type: "MonoBehaviour",
|
|
531
|
+
properties: {
|
|
532
|
+
m_GameObject: { fileID: gameObjectId },
|
|
533
|
+
m_Enabled: 1,
|
|
534
|
+
m_Script: { fileID: 115e5, guid: scriptGuid, type: 3 }
|
|
535
|
+
}
|
|
536
|
+
});
|
|
537
|
+
}
|
|
538
|
+
/* ── Tilemaps ───────────────────────────────────────────────── */
|
|
539
|
+
createTilemapGameObject(tilemap, objects, project) {
|
|
540
|
+
const gameObjectId = this.nextFileId();
|
|
541
|
+
const transformId = this.nextFileId();
|
|
542
|
+
const gridId = this.nextFileId();
|
|
543
|
+
objects.push({
|
|
544
|
+
fileID: gameObjectId,
|
|
545
|
+
classID: 1,
|
|
546
|
+
type: "GameObject",
|
|
547
|
+
properties: {
|
|
548
|
+
m_ObjectHideFlags: 0,
|
|
549
|
+
m_Name: tilemap.name,
|
|
550
|
+
m_IsActive: 1,
|
|
551
|
+
m_Layer: 0,
|
|
552
|
+
m_Tag: "Untagged"
|
|
553
|
+
}
|
|
554
|
+
});
|
|
555
|
+
objects.push({
|
|
556
|
+
fileID: gridId,
|
|
557
|
+
classID: 156,
|
|
558
|
+
// Grid
|
|
559
|
+
type: "Grid",
|
|
560
|
+
properties: {
|
|
561
|
+
m_GameObject: { fileID: gameObjectId },
|
|
562
|
+
m_CellSize: { x: tilemap.tileSize, y: tilemap.tileSize, z: 0 },
|
|
563
|
+
m_CellGap: { x: 0, y: 0, z: 0 },
|
|
564
|
+
m_CellLayout: 0,
|
|
565
|
+
// Rectangle
|
|
566
|
+
m_CellSwizzle: 0
|
|
567
|
+
// XYZ
|
|
568
|
+
}
|
|
569
|
+
});
|
|
570
|
+
objects.push({
|
|
571
|
+
fileID: transformId,
|
|
572
|
+
classID: 4,
|
|
573
|
+
type: "Transform",
|
|
574
|
+
properties: {
|
|
575
|
+
m_GameObject: { fileID: gameObjectId },
|
|
576
|
+
m_LocalRotation: { x: 0, y: 0, z: 0, w: 1 },
|
|
577
|
+
m_LocalPosition: { x: 0, y: 0, z: 0 },
|
|
578
|
+
m_LocalScale: { x: 1, y: 1, z: 1 },
|
|
579
|
+
m_Children: [],
|
|
580
|
+
m_Father: { fileID: 0 },
|
|
581
|
+
m_RootOrder: 0
|
|
582
|
+
}
|
|
583
|
+
});
|
|
584
|
+
for (let i = 0; i < tilemap.layers.length; i++) {
|
|
585
|
+
this.createTilemapLayer(tilemap.layers[i], tilemap, objects, transformId, project);
|
|
530
586
|
}
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
587
|
+
}
|
|
588
|
+
createTilemapLayer(layer, tilemap, objects, parentTransformId, _project) {
|
|
589
|
+
const gameObjectId = this.nextFileId();
|
|
590
|
+
const transformId = this.nextFileId();
|
|
591
|
+
const tilemapId = this.nextFileId();
|
|
592
|
+
const rendererId = this.nextFileId();
|
|
593
|
+
objects.push({
|
|
594
|
+
fileID: gameObjectId,
|
|
595
|
+
classID: 1,
|
|
596
|
+
type: "GameObject",
|
|
597
|
+
properties: {
|
|
598
|
+
m_Name: layer.name,
|
|
599
|
+
m_IsActive: layer.visible ? 1 : 0
|
|
600
|
+
}
|
|
601
|
+
});
|
|
602
|
+
objects.push({
|
|
603
|
+
fileID: transformId,
|
|
604
|
+
classID: 4,
|
|
605
|
+
type: "Transform",
|
|
606
|
+
properties: {
|
|
607
|
+
m_GameObject: { fileID: gameObjectId },
|
|
608
|
+
m_Father: { fileID: parentTransformId }
|
|
609
|
+
}
|
|
610
|
+
});
|
|
611
|
+
objects.push({
|
|
612
|
+
fileID: tilemapId,
|
|
613
|
+
classID: 156,
|
|
614
|
+
// Tilemap
|
|
615
|
+
type: "Tilemap",
|
|
616
|
+
properties: {
|
|
617
|
+
m_GameObject: { fileID: gameObjectId },
|
|
618
|
+
m_Size: { x: tilemap.width, y: tilemap.height, z: 1 },
|
|
619
|
+
m_TileAssets: [],
|
|
620
|
+
// Would reference TileBase assets
|
|
621
|
+
m_TileMatrixArray: [],
|
|
622
|
+
m_TileColorArray: []
|
|
623
|
+
}
|
|
624
|
+
});
|
|
625
|
+
objects.push({
|
|
626
|
+
fileID: rendererId,
|
|
627
|
+
classID: 156,
|
|
628
|
+
// TilemapRenderer
|
|
629
|
+
type: "TilemapRenderer",
|
|
630
|
+
properties: {
|
|
631
|
+
m_GameObject: { fileID: gameObjectId },
|
|
632
|
+
m_Enabled: 1,
|
|
633
|
+
m_SortingLayerID: 0,
|
|
634
|
+
m_SortingOrder: 0,
|
|
635
|
+
m_ChunkSize: { x: 32, y: 32, z: 1 }
|
|
636
|
+
}
|
|
637
|
+
});
|
|
638
|
+
}
|
|
639
|
+
/* ── Materials ──────────────────────────────────────────────── */
|
|
640
|
+
async exportMaterials(project, options, unity) {
|
|
641
|
+
const materials = project.assets.filter((a) => a.type === "material");
|
|
642
|
+
for (const material of materials) {
|
|
643
|
+
const matYaml = this.createMaterialYAML(material, unity?.useURP);
|
|
644
|
+
const path = `Assets/Materials/${this.sanitizeFileName(material.name)}.mat`;
|
|
645
|
+
this.addTextFile(path, matYaml);
|
|
646
|
+
this.addTextFile(`${path}.meta`, this.createMetaFile(material.id));
|
|
548
647
|
}
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
});
|
|
567
|
-
// Grid component
|
|
568
|
-
objects.push({
|
|
569
|
-
fileID: gridId,
|
|
570
|
-
classID: 156, // Grid
|
|
571
|
-
type: 'Grid',
|
|
572
|
-
properties: {
|
|
573
|
-
m_GameObject: { fileID: gameObjectId },
|
|
574
|
-
m_CellSize: { x: tilemap.tileSize, y: tilemap.tileSize, z: 0 },
|
|
575
|
-
m_CellGap: { x: 0, y: 0, z: 0 },
|
|
576
|
-
m_CellLayout: 0, // Rectangle
|
|
577
|
-
m_CellSwizzle: 0, // XYZ
|
|
578
|
-
},
|
|
579
|
-
});
|
|
580
|
-
// Transform for grid
|
|
581
|
-
objects.push({
|
|
582
|
-
fileID: transformId,
|
|
583
|
-
classID: 4,
|
|
584
|
-
type: 'Transform',
|
|
585
|
-
properties: {
|
|
586
|
-
m_GameObject: { fileID: gameObjectId },
|
|
587
|
-
m_LocalRotation: { x: 0, y: 0, z: 0, w: 1 },
|
|
588
|
-
m_LocalPosition: { x: 0, y: 0, z: 0 },
|
|
589
|
-
m_LocalScale: { x: 1, y: 1, z: 1 },
|
|
590
|
-
m_Children: [],
|
|
591
|
-
m_Father: { fileID: 0 },
|
|
592
|
-
m_RootOrder: 0,
|
|
593
|
-
},
|
|
594
|
-
});
|
|
595
|
-
// Create Tilemap layer objects
|
|
596
|
-
for (let i = 0; i < tilemap.layers.length; i++) {
|
|
597
|
-
this.createTilemapLayer(tilemap.layers[i], tilemap, objects, transformId, project);
|
|
598
|
-
}
|
|
599
|
-
}
|
|
600
|
-
createTilemapLayer(layer, tilemap, objects, parentTransformId, _project) {
|
|
601
|
-
const gameObjectId = this.nextFileId();
|
|
602
|
-
const transformId = this.nextFileId();
|
|
603
|
-
const tilemapId = this.nextFileId();
|
|
604
|
-
const rendererId = this.nextFileId();
|
|
605
|
-
// Layer GameObject
|
|
606
|
-
objects.push({
|
|
607
|
-
fileID: gameObjectId,
|
|
608
|
-
classID: 1,
|
|
609
|
-
type: 'GameObject',
|
|
610
|
-
properties: {
|
|
611
|
-
m_Name: layer.name,
|
|
612
|
-
m_IsActive: layer.visible ? 1 : 0,
|
|
613
|
-
},
|
|
614
|
-
});
|
|
615
|
-
// Transform
|
|
616
|
-
objects.push({
|
|
617
|
-
fileID: transformId,
|
|
618
|
-
classID: 4,
|
|
619
|
-
type: 'Transform',
|
|
620
|
-
properties: {
|
|
621
|
-
m_GameObject: { fileID: gameObjectId },
|
|
622
|
-
m_Father: { fileID: parentTransformId },
|
|
623
|
-
},
|
|
624
|
-
});
|
|
625
|
-
// Tilemap component
|
|
626
|
-
objects.push({
|
|
627
|
-
fileID: tilemapId,
|
|
628
|
-
classID: 156, // Tilemap
|
|
629
|
-
type: 'Tilemap',
|
|
630
|
-
properties: {
|
|
631
|
-
m_GameObject: { fileID: gameObjectId },
|
|
632
|
-
m_Size: { x: tilemap.width, y: tilemap.height, z: 1 },
|
|
633
|
-
m_TileAssets: [], // Would reference TileBase assets
|
|
634
|
-
m_TileMatrixArray: [],
|
|
635
|
-
m_TileColorArray: [],
|
|
636
|
-
},
|
|
637
|
-
});
|
|
638
|
-
// TilemapRenderer
|
|
639
|
-
objects.push({
|
|
640
|
-
fileID: rendererId,
|
|
641
|
-
classID: 156, // TilemapRenderer
|
|
642
|
-
type: 'TilemapRenderer',
|
|
643
|
-
properties: {
|
|
644
|
-
m_GameObject: { fileID: gameObjectId },
|
|
645
|
-
m_Enabled: 1,
|
|
646
|
-
m_SortingLayerID: 0,
|
|
647
|
-
m_SortingOrder: 0,
|
|
648
|
-
m_ChunkSize: { x: 32, y: 32, z: 1 },
|
|
649
|
-
},
|
|
650
|
-
});
|
|
651
|
-
}
|
|
652
|
-
/* ── Materials ──────────────────────────────────────────────── */
|
|
653
|
-
async exportMaterials(project, options, unity) {
|
|
654
|
-
const materials = project.assets.filter((a) => a.type === 'material');
|
|
655
|
-
for (const material of materials) {
|
|
656
|
-
const matYaml = this.createMaterialYAML(material, unity?.useURP);
|
|
657
|
-
const path = `Assets/Materials/${this.sanitizeFileName(material.name)}.mat`;
|
|
658
|
-
this.addTextFile(path, matYaml);
|
|
659
|
-
this.addTextFile(`${path}.meta`, this.createMetaFile(material.id));
|
|
660
|
-
}
|
|
661
|
-
}
|
|
662
|
-
createMaterialYAML(material, useURP) {
|
|
663
|
-
const shaderGuid = useURP
|
|
664
|
-
? '933532a4fcc9baf4fa0491de14d08ed7' // Universal Render Pipeline/Lit
|
|
665
|
-
: '0000000000000000f000000000000000'; // Standard
|
|
666
|
-
const color = material.metadata?.color ?? '#ffffff';
|
|
667
|
-
const rgba = this.parseColor(color);
|
|
668
|
-
return `%YAML 1.1
|
|
669
|
-
%TAG !u! tag:unity3d.com,2011:
|
|
670
|
-
--- !u!21 &2100000
|
|
671
|
-
Material:
|
|
672
|
-
serializedVersion: 8
|
|
673
|
-
m_ObjectHideFlags: 0
|
|
674
|
-
m_CorrespondingSourceObject: {fileID: 0}
|
|
675
|
-
m_PrefabInstance: {fileID: 0}
|
|
676
|
-
m_PrefabAsset: {fileID: 0}
|
|
677
|
-
m_Name: ${material.name}
|
|
678
|
-
m_Shader: {fileID: 46, guid: ${shaderGuid}, type: 2}
|
|
679
|
-
m_Parent: {fileID: 0}
|
|
648
|
+
}
|
|
649
|
+
createMaterialYAML(material, useURP) {
|
|
650
|
+
const shaderGuid = useURP ? "933532a4fcc9baf4fa0491de14d08ed7" : "0000000000000000f000000000000000";
|
|
651
|
+
const color = material.metadata?.color ?? "#ffffff";
|
|
652
|
+
const rgba = this.parseColor(color);
|
|
653
|
+
return `%YAML 1.1
|
|
654
|
+
%TAG !u! tag:unity3d.com,2011:
|
|
655
|
+
--- !u!21 &2100000
|
|
656
|
+
Material:
|
|
657
|
+
serializedVersion: 8
|
|
658
|
+
m_ObjectHideFlags: 0
|
|
659
|
+
m_CorrespondingSourceObject: {fileID: 0}
|
|
660
|
+
m_PrefabInstance: {fileID: 0}
|
|
661
|
+
m_PrefabAsset: {fileID: 0}
|
|
662
|
+
m_Name: ${material.name}
|
|
663
|
+
m_Shader: {fileID: 46, guid: ${shaderGuid}, type: 2}
|
|
664
|
+
m_Parent: {fileID: 0}
|
|
680
665
|
m_Color: ${JSON.stringify(rgba)}`;
|
|
666
|
+
}
|
|
667
|
+
/* ── Assets ─────────────────────────────────────────────────── */
|
|
668
|
+
async exportAssets(project, _options) {
|
|
669
|
+
for (const asset of project.assets) {
|
|
670
|
+
switch (asset.type) {
|
|
671
|
+
case "sprite":
|
|
672
|
+
this.exportSpriteAsset(asset);
|
|
673
|
+
break;
|
|
674
|
+
case "audio":
|
|
675
|
+
this.exportAudioAsset(asset);
|
|
676
|
+
break;
|
|
677
|
+
case "font":
|
|
678
|
+
this.exportFontAsset(asset);
|
|
679
|
+
break;
|
|
680
|
+
case "tileset":
|
|
681
|
+
this.exportTilesetAsset(asset);
|
|
682
|
+
break;
|
|
683
|
+
case "animation":
|
|
684
|
+
this.exportAnimationAsset(asset);
|
|
685
|
+
break;
|
|
686
|
+
}
|
|
681
687
|
}
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
mipmaps:
|
|
713
|
-
mipMapMode: 0
|
|
714
|
-
enableMipMap: 0
|
|
715
|
-
bumpmap:
|
|
716
|
-
convertToNormalMap: 0
|
|
717
|
-
isReadable: 0
|
|
718
|
-
streamingMipmaps: 0
|
|
719
|
-
spriteMode: 1
|
|
720
|
-
spriteExtrude: 1
|
|
721
|
-
spriteMeshType: 1
|
|
722
|
-
alignment: 0
|
|
723
|
-
spritePivot: {x: 0.5, y: 0.5}
|
|
724
|
-
spritePixelsToUnits: 100
|
|
725
|
-
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
|
726
|
-
spriteGenerateFallbackPhysicsShape: 1
|
|
727
|
-
alphaUsage: 1
|
|
728
|
-
alphaIsTransparency: 1
|
|
729
|
-
spriteTessellationDetail: -1
|
|
730
|
-
textureType: 8
|
|
731
|
-
textureShape: 1
|
|
732
|
-
filterMode: 0
|
|
733
|
-
maxTextureSize: 2048
|
|
688
|
+
}
|
|
689
|
+
exportSpriteAsset(asset) {
|
|
690
|
+
const meta = `fileFormatVersion: 2
|
|
691
|
+
guid: ${this.guidMap.get(asset.id)}
|
|
692
|
+
TextureImporter:
|
|
693
|
+
internalIDToNameTable: []
|
|
694
|
+
externalObjects: {}
|
|
695
|
+
serializedVersion: 12
|
|
696
|
+
mipmaps:
|
|
697
|
+
mipMapMode: 0
|
|
698
|
+
enableMipMap: 0
|
|
699
|
+
bumpmap:
|
|
700
|
+
convertToNormalMap: 0
|
|
701
|
+
isReadable: 0
|
|
702
|
+
streamingMipmaps: 0
|
|
703
|
+
spriteMode: 1
|
|
704
|
+
spriteExtrude: 1
|
|
705
|
+
spriteMeshType: 1
|
|
706
|
+
alignment: 0
|
|
707
|
+
spritePivot: {x: 0.5, y: 0.5}
|
|
708
|
+
spritePixelsToUnits: 100
|
|
709
|
+
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
|
710
|
+
spriteGenerateFallbackPhysicsShape: 1
|
|
711
|
+
alphaUsage: 1
|
|
712
|
+
alphaIsTransparency: 1
|
|
713
|
+
spriteTessellationDetail: -1
|
|
714
|
+
textureType: 8
|
|
715
|
+
textureShape: 1
|
|
716
|
+
filterMode: 0
|
|
717
|
+
maxTextureSize: 2048
|
|
734
718
|
textureCompression: 1`;
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
ambisonic: 0
|
|
719
|
+
const path = `Assets/Sprites/${this.sanitizeFileName(asset.name)}`;
|
|
720
|
+
this.addTextFile(`${path}.meta`, meta);
|
|
721
|
+
}
|
|
722
|
+
exportAudioAsset(asset) {
|
|
723
|
+
const meta = `fileFormatVersion: 2
|
|
724
|
+
guid: ${this.guidMap.get(asset.id)}
|
|
725
|
+
AudioImporter:
|
|
726
|
+
externalObjects: {}
|
|
727
|
+
serializedVersion: 7
|
|
728
|
+
defaultSettings:
|
|
729
|
+
loadType: 0
|
|
730
|
+
sampleRateSetting: 0
|
|
731
|
+
sampleRateOverride: 44100
|
|
732
|
+
compressionFormat: 1
|
|
733
|
+
quality: 1
|
|
734
|
+
conversionMode: 0
|
|
735
|
+
forceToMono: 0
|
|
736
|
+
normalize: 1
|
|
737
|
+
preloadAudioData: 1
|
|
738
|
+
loadInBackground: 0
|
|
739
|
+
ambisonic: 0
|
|
757
740
|
3D: 1`;
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
guid: ${this.guidMap.get(asset.id)}
|
|
764
|
-
TrueTypeFontImporter:
|
|
765
|
-
externalObjects: {}
|
|
766
|
-
serializedVersion: 4
|
|
767
|
-
fontSize: 16
|
|
768
|
-
forceTextureCase: -2
|
|
769
|
-
characterSpacing: 0
|
|
770
|
-
characterPadding: 1
|
|
771
|
-
includeFontData: 1
|
|
772
|
-
fontNames:
|
|
773
|
-
- ${asset.name}
|
|
774
|
-
fallbackFontReferences: []
|
|
775
|
-
customCharacters:
|
|
776
|
-
fontRenderingMode: 0
|
|
741
|
+
const path = `Assets/Audio/${this.sanitizeFileName(asset.name)}`;
|
|
742
|
+
this.addTextFile(`${path}.meta`, meta);
|
|
743
|
+
}
|
|
744
|
+
exportFontAsset(asset) {
|
|
745
|
+
const meta = `fileFormatVersion: 2
|
|
746
|
+
guid: ${this.guidMap.get(asset.id)}
|
|
747
|
+
TrueTypeFontImporter:
|
|
748
|
+
externalObjects: {}
|
|
749
|
+
serializedVersion: 4
|
|
750
|
+
fontSize: 16
|
|
751
|
+
forceTextureCase: -2
|
|
752
|
+
characterSpacing: 0
|
|
753
|
+
characterPadding: 1
|
|
754
|
+
includeFontData: 1
|
|
755
|
+
fontNames:
|
|
756
|
+
- ${asset.name}
|
|
757
|
+
fallbackFontReferences: []
|
|
758
|
+
customCharacters:
|
|
759
|
+
fontRenderingMode: 0
|
|
777
760
|
ascentCalculationMode: 1`;
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
m_EditorClassIdentifier:
|
|
761
|
+
const path = `Assets/Fonts/${this.sanitizeFileName(asset.name)}`;
|
|
762
|
+
this.addTextFile(`${path}.meta`, meta);
|
|
763
|
+
}
|
|
764
|
+
exportTilesetAsset(asset) {
|
|
765
|
+
const palette = `%YAML 1.1
|
|
766
|
+
%TAG !u! tag:unity3d.com,2011:
|
|
767
|
+
--- !u!114 &11400000
|
|
768
|
+
MonoBehaviour:
|
|
769
|
+
m_ObjectHideFlags: 0
|
|
770
|
+
m_Name: ${asset.name}
|
|
771
|
+
m_EditorClassIdentifier:
|
|
790
772
|
m_Tileset: {fileID: 0}`;
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
pptrCurveMapping: []
|
|
773
|
+
const path = `Assets/Tilesets/${this.sanitizeFileName(asset.name)}.asset`;
|
|
774
|
+
this.addTextFile(path, palette);
|
|
775
|
+
this.addTextFile(`${path}.meta`, this.createMetaFile(asset.id));
|
|
776
|
+
}
|
|
777
|
+
exportAnimationAsset(asset) {
|
|
778
|
+
const meta = asset.metadata || {};
|
|
779
|
+
const frameRate = meta.frameRate || 12;
|
|
780
|
+
const clip = `%YAML 1.1
|
|
781
|
+
%TAG !u! tag:unity3d.com,2011:
|
|
782
|
+
--- !u!74 &7400000
|
|
783
|
+
AnimationClip:
|
|
784
|
+
m_ObjectHideFlags: 0
|
|
785
|
+
m_Name: ${asset.name}
|
|
786
|
+
serializedVersion: 7
|
|
787
|
+
m_Legacy: 0
|
|
788
|
+
m_Compressed: 0
|
|
789
|
+
m_UseHighQualityCurve: 1
|
|
790
|
+
m_RotationCurves: []
|
|
791
|
+
m_CompressedRotationCurves: []
|
|
792
|
+
m_EulerCurves: []
|
|
793
|
+
m_PositionCurves: []
|
|
794
|
+
m_ScaleCurves: []
|
|
795
|
+
m_FloatCurves: []
|
|
796
|
+
m_PPtrCurves: []
|
|
797
|
+
m_SampleRate: ${frameRate}
|
|
798
|
+
m_WrapMode: 0
|
|
799
|
+
m_Bounds:
|
|
800
|
+
m_Center: {x: 0, y: 0, z: 0}
|
|
801
|
+
m_Extent: {x: 0, y: 0, z: 0}
|
|
802
|
+
m_ClipBindingConstant:
|
|
803
|
+
genericBindings: []
|
|
804
|
+
pptrCurveMapping: []
|
|
824
805
|
m_Events: []`;
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
using System;
|
|
853
|
-
using System.Collections;
|
|
854
|
-
using System.Collections.Generic;
|
|
855
|
-
|
|
856
|
-
namespace ${namespace}.Runtime
|
|
857
|
-
{
|
|
858
|
-
/// <summary>
|
|
859
|
-
/// Bridge between Nice2Dev runtime and Unity systems.
|
|
860
|
-
/// Auto-generated by Nice2Dev export.
|
|
861
|
-
/// </summary>
|
|
862
|
-
public static class Nice2DevBridge
|
|
863
|
-
{
|
|
864
|
-
private static Dictionary<string, GameObject> _entityMap = new();
|
|
865
|
-
private static Dictionary<string, Action<object>> _eventHandlers = new();
|
|
866
|
-
|
|
867
|
-
/// <summary>
|
|
868
|
-
/// Register an entity for cross-reference.
|
|
869
|
-
/// </summary>
|
|
870
|
-
public static void RegisterEntity(string id, GameObject obj)
|
|
871
|
-
{
|
|
872
|
-
_entityMap[id] = obj;
|
|
873
|
-
}
|
|
874
|
-
|
|
875
|
-
/// <summary>
|
|
876
|
-
/// Get entity by ID.
|
|
877
|
-
/// </summary>
|
|
878
|
-
public static GameObject GetEntity(string id)
|
|
879
|
-
{
|
|
880
|
-
return _entityMap.TryGetValue(id, out var obj) ? obj : null;
|
|
881
|
-
}
|
|
882
|
-
|
|
883
|
-
/// <summary>
|
|
884
|
-
/// Emit a custom event.
|
|
885
|
-
/// </summary>
|
|
886
|
-
public static void EmitEvent(string eventName, object data = null)
|
|
887
|
-
{
|
|
888
|
-
if (_eventHandlers.TryGetValue(eventName, out var handler))
|
|
889
|
-
{
|
|
890
|
-
handler?.Invoke(data);
|
|
891
|
-
}
|
|
892
|
-
}
|
|
893
|
-
|
|
894
|
-
/// <summary>
|
|
895
|
-
/// Subscribe to a custom event.
|
|
896
|
-
/// </summary>
|
|
897
|
-
public static void OnEvent(string eventName, Action<object> handler)
|
|
898
|
-
{
|
|
899
|
-
if (!_eventHandlers.ContainsKey(eventName))
|
|
900
|
-
{
|
|
901
|
-
_eventHandlers[eventName] = handler;
|
|
902
|
-
}
|
|
903
|
-
else
|
|
904
|
-
{
|
|
905
|
-
_eventHandlers[eventName] += handler;
|
|
906
|
-
}
|
|
907
|
-
}
|
|
908
|
-
|
|
909
|
-
/// <summary>
|
|
910
|
-
/// Unsubscribe from a custom event.
|
|
911
|
-
/// </summary>
|
|
912
|
-
public static void OffEvent(string eventName, Action<object> handler)
|
|
913
|
-
{
|
|
914
|
-
if (_eventHandlers.ContainsKey(eventName))
|
|
915
|
-
{
|
|
916
|
-
_eventHandlers[eventName] -= handler;
|
|
917
|
-
}
|
|
918
|
-
}
|
|
919
|
-
|
|
920
|
-
/// <summary>
|
|
921
|
-
/// Wait for seconds (coroutine helper).
|
|
922
|
-
/// </summary>
|
|
923
|
-
public static IEnumerator Wait(float seconds)
|
|
924
|
-
{
|
|
925
|
-
yield return new WaitForSeconds(seconds);
|
|
926
|
-
}
|
|
927
|
-
|
|
928
|
-
/// <summary>
|
|
929
|
-
/// Spawn a prefab at position.
|
|
930
|
-
/// </summary>
|
|
931
|
-
public static GameObject Spawn(GameObject prefab, Vector2 position)
|
|
932
|
-
{
|
|
933
|
-
return UnityEngine.Object.Instantiate(prefab, new Vector3(position.x, position.y, 0), Quaternion.identity);
|
|
934
|
-
}
|
|
935
|
-
|
|
936
|
-
/// <summary>
|
|
937
|
-
/// Destroy an entity.
|
|
938
|
-
/// </summary>
|
|
939
|
-
public static void Destroy(GameObject obj, float delay = 0f)
|
|
940
|
-
{
|
|
941
|
-
if (delay > 0)
|
|
942
|
-
{
|
|
943
|
-
UnityEngine.Object.Destroy(obj, delay);
|
|
944
|
-
}
|
|
945
|
-
else
|
|
946
|
-
{
|
|
947
|
-
UnityEngine.Object.Destroy(obj);
|
|
948
|
-
}
|
|
949
|
-
}
|
|
950
|
-
|
|
951
|
-
/// <summary>
|
|
952
|
-
/// Play audio clip.
|
|
953
|
-
/// </summary>
|
|
954
|
-
public static void PlaySound(AudioClip clip, float volume = 1f)
|
|
955
|
-
{
|
|
956
|
-
AudioSource.PlayClipAtPoint(clip, Camera.main.transform.position, volume);
|
|
957
|
-
}
|
|
958
|
-
|
|
959
|
-
/// <summary>
|
|
960
|
-
/// Get input axis.
|
|
961
|
-
/// </summary>
|
|
962
|
-
public static float GetAxis(string axisName)
|
|
963
|
-
{
|
|
964
|
-
return Input.GetAxis(axisName);
|
|
965
|
-
}
|
|
966
|
-
|
|
967
|
-
/// <summary>
|
|
968
|
-
/// Check if key is pressed.
|
|
969
|
-
/// </summary>
|
|
970
|
-
public static bool IsKeyPressed(KeyCode key)
|
|
971
|
-
{
|
|
972
|
-
return Input.GetKey(key);
|
|
973
|
-
}
|
|
974
|
-
|
|
975
|
-
/// <summary>
|
|
976
|
-
/// Check if key was just pressed.
|
|
977
|
-
/// </summary>
|
|
978
|
-
public static bool IsKeyJustPressed(KeyCode key)
|
|
979
|
-
{
|
|
980
|
-
return Input.GetKeyDown(key);
|
|
981
|
-
}
|
|
982
|
-
|
|
983
|
-
/// <summary>
|
|
984
|
-
/// Get mouse position in world space.
|
|
985
|
-
/// </summary>
|
|
986
|
-
public static Vector2 GetMouseWorldPosition()
|
|
987
|
-
{
|
|
988
|
-
if (Camera.main == null) return Vector2.zero;
|
|
989
|
-
return Camera.main.ScreenToWorldPoint(Input.mousePosition);
|
|
990
|
-
}
|
|
991
|
-
|
|
992
|
-
/// <summary>
|
|
993
|
-
/// Linear interpolation.
|
|
994
|
-
/// </summary>
|
|
995
|
-
public static float Lerp(float a, float b, float t)
|
|
996
|
-
{
|
|
997
|
-
return Mathf.Lerp(a, b, t);
|
|
998
|
-
}
|
|
999
|
-
|
|
1000
|
-
/// <summary>
|
|
1001
|
-
/// Random float between min and max.
|
|
1002
|
-
/// </summary>
|
|
1003
|
-
public static float Random(float min, float max)
|
|
1004
|
-
{
|
|
1005
|
-
return UnityEngine.Random.Range(min, max);
|
|
1006
|
-
}
|
|
1007
|
-
|
|
1008
|
-
/// <summary>
|
|
1009
|
-
/// Random int between min and max (exclusive).
|
|
1010
|
-
/// </summary>
|
|
1011
|
-
public static int RandomInt(int min, int max)
|
|
1012
|
-
{
|
|
1013
|
-
return UnityEngine.Random.Range(min, max);
|
|
1014
|
-
}
|
|
1015
|
-
}
|
|
1016
|
-
}`;
|
|
1017
|
-
const path = `Assets/Scripts/Runtime/Nice2DevBridge.cs`;
|
|
1018
|
-
this.addTextFile(path, bridge);
|
|
1019
|
-
this.addTextFile(`${path}.meta`, this.createScriptMetaFile('nice2dev-bridge'));
|
|
1020
|
-
}
|
|
1021
|
-
/* ── Package Manifest ───────────────────────────────────────── */
|
|
1022
|
-
exportPackageManifest(project) {
|
|
1023
|
-
// Create .unitypackage manifest
|
|
1024
|
-
const manifest = {
|
|
1025
|
-
packageName: project.name,
|
|
1026
|
-
version: project.version,
|
|
1027
|
-
exportedAt: new Date().toISOString(),
|
|
1028
|
-
files: this.files.map((f) => f.path),
|
|
1029
|
-
};
|
|
1030
|
-
this.addTextFile('package.json', JSON.stringify(manifest, null, 2));
|
|
1031
|
-
}
|
|
1032
|
-
/* ── YAML Serialization ─────────────────────────────────────── */
|
|
1033
|
-
serializeUnityYAML(yaml) {
|
|
1034
|
-
let output = `%YAML 1.1
|
|
1035
|
-
%TAG !u! tag:unity3d.com,2011:
|
|
1036
|
-
`;
|
|
1037
|
-
for (const obj of yaml.objects) {
|
|
1038
|
-
output += `--- !u!${obj.classID} &${obj.fileID}\n`;
|
|
1039
|
-
output += `${obj.type}:\n`;
|
|
1040
|
-
output += this.serializeYAMLObject(obj.properties, 1);
|
|
806
|
+
const path = `Assets/Animations/${this.sanitizeFileName(asset.name)}.anim`;
|
|
807
|
+
this.addTextFile(path, clip);
|
|
808
|
+
this.addTextFile(`${path}.meta`, this.createMetaFile(asset.id));
|
|
809
|
+
}
|
|
810
|
+
/* ── Assembly Definition ────────────────────────────────────── */
|
|
811
|
+
exportAssemblyDefinition(projectName, namespace) {
|
|
812
|
+
const asmdef = {
|
|
813
|
+
name: namespace,
|
|
814
|
+
rootNamespace: namespace,
|
|
815
|
+
references: ["Unity.TextMeshPro", "Unity.InputSystem"],
|
|
816
|
+
includePlatforms: [],
|
|
817
|
+
excludePlatforms: [],
|
|
818
|
+
allowUnsafeCode: false,
|
|
819
|
+
overrideReferences: false,
|
|
820
|
+
precompiledReferences: [],
|
|
821
|
+
autoReferenced: true,
|
|
822
|
+
defineConstraints: [],
|
|
823
|
+
versionDefines: [],
|
|
824
|
+
noEngineReferences: false
|
|
825
|
+
};
|
|
826
|
+
const path = `Assets/Scripts/${namespace}.asmdef`;
|
|
827
|
+
this.addTextFile(path, JSON.stringify(asmdef, null, 2));
|
|
828
|
+
this.addTextFile(`${path}.meta`, this.createMetaFile("asmdef"));
|
|
829
|
+
}
|
|
830
|
+
/* ── Runtime Bridge ─────────────────────────────────────────── */
|
|
831
|
+
exportRuntimeBridge(namespace) {
|
|
832
|
+
const bridge = `using UnityEngine;
|
|
833
|
+
using System;
|
|
834
|
+
using System.Collections;
|
|
835
|
+
using System.Collections.Generic;
|
|
836
|
+
|
|
837
|
+
namespace ${namespace}.Runtime
|
|
838
|
+
{
|
|
839
|
+
/// <summary>
|
|
840
|
+
/// Bridge between Nice2Dev runtime and Unity systems.
|
|
841
|
+
/// Auto-generated by Nice2Dev export.
|
|
842
|
+
/// </summary>
|
|
843
|
+
public static class Nice2DevBridge
|
|
844
|
+
{
|
|
845
|
+
private static Dictionary<string, GameObject> _entityMap = new();
|
|
846
|
+
private static Dictionary<string, Action<object>> _eventHandlers = new();
|
|
847
|
+
|
|
848
|
+
/// <summary>
|
|
849
|
+
/// Register an entity for cross-reference.
|
|
850
|
+
/// </summary>
|
|
851
|
+
public static void RegisterEntity(string id, GameObject obj)
|
|
852
|
+
{
|
|
853
|
+
_entityMap[id] = obj;
|
|
1041
854
|
}
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
855
|
+
|
|
856
|
+
/// <summary>
|
|
857
|
+
/// Get entity by ID.
|
|
858
|
+
/// </summary>
|
|
859
|
+
public static GameObject GetEntity(string id)
|
|
860
|
+
{
|
|
861
|
+
return _entityMap.TryGetValue(id, out var obj) ? obj : null;
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
/// <summary>
|
|
865
|
+
/// Emit a custom event.
|
|
866
|
+
/// </summary>
|
|
867
|
+
public static void EmitEvent(string eventName, object data = null)
|
|
868
|
+
{
|
|
869
|
+
if (_eventHandlers.TryGetValue(eventName, out var handler))
|
|
870
|
+
{
|
|
871
|
+
handler?.Invoke(data);
|
|
1050
872
|
}
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
const w = 'w' in inner ? `, w: ${inner.w}` : '';
|
|
1062
|
-
output += `${spaces}${key}: {x: ${inner.x}, y: ${inner.y}${z}${w}}\n`;
|
|
1063
|
-
}
|
|
1064
|
-
else if ('r' in inner && 'g' in inner) {
|
|
1065
|
-
output += `${spaces}${key}: {r: ${inner.r}, g: ${inner.g}, b: ${inner.b}, a: ${inner.a}}\n`;
|
|
1066
|
-
}
|
|
1067
|
-
else {
|
|
1068
|
-
output += `${spaces}${key}:\n`;
|
|
1069
|
-
output += this.serializeYAMLObject(inner, indent + 1);
|
|
1070
|
-
}
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
/// <summary>
|
|
876
|
+
/// Subscribe to a custom event.
|
|
877
|
+
/// </summary>
|
|
878
|
+
public static void OnEvent(string eventName, Action<object> handler)
|
|
879
|
+
{
|
|
880
|
+
if (!_eventHandlers.ContainsKey(eventName))
|
|
881
|
+
{
|
|
882
|
+
_eventHandlers[eventName] = handler;
|
|
1071
883
|
}
|
|
1072
|
-
else
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
}
|
|
1076
|
-
else {
|
|
1077
|
-
output += `${spaces}${key}:\n`;
|
|
1078
|
-
for (const item of value) {
|
|
1079
|
-
if (typeof item === 'object' && item !== null) {
|
|
1080
|
-
output += `${spaces}- `;
|
|
1081
|
-
const itemStr = this.serializeYAMLObject(item, indent + 1);
|
|
1082
|
-
output += itemStr.trim().replace(/\n/g, `\n${spaces} `) + '\n';
|
|
1083
|
-
}
|
|
1084
|
-
else {
|
|
1085
|
-
output += `${spaces}- ${item}\n`;
|
|
1086
|
-
}
|
|
1087
|
-
}
|
|
1088
|
-
}
|
|
884
|
+
else
|
|
885
|
+
{
|
|
886
|
+
_eventHandlers[eventName] += handler;
|
|
1089
887
|
}
|
|
1090
|
-
|
|
1091
|
-
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
/// <summary>
|
|
891
|
+
/// Unsubscribe from a custom event.
|
|
892
|
+
/// </summary>
|
|
893
|
+
public static void OffEvent(string eventName, Action<object> handler)
|
|
894
|
+
{
|
|
895
|
+
if (_eventHandlers.ContainsKey(eventName))
|
|
896
|
+
{
|
|
897
|
+
_eventHandlers[eventName] -= handler;
|
|
1092
898
|
}
|
|
1093
899
|
}
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
900
|
+
|
|
901
|
+
/// <summary>
|
|
902
|
+
/// Wait for seconds (coroutine helper).
|
|
903
|
+
/// </summary>
|
|
904
|
+
public static IEnumerator Wait(float seconds)
|
|
905
|
+
{
|
|
906
|
+
yield return new WaitForSeconds(seconds);
|
|
1100
907
|
}
|
|
1101
|
-
|
|
1102
|
-
|
|
908
|
+
|
|
909
|
+
/// <summary>
|
|
910
|
+
/// Spawn a prefab at position.
|
|
911
|
+
/// </summary>
|
|
912
|
+
public static GameObject Spawn(GameObject prefab, Vector2 position)
|
|
913
|
+
{
|
|
914
|
+
return UnityEngine.Object.Instantiate(prefab, new Vector3(position.x, position.y, 0), Quaternion.identity);
|
|
1103
915
|
}
|
|
1104
|
-
|
|
1105
|
-
|
|
916
|
+
|
|
917
|
+
/// <summary>
|
|
918
|
+
/// Destroy an entity.
|
|
919
|
+
/// </summary>
|
|
920
|
+
public static void Destroy(GameObject obj, float delay = 0f)
|
|
921
|
+
{
|
|
922
|
+
if (delay > 0)
|
|
923
|
+
{
|
|
924
|
+
UnityEngine.Object.Destroy(obj, delay);
|
|
925
|
+
}
|
|
926
|
+
else
|
|
927
|
+
{
|
|
928
|
+
UnityEngine.Object.Destroy(obj);
|
|
929
|
+
}
|
|
1106
930
|
}
|
|
1107
|
-
|
|
1108
|
-
|
|
931
|
+
|
|
932
|
+
/// <summary>
|
|
933
|
+
/// Play audio clip.
|
|
934
|
+
/// </summary>
|
|
935
|
+
public static void PlaySound(AudioClip clip, float volume = 1f)
|
|
936
|
+
{
|
|
937
|
+
AudioSource.PlayClipAtPoint(clip, Camera.main.transform.position, volume);
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
/// <summary>
|
|
941
|
+
/// Get input axis.
|
|
942
|
+
/// </summary>
|
|
943
|
+
public static float GetAxis(string axisName)
|
|
944
|
+
{
|
|
945
|
+
return Input.GetAxis(axisName);
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
/// <summary>
|
|
949
|
+
/// Check if key is pressed.
|
|
950
|
+
/// </summary>
|
|
951
|
+
public static bool IsKeyPressed(KeyCode key)
|
|
952
|
+
{
|
|
953
|
+
return Input.GetKey(key);
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
/// <summary>
|
|
957
|
+
/// Check if key was just pressed.
|
|
958
|
+
/// </summary>
|
|
959
|
+
public static bool IsKeyJustPressed(KeyCode key)
|
|
960
|
+
{
|
|
961
|
+
return Input.GetKeyDown(key);
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
/// <summary>
|
|
965
|
+
/// Get mouse position in world space.
|
|
966
|
+
/// </summary>
|
|
967
|
+
public static Vector2 GetMouseWorldPosition()
|
|
968
|
+
{
|
|
969
|
+
if (Camera.main == null) return Vector2.zero;
|
|
970
|
+
return Camera.main.ScreenToWorldPoint(Input.mousePosition);
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
/// <summary>
|
|
974
|
+
/// Linear interpolation.
|
|
975
|
+
/// </summary>
|
|
976
|
+
public static float Lerp(float a, float b, float t)
|
|
977
|
+
{
|
|
978
|
+
return Mathf.Lerp(a, b, t);
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
/// <summary>
|
|
982
|
+
/// Random float between min and max.
|
|
983
|
+
/// </summary>
|
|
984
|
+
public static float Random(float min, float max)
|
|
985
|
+
{
|
|
986
|
+
return UnityEngine.Random.Range(min, max);
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
/// <summary>
|
|
990
|
+
/// Random int between min and max (exclusive).
|
|
991
|
+
/// </summary>
|
|
992
|
+
public static int RandomInt(int min, int max)
|
|
993
|
+
{
|
|
994
|
+
return UnityEngine.Random.Range(min, max);
|
|
1109
995
|
}
|
|
1110
996
|
}
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
}
|
|
1115
|
-
|
|
1116
|
-
|
|
997
|
+
}`;
|
|
998
|
+
const path = `Assets/Scripts/Runtime/Nice2DevBridge.cs`;
|
|
999
|
+
this.addTextFile(path, bridge);
|
|
1000
|
+
this.addTextFile(`${path}.meta`, this.createScriptMetaFile("nice2dev-bridge"));
|
|
1001
|
+
}
|
|
1002
|
+
/* ── Package Manifest ───────────────────────────────────────── */
|
|
1003
|
+
exportPackageManifest(project) {
|
|
1004
|
+
const manifest = {
|
|
1005
|
+
packageName: project.name,
|
|
1006
|
+
version: project.version,
|
|
1007
|
+
exportedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1008
|
+
files: this.files.map((f) => f.path)
|
|
1009
|
+
};
|
|
1010
|
+
this.addTextFile("package.json", JSON.stringify(manifest, null, 2));
|
|
1011
|
+
}
|
|
1012
|
+
/* ── YAML Serialization ─────────────────────────────────────── */
|
|
1013
|
+
serializeUnityYAML(yaml) {
|
|
1014
|
+
let output = `%YAML 1.1
|
|
1015
|
+
%TAG !u! tag:unity3d.com,2011:
|
|
1016
|
+
`;
|
|
1017
|
+
for (const obj of yaml.objects) {
|
|
1018
|
+
output += `--- !u!${obj.classID} &${obj.fileID}
|
|
1019
|
+
`;
|
|
1020
|
+
output += `${obj.type}:
|
|
1021
|
+
`;
|
|
1022
|
+
output += this.serializeYAMLObject(obj.properties, 1);
|
|
1117
1023
|
}
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1024
|
+
return output;
|
|
1025
|
+
}
|
|
1026
|
+
serializeYAMLObject(obj, indent) {
|
|
1027
|
+
const spaces = " ".repeat(indent);
|
|
1028
|
+
let output = "";
|
|
1029
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
1030
|
+
if (value === null || value === void 0) {
|
|
1031
|
+
output += `${spaces}${key}:
|
|
1032
|
+
`;
|
|
1033
|
+
} else if (typeof value === "object" && !Array.isArray(value)) {
|
|
1034
|
+
const inner = value;
|
|
1035
|
+
if (Object.keys(inner).length === 0) {
|
|
1036
|
+
output += `${spaces}${key}: {}
|
|
1037
|
+
`;
|
|
1038
|
+
} else if ("fileID" in inner) {
|
|
1039
|
+
output += `${spaces}${key}: {fileID: ${inner.fileID}${inner.guid ? `, guid: ${inner.guid}` : ""}${inner.type ? `, type: ${inner.type}` : ""}}
|
|
1040
|
+
`;
|
|
1041
|
+
} else if ("x" in inner && "y" in inner) {
|
|
1042
|
+
const z = "z" in inner ? `, z: ${inner.z}` : "";
|
|
1043
|
+
const w = "w" in inner ? `, w: ${inner.w}` : "";
|
|
1044
|
+
output += `${spaces}${key}: {x: ${inner.x}, y: ${inner.y}${z}${w}}
|
|
1045
|
+
`;
|
|
1046
|
+
} else if ("r" in inner && "g" in inner) {
|
|
1047
|
+
output += `${spaces}${key}: {r: ${inner.r}, g: ${inner.g}, b: ${inner.b}, a: ${inner.a}}
|
|
1048
|
+
`;
|
|
1049
|
+
} else {
|
|
1050
|
+
output += `${spaces}${key}:
|
|
1051
|
+
`;
|
|
1052
|
+
output += this.serializeYAMLObject(inner, indent + 1);
|
|
1053
|
+
}
|
|
1054
|
+
} else if (Array.isArray(value)) {
|
|
1055
|
+
if (value.length === 0) {
|
|
1056
|
+
output += `${spaces}${key}: []
|
|
1057
|
+
`;
|
|
1058
|
+
} else {
|
|
1059
|
+
output += `${spaces}${key}:
|
|
1060
|
+
`;
|
|
1061
|
+
for (const item of value) {
|
|
1062
|
+
if (typeof item === "object" && item !== null) {
|
|
1063
|
+
output += `${spaces}- `;
|
|
1064
|
+
const itemStr = this.serializeYAMLObject(item, indent + 1);
|
|
1065
|
+
output += itemStr.trim().replace(/\n/g, `
|
|
1066
|
+
${spaces} `) + "\n";
|
|
1067
|
+
} else {
|
|
1068
|
+
output += `${spaces}- ${item}
|
|
1069
|
+
`;
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
} else {
|
|
1074
|
+
output += `${spaces}${key}: ${value}
|
|
1075
|
+
`;
|
|
1076
|
+
}
|
|
1125
1077
|
}
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
serializedVersion: 2
|
|
1133
|
-
defaultReferences: []
|
|
1134
|
-
executionOrder: 0
|
|
1135
|
-
icon: {instanceID: 0}`;
|
|
1078
|
+
return output;
|
|
1079
|
+
}
|
|
1080
|
+
/* ── Utility Methods ────────────────────────────────────────── */
|
|
1081
|
+
generateGuids(project) {
|
|
1082
|
+
for (const script of project.scripts) {
|
|
1083
|
+
this.guidMap.set(script.id, this.generateGUID());
|
|
1136
1084
|
}
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
const r = parseInt(clean.slice(0, 2), 16) / 255;
|
|
1140
|
-
const g = parseInt(clean.slice(2, 4), 16) / 255;
|
|
1141
|
-
const b = parseInt(clean.slice(4, 6), 16) / 255;
|
|
1142
|
-
const a = clean.length > 6 ? parseInt(clean.slice(6, 8), 16) / 255 : 1;
|
|
1143
|
-
return { r, g, b, a };
|
|
1085
|
+
for (const asset of project.assets) {
|
|
1086
|
+
this.guidMap.set(asset.id, this.generateGUID());
|
|
1144
1087
|
}
|
|
1145
|
-
|
|
1146
|
-
|
|
1088
|
+
for (const prefab of project.prefabs) {
|
|
1089
|
+
this.guidMap.set(prefab.id, this.generateGUID());
|
|
1147
1090
|
}
|
|
1148
|
-
|
|
1149
|
-
|
|
1091
|
+
for (const scene of project.scenes) {
|
|
1092
|
+
this.guidMap.set(scene.id, this.generateGUID());
|
|
1150
1093
|
}
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1094
|
+
}
|
|
1095
|
+
generateGUID() {
|
|
1096
|
+
return "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx".replace(
|
|
1097
|
+
/x/g,
|
|
1098
|
+
() => Math.floor(Math.random() * 16).toString(16)
|
|
1099
|
+
);
|
|
1100
|
+
}
|
|
1101
|
+
nextFileId() {
|
|
1102
|
+
return this.fileIdCounter++;
|
|
1103
|
+
}
|
|
1104
|
+
createMetaFile(id) {
|
|
1105
|
+
const guid = this.guidMap.get(id) || this.generateGUID();
|
|
1106
|
+
return `fileFormatVersion: 2
|
|
1107
|
+
guid: ${guid}
|
|
1108
|
+
NativeFormatImporter:
|
|
1109
|
+
externalObjects: {}
|
|
1110
|
+
mainObjectFileID: 0`;
|
|
1111
|
+
}
|
|
1112
|
+
createScriptMetaFile(scriptId) {
|
|
1113
|
+
const guid = this.guidMap.get(scriptId) || this.generateGUID();
|
|
1114
|
+
return `fileFormatVersion: 2
|
|
1115
|
+
guid: ${guid}
|
|
1116
|
+
MonoImporter:
|
|
1117
|
+
externalObjects: {}
|
|
1118
|
+
serializedVersion: 2
|
|
1119
|
+
defaultReferences: []
|
|
1120
|
+
executionOrder: 0
|
|
1121
|
+
icon: {instanceID: 0}`;
|
|
1122
|
+
}
|
|
1123
|
+
parseColor(hex) {
|
|
1124
|
+
const clean = hex.replace("#", "");
|
|
1125
|
+
const r = parseInt(clean.slice(0, 2), 16) / 255;
|
|
1126
|
+
const g = parseInt(clean.slice(2, 4), 16) / 255;
|
|
1127
|
+
const b = parseInt(clean.slice(4, 6), 16) / 255;
|
|
1128
|
+
const a = clean.length > 6 ? parseInt(clean.slice(6, 8), 16) / 255 : 1;
|
|
1129
|
+
return { r, g, b, a };
|
|
1130
|
+
}
|
|
1131
|
+
sanitizeFileName(name) {
|
|
1132
|
+
return name.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
1133
|
+
}
|
|
1134
|
+
toValidNamespace(name) {
|
|
1135
|
+
return name.replace(/[^a-zA-Z0-9]/g, "").replace(/^[0-9]/, "_$&");
|
|
1136
|
+
}
|
|
1137
|
+
getTextAlignment(alignment) {
|
|
1138
|
+
switch (alignment) {
|
|
1139
|
+
case "left":
|
|
1140
|
+
return 257;
|
|
1141
|
+
case "center":
|
|
1142
|
+
return 258;
|
|
1143
|
+
case "right":
|
|
1144
|
+
return 260;
|
|
1145
|
+
case "top-left":
|
|
1146
|
+
return 257;
|
|
1147
|
+
case "top-center":
|
|
1148
|
+
return 258;
|
|
1149
|
+
case "top-right":
|
|
1150
|
+
return 260;
|
|
1151
|
+
case "bottom-left":
|
|
1152
|
+
return 4097;
|
|
1153
|
+
case "bottom-center":
|
|
1154
|
+
return 4098;
|
|
1155
|
+
case "bottom-right":
|
|
1156
|
+
return 4100;
|
|
1157
|
+
default:
|
|
1158
|
+
return 258;
|
|
1174
1159
|
}
|
|
1160
|
+
}
|
|
1175
1161
|
}
|
|
1176
|
-
|
|
1177
1162
|
exports.UnityExporter = UnityExporter;
|