├── .gitignore ├── Assets ├── RemoteSceneMonitor.meta ├── RemoteSceneMonitor │ ├── CHANGELOG.md │ ├── CHANGELOG.md.meta │ ├── LICENSE.md │ ├── LICENSE.md.meta │ ├── PackStreamingAssets.meta │ ├── PackStreamingAssets │ │ ├── PackStreamingAssets.asset │ │ ├── PackStreamingAssets.asset.meta │ │ ├── PackStreamingAssets.data.txt │ │ └── PackStreamingAssets.data.txt.meta │ ├── Prefs.meta │ ├── Prefs │ │ ├── RemoteSceneMonitor.prefab │ │ └── RemoteSceneMonitor.prefab.meta │ ├── README.md │ ├── README.md.meta │ ├── Scenes.meta │ ├── Scenes │ │ ├── MultyScene.meta │ │ ├── MultyScene │ │ │ ├── Scene1.unity │ │ │ ├── Scene1.unity.meta │ │ │ ├── Scene2.unity │ │ │ └── Scene2.unity.meta │ │ ├── StartScene.unity │ │ └── StartScene.unity.meta │ ├── Scripts.meta │ ├── Scripts │ │ ├── Editor.meta │ │ ├── Editor │ │ │ ├── PackingInOneFileEditor.cs │ │ │ ├── PackingInOneFileEditor.cs.meta │ │ │ ├── PackingStreamingAssets.cs │ │ │ ├── PackingStreamingAssets.cs.meta │ │ │ ├── RemoteSceneMonitor.Editor.asmdef │ │ │ └── RemoteSceneMonitor.Editor.asmdef.meta │ │ ├── FileReadResult.cs │ │ ├── FileReadResult.cs.meta │ │ ├── GameObjectActionHandler.cs │ │ ├── GameObjectActionHandler.cs.meta │ │ ├── GameObjectInfo.cs │ │ ├── GameObjectInfo.cs.meta │ │ ├── HierarchyScene.meta │ │ ├── HierarchyScene │ │ │ ├── HierarchyNode.cs │ │ │ ├── HierarchyNode.cs.meta │ │ │ ├── HierarchyTools.cs │ │ │ └── HierarchyTools.cs.meta │ │ ├── Http.meta │ │ ├── Http │ │ │ ├── HttpServer.cs │ │ │ ├── HttpServer.cs.meta │ │ │ ├── HttpServerContext.cs │ │ │ ├── HttpServerContext.cs.meta │ │ │ ├── ResponseData.cs │ │ │ └── ResponseData.cs.meta │ │ ├── LogToConsoleConfig.cs │ │ ├── LogToConsoleConfig.cs.meta │ │ ├── Packing.meta │ │ ├── Packing │ │ │ ├── PackingData.cs │ │ │ ├── PackingData.cs.meta │ │ │ ├── PackingDataSerializer.cs │ │ │ ├── PackingDataSerializer.cs.meta │ │ │ ├── PackingInOneFile.cs │ │ │ └── PackingInOneFile.cs.meta │ │ ├── ReadResourceFileUtils.cs │ │ ├── ReadResourceFileUtils.cs.meta │ │ ├── RemoteSceneMonitor.asmdef │ │ ├── RemoteSceneMonitor.asmdef.meta │ │ ├── RemoteSceneMonitor.cs │ │ ├── RemoteSceneMonitor.cs.meta │ │ ├── RemoteSceneMonitorComponent.cs │ │ ├── RemoteSceneMonitorComponent.cs.meta │ │ ├── ResourceFileStorage.cs │ │ ├── ResourceFileStorage.cs.meta │ │ ├── Response.meta │ │ ├── Response │ │ │ ├── ActionResponse.cs │ │ │ ├── ActionResponse.cs.meta │ │ │ ├── FileGetResponse.cs │ │ │ ├── FileGetResponse.cs.meta │ │ │ ├── GameObjectInfoResponse.cs │ │ │ ├── GameObjectInfoResponse.cs.meta │ │ │ ├── HierarchyResponse.cs │ │ │ ├── HierarchyResponse.cs.meta │ │ │ ├── Response.cs │ │ │ ├── Response.cs.meta │ │ │ ├── ResponseFactory.cs │ │ │ └── ResponseFactory.cs.meta │ │ ├── ResponseTools.cs │ │ ├── ResponseTools.cs.meta │ │ ├── TaskLib.meta │ │ ├── TaskLib │ │ │ ├── TaskLib.cs │ │ │ ├── TaskLib.cs.meta │ │ │ ├── TaskToMainThreadAwaitable.cs │ │ │ ├── TaskToMainThreadAwaitable.cs.meta │ │ │ ├── TaskToThreadPoolAwaitable.cs │ │ │ ├── TaskToThreadPoolAwaitable.cs.meta │ │ │ ├── UnityCallbackUpdate.cs │ │ │ └── UnityCallbackUpdate.cs.meta │ │ ├── TemplateFileNames.cs │ │ ├── TemplateFileNames.cs.meta │ │ ├── TestAddGameObject.cs │ │ ├── TestAddGameObject.cs.meta │ │ ├── TreeHtmlMake.cs │ │ ├── TreeHtmlMake.cs.meta │ │ ├── Utils.meta │ │ └── Utils │ │ │ ├── PrettyJson.cs │ │ │ └── PrettyJson.cs.meta │ ├── package.json │ └── package.json.meta ├── StreamingAssets.meta └── StreamingAssets │ ├── RemoteSceneMonitorResources.meta │ └── RemoteSceneMonitorResources │ ├── favicon.ico │ ├── favicon.ico.meta │ ├── images.meta │ ├── images │ ├── object_icon.png │ ├── object_icon.png.meta │ ├── scene_icon.png │ └── scene_icon.png.meta │ ├── index.html │ ├── index.html.meta │ ├── js.meta │ ├── js │ ├── hierarchyObjects.js │ ├── hierarchyObjects.js.meta │ ├── objectsInfo.js │ ├── objectsInfo.js.meta │ ├── utils.js │ └── utils.js.meta │ ├── lib.meta │ └── lib │ ├── ztree.meta │ └── ztree │ ├── css.meta │ ├── css │ ├── awesomeStyle.meta │ ├── awesomeStyle │ │ ├── awesome.css │ │ ├── awesome.css.meta │ │ ├── awesome.less │ │ ├── awesome.less.meta │ │ ├── fa.less │ │ ├── fa.less.meta │ │ ├── img.meta │ │ └── img │ │ │ ├── loading.gif │ │ │ └── loading.gif.meta │ ├── demo.css │ ├── demo.css.meta │ ├── metroStyle.meta │ ├── metroStyle │ │ ├── img.meta │ │ ├── img │ │ │ ├── line_conn.png │ │ │ ├── line_conn.png.meta │ │ │ ├── loading.gif │ │ │ ├── loading.gif.meta │ │ │ ├── metro.gif │ │ │ ├── metro.gif.meta │ │ │ ├── metro.png │ │ │ └── metro.png.meta │ │ ├── metroStyle.css │ │ └── metroStyle.css.meta │ ├── zTreeStyle.meta │ └── zTreeStyle │ │ ├── img.meta │ │ ├── img │ │ ├── diy.meta │ │ ├── diy │ │ │ ├── 1_close.png │ │ │ ├── 1_close.png.meta │ │ │ ├── 1_open.png │ │ │ ├── 1_open.png.meta │ │ │ ├── 2.png │ │ │ ├── 2.png.meta │ │ │ ├── 3.png │ │ │ ├── 3.png.meta │ │ │ ├── 4.png │ │ │ ├── 4.png.meta │ │ │ ├── 5.png │ │ │ ├── 5.png.meta │ │ │ ├── 6.png │ │ │ ├── 6.png.meta │ │ │ ├── 7.png │ │ │ ├── 7.png.meta │ │ │ ├── 8.png │ │ │ ├── 8.png.meta │ │ │ ├── 9.png │ │ │ └── 9.png.meta │ │ ├── line_conn.gif │ │ ├── line_conn.gif.meta │ │ ├── loading.gif │ │ ├── loading.gif.meta │ │ ├── zTreeStandard.gif │ │ ├── zTreeStandard.gif.meta │ │ ├── zTreeStandard.png │ │ └── zTreeStandard.png.meta │ │ ├── zTreeStyle.css │ │ └── zTreeStyle.css.meta │ ├── js.meta │ └── js │ ├── jquery-1.4.4.min.js │ ├── jquery-1.4.4.min.js.meta │ ├── jquery.ztree.all.js │ ├── jquery.ztree.all.js.meta │ ├── jquery.ztree.all.min.js │ ├── jquery.ztree.all.min.js.meta │ ├── jquery.ztree.core.js │ ├── jquery.ztree.core.js.meta │ ├── jquery.ztree.core.min.js │ ├── jquery.ztree.core.min.js.meta │ ├── jquery.ztree.excheck.js │ ├── jquery.ztree.excheck.js.meta │ ├── jquery.ztree.excheck.min.js │ ├── jquery.ztree.excheck.min.js.meta │ ├── jquery.ztree.exedit.js │ ├── jquery.ztree.exedit.js.meta │ ├── jquery.ztree.exedit.min.js │ ├── jquery.ztree.exedit.min.js.meta │ ├── jquery.ztree.exhide.js │ ├── jquery.ztree.exhide.js.meta │ ├── jquery.ztree.exhide.min.js │ └── jquery.ztree.exhide.min.js.meta ├── Packages ├── manifest.json └── packages-lock.json ├── ProjectSettings ├── AudioManager.asset ├── ClusterInputManager.asset ├── DynamicsManager.asset ├── EditorBuildSettings.asset ├── EditorSettings.asset ├── GraphicsSettings.asset ├── InputManager.asset ├── NavMeshAreas.asset ├── PackageManagerSettings.asset ├── Physics2DSettings.asset ├── PresetManager.asset ├── ProjectSettings.asset ├── ProjectVersion.txt ├── QualitySettings.asset ├── TagManager.asset ├── TimeManager.asset ├── UnityConnectSettings.asset ├── VFXManager.asset ├── VersionControlSettings.asset └── XRSettings.asset ├── README.md ├── Screenshots ├── 0_screenshot.png ├── 1_screenshot.png ├── 2_screenshot.png └── screenshot.png └── UserSettings └── EditorUserSettings.asset /.gitignore: -------------------------------------------------------------------------------- 1 | # This .gitignore file should be placed at the root of your Unity project directory 2 | # 3 | # Get latest from https://github.com/github/gitignore/blob/master/Unity.gitignore 4 | # 5 | /[Ll]ibrary/ 6 | /[Tt]emp/ 7 | /[Oo]bj/ 8 | /[Bb]uild/ 9 | /[Bb]uilds/ 10 | /[Ll]ogs/ 11 | /[Mm]emoryCaptures/ 12 | 13 | # Asset meta data should only be ignored when the corresponding asset is also ignored 14 | !/[Aa]ssets/**/*.meta 15 | 16 | # Uncomment this line if you wish to ignore the asset store tools plugin 17 | # /[Aa]ssets/AssetStoreTools* 18 | 19 | # Autogenerated Jetbrains Rider plugin 20 | [Aa]ssets/Plugins/Editor/JetBrains* 21 | 22 | # Visual Studio cache directory 23 | .vs/ 24 | 25 | # Gradle cache directory 26 | .gradle/ 27 | 28 | # Autogenerated VS/MD/Consulo solution and project files 29 | ExportedObj/ 30 | .consulo/ 31 | *.csproj 32 | *.unityproj 33 | *.sln 34 | *.suo 35 | *.tmp 36 | *.user 37 | *.userprefs 38 | *.pidb 39 | *.booproj 40 | *.svd 41 | *.pdb 42 | *.mdb 43 | *.opendb 44 | *.VC.db 45 | 46 | # Unity3D generated meta files 47 | *.pidb.meta 48 | *.pdb.meta 49 | *.mdb.meta 50 | 51 | # Unity3D generated file on crash reports 52 | sysinfo.txt 53 | 54 | # Builds 55 | *.apk 56 | *.unitypackage 57 | 58 | # Crashlytics generated file 59 | crashlytics-build.properties 60 | 61 | .idea/ 62 | _ReSharper.Caches 63 | -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 49642b8adb1103948991fc79e4da7bd4 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/CHANGELOG.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6cecce383b0a2d346988a8e4c29ef893 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/LICENSE.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shda/RemoteSceneMonitor/06d6eeeee256a916fe0f1f04c7216b27ca84d222/Assets/RemoteSceneMonitor/LICENSE.md -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/LICENSE.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3fc6d3303adb9bd4496d9e7879b5c5ee 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/PackStreamingAssets.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4c7ae1fbebddb084797406a2ac3274dd 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/PackStreamingAssets/PackStreamingAssets.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: e8143133259c4d8db054eaaaeb848b08, type: 3} 13 | m_Name: PackStreamingAssets 14 | m_EditorClassIdentifier: 15 | packingDataAsset: {fileID: 4900000, guid: fec991ef23bdacc4690d017e7728fa57, type: 3} 16 | -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/PackStreamingAssets/PackStreamingAssets.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6af996c98b0cedf488e76a1c3f47f0f6 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/PackStreamingAssets/PackStreamingAssets.data.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fec991ef23bdacc4690d017e7728fa57 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Prefs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 163ac83332e4bd54ab43c4d14b26e70e 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Prefs/RemoteSceneMonitor.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &2871982345364197814 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | serializedVersion: 6 10 | m_Component: 11 | - component: {fileID: 2871982345364197815} 12 | - component: {fileID: 2871982345364197800} 13 | m_Layer: 0 14 | m_Name: RemoteSceneMonitor 15 | m_TagString: Untagged 16 | m_Icon: {fileID: 0} 17 | m_NavMeshLayer: 0 18 | m_StaticEditorFlags: 0 19 | m_IsActive: 1 20 | --- !u!4 &2871982345364197815 21 | Transform: 22 | m_ObjectHideFlags: 0 23 | m_CorrespondingSourceObject: {fileID: 0} 24 | m_PrefabInstance: {fileID: 0} 25 | m_PrefabAsset: {fileID: 0} 26 | m_GameObject: {fileID: 2871982345364197814} 27 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 28 | m_LocalPosition: {x: 0, y: 0, z: 0} 29 | m_LocalScale: {x: 1, y: 1, z: 1} 30 | m_Children: [] 31 | m_Father: {fileID: 0} 32 | m_RootOrder: 0 33 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 34 | --- !u!114 &2871982345364197800 35 | MonoBehaviour: 36 | m_ObjectHideFlags: 0 37 | m_CorrespondingSourceObject: {fileID: 0} 38 | m_PrefabInstance: {fileID: 0} 39 | m_PrefabAsset: {fileID: 0} 40 | m_GameObject: {fileID: 2871982345364197814} 41 | m_Enabled: 1 42 | m_EditorHideFlags: 0 43 | m_Script: {fileID: 11500000, guid: 1fb1b00cefce47a4b066b7225142ff59, type: 3} 44 | m_Name: 45 | m_EditorClassIdentifier: 46 | port: 1234 47 | packingInOneFile: {fileID: 11400000, guid: 6af996c98b0cedf488e76a1c3f47f0f6, type: 2} 48 | openBrowserAfterPressPlayEditor: 1 49 | logToConsole: 0 50 | -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Prefs/RemoteSceneMonitor.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c7ba124a5b4750148bc9b413afe1bdf3 3 | PrefabImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/README.md: -------------------------------------------------------------------------------- 1 | # Web interface for debug object to scene Unity. 2 | 3 | Features include: 4 | * list of all gameobjects in all scenes 5 | * remove gameobjects or change parents from game objects on scenes 6 | * get and change the position, rotation and scale of gameobjects -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/README.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 89d1bb8a3d775f24ba5ed5a7903d898d 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scenes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0ca74043ac8845c45b622c4cea2ed666 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scenes/MultyScene.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3cd6aac429f2bed4894b0b07227b1912 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scenes/MultyScene/Scene1.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 717aa972893592e4fb78698a5505cac6 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scenes/MultyScene/Scene2.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fb94d59033ecc254987669e9506c50e7 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scenes/StartScene.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9fc0d4010bbf28b4594072e72b8655ab 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 071ed4e025ec3bc438c6a3f0720a432c 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c7203fb38876f534185b28a8dfced0ff 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/Editor/PackingInOneFileEditor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.IO.Compression; 5 | using System.Linq; 6 | using System.Runtime.Serialization; 7 | using System.Runtime.Serialization.Formatters.Binary; 8 | using UnityEditor; 9 | using UnityEngine; 10 | 11 | namespace RemoteSceneMonitor.Scripts.Editor 12 | { 13 | public static class PackingInOneFileEditor 14 | { 15 | public static void PackingStreamingAssetsFolder(string pathToSourceFolder, string pathToOutPackingFile) 16 | { 17 | List filesInDirs = new List(); 18 | GetAllFileInFolderRecursive(filesInDirs, pathToSourceFolder, new[] {".meta"}); 19 | 20 | foreach (var filesInDir in filesInDirs) 21 | { 22 | Debug.Log(filesInDir); 23 | } 24 | 25 | PackingData packingData = new PackingData(); 26 | 27 | foreach (var filePath in filesInDirs) 28 | { 29 | string finalPath = filePath.Replace(pathToSourceFolder + "\\", "").Replace("\\", "/"); 30 | packingData.filesDictionary[finalPath] = File.ReadAllBytes(filePath); 31 | } 32 | 33 | string outString = PackingDataSerializer.SerializeToString(packingData); 34 | File.WriteAllText(pathToOutPackingFile , outString); 35 | 36 | AssetDatabase.Refresh(); 37 | } 38 | 39 | private static void GetAllFileInFolderRecursive(List allFiles, string path, string[] excludeExt) 40 | { 41 | string[] files = Directory.GetFiles(path); 42 | foreach (var file in files) 43 | { 44 | string ext = Path.GetExtension(file); 45 | if (!excludeExt.Contains(ext)) 46 | { 47 | allFiles.Add(file); 48 | } 49 | } 50 | 51 | var directories = Directory.GetDirectories(path); 52 | foreach (var directory in directories) 53 | { 54 | GetAllFileInFolderRecursive(allFiles, directory, excludeExt); 55 | } 56 | } 57 | } 58 | } -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/Editor/PackingInOneFileEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a8f0d1db2354afc489b4f9d79a660e69 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/Editor/PackingStreamingAssets.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | 3 | namespace RemoteSceneMonitor.Scripts.Editor 4 | { 5 | public static class PackingStreamingAssets 6 | { 7 | private const string PathToStreamingAssets = "Assets\\StreamingAssets\\RemoteSceneMonitorResources"; 8 | private const string PathToOutPackageFile = "Assets\\RemoteSceneMonitor\\PackStreamingAssets\\PackStreamingAssets.data.txt"; 9 | 10 | [MenuItem("PackingInOneFile/Packing streaming assets folder")] 11 | private static void PackingStreamingAssetsFolder() 12 | { 13 | PackingInOneFileEditor.PackingStreamingAssetsFolder(PathToStreamingAssets , PathToOutPackageFile); 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/Editor/PackingStreamingAssets.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 52a59f8a178d4be9b9fd142d751a31e8 3 | timeCreated: 1613036428 -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/Editor/RemoteSceneMonitor.Editor.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "SceneHierarchyInBuild.Editor", 3 | "rootNamespace": "", 4 | "references": [ 5 | "GUID:e9f1ea3ded6d30848bc63770714b7550" 6 | ], 7 | "includePlatforms": [ 8 | "Editor" 9 | ], 10 | "excludePlatforms": [], 11 | "allowUnsafeCode": false, 12 | "overrideReferences": false, 13 | "precompiledReferences": [], 14 | "autoReferenced": true, 15 | "defineConstraints": [], 16 | "versionDefines": [], 17 | "noEngineReferences": false 18 | } -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/Editor/RemoteSceneMonitor.Editor.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c397ed2e303c30543956bcc065cd426f 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/FileReadResult.cs: -------------------------------------------------------------------------------- 1 | namespace RemoteSceneMonitor 2 | { 3 | public class FileReadResult 4 | { 5 | public string text; 6 | public string error; 7 | public byte[] data; 8 | 9 | public bool IsError { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/FileReadResult.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e66c0f474db345fa9fd8f85a08aea518 3 | timeCreated: 1595772904 -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/GameObjectActionHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Specialized; 3 | using System.Threading.Tasks; 4 | using RemoteSceneMonitor.HierarchyScene; 5 | using TaskLib; 6 | using UnityEngine; 7 | 8 | namespace RemoteSceneMonitor 9 | { 10 | public class GameObjectActionHandler 11 | { 12 | public async Task ActionRequestHandler(NameValueCollection queryString) 13 | { 14 | var actionType = queryString.Get("type"); 15 | 16 | if (string.IsNullOrEmpty(actionType)) 17 | { 18 | throw new Exception("Dont find tag \"type\" in query string"); 19 | } 20 | 21 | byte[] finalArray = new byte[0]; 22 | 23 | switch (actionType) 24 | { 25 | case "delete": 26 | finalArray = await ActionDelete(queryString); 27 | break; 28 | case "move": 29 | finalArray = await ActionMove(queryString); 30 | break; 31 | case "changeTransform": 32 | finalArray = await ActionChangeTransform(queryString); 33 | break; 34 | } 35 | 36 | return finalArray; 37 | } 38 | 39 | private async Task ActionChangeTransform(NameValueCollection queryString) 40 | { 41 | var vector = new Vector3( 42 | ParseFloatString(queryString.Get("x")), 43 | ParseFloatString(queryString.Get("y")), 44 | ParseFloatString(queryString.Get("z"))); 45 | 46 | await TaskSwitcher.SwitchToMainThread(); 47 | 48 | var idGameObject = int.Parse(queryString.Get("id")); 49 | var hierarchy = HierarchyTools.GetHierarchyActiveScene(); 50 | hierarchy.gameobjectsDictonary.TryGetValue(idGameObject, out var changeGameObject); 51 | 52 | var fieldChange = queryString.Get("transformType"); 53 | switch (fieldChange) 54 | { 55 | case "position": 56 | changeGameObject.transform.position = vector; 57 | break; 58 | case "rotation": 59 | changeGameObject.transform.rotation = Quaternion.Euler(vector); 60 | break; 61 | case "scale": 62 | changeGameObject.transform.localScale = vector; 63 | break; 64 | } 65 | 66 | return ResponseTools.CreateOkResponse(); 67 | } 68 | 69 | private float ParseFloatString(string value) 70 | { 71 | value = value.Replace(".", ","); 72 | return float.Parse(value); 73 | } 74 | 75 | private async Task ActionDelete(NameValueCollection queryString) 76 | { 77 | var idString = queryString.Get("id"); 78 | if (string.IsNullOrEmpty(idString)) 79 | { 80 | throw new Exception("Dont find id in ActionDelete action"); 81 | } 82 | 83 | if (int.TryParse(idString, out var idDelete)) 84 | { 85 | await DeleteGameObjectById(idDelete); 86 | return ResponseTools.CreateOkResponse(); 87 | } 88 | 89 | return new byte[0]; 90 | } 91 | 92 | private async Task ActionMove(NameValueCollection queryString) 93 | { 94 | var idSourceString = queryString.Get("idSource"); 95 | var idDestinationString = queryString.Get("idDestination"); 96 | 97 | if (string.IsNullOrEmpty(idSourceString)) 98 | { 99 | throw new Exception("Dont find idSource in ActionMove action"); 100 | } 101 | 102 | if (string.IsNullOrEmpty(idDestinationString)) 103 | { 104 | throw new Exception("Dont find idDestination in ActionMove action"); 105 | } 106 | 107 | var idSourceInt = int.Parse(idSourceString); 108 | var idDestinationInt = int.Parse(idDestinationString); 109 | 110 | await MoveChildren(idSourceInt , idDestinationInt); 111 | 112 | return ResponseTools.CreateOkResponse(); 113 | } 114 | 115 | private async Task DeleteGameObjectById(int idDeleteObject) 116 | { 117 | await TaskSwitcher.SwitchToMainThread(); 118 | 119 | var hierarchy = HierarchyTools.GetHierarchyActiveScene(); 120 | hierarchy.gameobjectsDictonary.TryGetValue(idDeleteObject, out var deleteObject); 121 | if (deleteObject != null) 122 | { 123 | UnityEngine.Object.DestroyImmediate(deleteObject.gameObject); 124 | } 125 | } 126 | 127 | private async Task MoveChildren(int idMove, int idTarget) 128 | { 129 | await TaskSwitcher.SwitchToMainThread(); 130 | 131 | var hierarchy = HierarchyTools.GetHierarchyActiveScene(); 132 | 133 | hierarchy.gameobjectsDictonary.TryGetValue(idMove, out var moveObject); 134 | hierarchy.gameobjectsDictonary.TryGetValue(idTarget, out var targetObject); 135 | 136 | 137 | if(moveObject != null) 138 | { 139 | if (targetObject != null) 140 | { 141 | moveObject.transform.parent = targetObject.transform; 142 | } 143 | else 144 | { 145 | moveObject.transform.parent = null; 146 | } 147 | } 148 | } 149 | } 150 | } -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/GameObjectActionHandler.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4b764c33a1de4691ab0faba0134e0679 3 | timeCreated: 1596255250 -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/GameObjectInfo.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace RemoteSceneMonitor 4 | { 5 | public class GameObjectInfo 6 | { 7 | public bool activeSelf; 8 | public string name; 9 | public Vector3 position; 10 | public Vector3 rotation; 11 | public Vector3 scale; 12 | } 13 | } -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/GameObjectInfo.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9cbbd469853d4601adb3a20a42e92f66 3 | timeCreated: 1596261247 -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/HierarchyScene.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9aa9b6f8b50342a5b091561ada802f42 3 | timeCreated: 1596256414 -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/HierarchyScene/HierarchyNode.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using UnityEngine; 3 | 4 | namespace RemoteSceneMonitor.HierarchyScene 5 | { 6 | public class HierarchyNode 7 | { 8 | public bool isScene; 9 | public bool isEnable; 10 | public string name; 11 | public int id; 12 | public int pId; 13 | 14 | [JsonIgnore] 15 | public GameObject gameObject; 16 | 17 | public HierarchyNode[] children; 18 | } 19 | } -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/HierarchyScene/HierarchyNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9605e11d49d348528ca5517377825bf9 3 | timeCreated: 1595440768 -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/HierarchyScene/HierarchyTools.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using Newtonsoft.Json; 4 | using UnityEngine; 5 | using UnityEngine.SceneManagement; 6 | 7 | namespace RemoteSceneMonitor.HierarchyScene 8 | { 9 | public class SceneHierarchyData 10 | { 11 | [JsonIgnore] 12 | public Dictionary gameobjectsDictonary = new Dictionary(); 13 | public HierarchyNode[] scenesRootNodesList; 14 | } 15 | 16 | public class HierarchyTools 17 | { 18 | public static SceneHierarchyData GetHierarchyActiveScene() 19 | { 20 | var allGameObjects = new Dictionary(); 21 | var listRootScenes = new List(SceneManager.sceneCount); 22 | 23 | for (int i = 0; i < SceneManager.sceneCount; i++) 24 | { 25 | var scene = SceneManager.GetSceneAt(i); 26 | var sceneNode = GetHierarchyByScene(scene , allGameObjects); 27 | listRootScenes.Add(sceneNode); 28 | } 29 | 30 | return new SceneHierarchyData() 31 | { 32 | gameobjectsDictonary = allGameObjects, 33 | scenesRootNodesList = listRootScenes.ToArray(), 34 | }; 35 | } 36 | 37 | private static HierarchyNode GetHierarchyByScene(Scene scene , Dictionary dictObjects) 38 | { 39 | var rootObjects = scene.GetRootGameObjects(); 40 | HierarchyNode sceneNode = new HierarchyNode 41 | { 42 | isScene = true, 43 | id = -scene.buildIndex, 44 | pId = -1, 45 | gameObject = null, 46 | name = scene.name, 47 | isEnable = true, 48 | }; 49 | 50 | GetHierarchy(sceneNode , rootObjects , dictObjects); 51 | return sceneNode; 52 | } 53 | 54 | private static void GetHierarchy(HierarchyNode node , IEnumerable childGameObjects , Dictionary dictObjects) 55 | { 56 | List childNodes = new List(); 57 | 58 | if (childGameObjects != null) 59 | { 60 | foreach (var children in childGameObjects) 61 | { 62 | dictObjects[children.GetInstanceID()] = children; 63 | 64 | HierarchyNode nodeChild = new HierarchyNode() 65 | { 66 | name = children.name, 67 | gameObject = children.gameObject, 68 | id = children.GetInstanceID(), 69 | pId = node.id, 70 | isScene = false, 71 | isEnable = children.gameObject.activeSelf, 72 | }; 73 | 74 | List childChild = new List(); 75 | 76 | for (int i = 0; i < children.transform.childCount; i++) 77 | { 78 | var childTransform = children.transform.GetChild(i); 79 | childChild.Add(childTransform.gameObject); 80 | } 81 | 82 | GetHierarchy(nodeChild , childChild , dictObjects); 83 | childNodes.Add(nodeChild); 84 | } 85 | } 86 | 87 | if (childNodes.Any()) 88 | { 89 | node.children = childNodes.ToArray(); 90 | } 91 | else 92 | { 93 | node.children = null; 94 | } 95 | } 96 | } 97 | } -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/HierarchyScene/HierarchyTools.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 75a34ad905c645978d506b9ab30a465c 3 | timeCreated: 1595434722 -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/Http.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d78fe71468f74c868d4fb04516bdbf6e 3 | timeCreated: 1595456373 -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/Http/HttpServer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net; 3 | using System.Threading.Tasks; 4 | using TaskLib; 5 | using UnityEngine; 6 | using Task = System.Threading.Tasks.Task; 7 | 8 | namespace RemoteSceneMonitor.Http 9 | { 10 | public class HttpServer : IDisposable 11 | { 12 | private HttpListener _listener; 13 | private int _port; 14 | 15 | private Func> _onResponseHandler; 16 | 17 | public HttpServer(int port , Func> onResponseHandler) 18 | { 19 | _port = port; 20 | _onResponseHandler = onResponseHandler; 21 | } 22 | 23 | public void StartAsync() 24 | { 25 | WorkThreadAsync(); 26 | } 27 | 28 | private async void WorkThreadAsync() 29 | { 30 | await TaskSwitcher.SwitchToThreadPool(); 31 | 32 | try 33 | { 34 | _listener = new HttpListener(); 35 | _listener.Prefixes.Add("http://*:" + _port + "/"); 36 | _listener.Start(); 37 | 38 | while (_listener != null && _listener.IsListening) 39 | { 40 | HttpListenerContext context = await _listener.GetContextAsync(); 41 | HttpServerContext serverContext = new HttpServerContext(context); 42 | WorkHandleAsync(serverContext); 43 | } 44 | } 45 | catch (Exception ex) 46 | { 47 | //Debug.LogException(ex); 48 | } 49 | } 50 | private async void WorkHandleAsync(HttpServerContext listenerContext) 51 | { 52 | await TaskSwitcher.SwitchToThreadPool(); 53 | 54 | if (_onResponseHandler != null) 55 | { 56 | var returnHandler = await _onResponseHandler(listenerContext); 57 | 58 | HttpListenerResponse response = listenerContext.GetResponse(); 59 | byte[] buffer = returnHandler.data; 60 | response.ContentLength64 = buffer.Length; 61 | using (System.IO.Stream output = response.OutputStream) 62 | { 63 | await output.WriteAsync(buffer, 0, buffer.Length); 64 | output.Close(); 65 | } 66 | } 67 | } 68 | 69 | public void Dispose() 70 | { 71 | _listener?.Stop(); 72 | _listener?.Close(); 73 | _listener = null; 74 | } 75 | } 76 | } -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/Http/HttpServer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9ee8dc9bf75c46249af6e65b69f5560a 3 | timeCreated: 1595456363 -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/Http/HttpServerContext.cs: -------------------------------------------------------------------------------- 1 | using System.Net; 2 | 3 | namespace RemoteSceneMonitor.Http 4 | { 5 | public class HttpServerContext 6 | { 7 | public string AbsolutePath { get;} 8 | public HttpListenerContext HttpListenerContext { get;} 9 | 10 | public ResponseData ResponseData { get; set; } 11 | 12 | public HttpServerContext(HttpListenerContext httpListenerContext) 13 | { 14 | HttpListenerContext = httpListenerContext; 15 | AbsolutePath = HttpListenerContext.Request.Url.AbsolutePath; 16 | } 17 | 18 | public HttpListenerResponse GetResponse() 19 | { 20 | return HttpListenerContext.Response; 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/Http/HttpServerContext.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7f71a51f3c124ddea4ad18b269da23ef 3 | timeCreated: 1595462670 -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/Http/ResponseData.cs: -------------------------------------------------------------------------------- 1 | namespace RemoteSceneMonitor.Http 2 | { 3 | public class ResponseData 4 | { 5 | public byte[] data { get; set; } 6 | } 7 | } -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/Http/ResponseData.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ec93b3cdf45c4c2c98d2f27c8e6d09f4 3 | timeCreated: 1595778839 -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/LogToConsoleConfig.cs: -------------------------------------------------------------------------------- 1 | namespace RemoteSceneMonitor 2 | { 3 | public class LogToConsoleConfig 4 | { 5 | public static bool IsLogToConsole = true; 6 | } 7 | } -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/LogToConsoleConfig.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 64778e2a9b6e417f9cae403b336528f4 3 | timeCreated: 1598407343 -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/Packing.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: aa862a717373b3c41bba1386461a0788 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/Packing/PackingData.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace RemoteSceneMonitor 4 | { 5 | [System.Serializable] 6 | public class PackingData 7 | { 8 | public Dictionary filesDictionary = new Dictionary(); 9 | } 10 | } -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/Packing/PackingData.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 37dceae9b4b4492e8ece523cafa54840 3 | timeCreated: 1613035434 -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/Packing/PackingDataSerializer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.IO.Compression; 4 | using System.Runtime.Serialization.Formatters.Binary; 5 | 6 | namespace RemoteSceneMonitor 7 | { 8 | public static class PackingDataSerializer 9 | { 10 | public static string SerializeToString(PackingData packingData) 11 | { 12 | string outString = ""; 13 | 14 | using (var input = new MemoryStream()) 15 | { 16 | BinaryFormatter binaryFormatter = new BinaryFormatter(); 17 | binaryFormatter.Serialize(input, packingData); 18 | input.Seek(0, SeekOrigin.Begin); 19 | 20 | using (var output = new MemoryStream()) 21 | { 22 | using (var deflateStream = new DeflateStream(output, CompressionMode.Compress)) 23 | { 24 | input.CopyTo(deflateStream); 25 | deflateStream.Close(); 26 | } 27 | 28 | outString = Convert.ToBase64String(output.ToArray()); 29 | } 30 | } 31 | 32 | return outString; 33 | } 34 | 35 | public static PackingData DeserializeFromString(string text) 36 | { 37 | PackingData message = null; 38 | using (var input = new MemoryStream(Convert.FromBase64String(text))) 39 | { 40 | using (var deflateStream = new DeflateStream(input, CompressionMode.Decompress)) 41 | { 42 | using (var output = new MemoryStream()) 43 | { 44 | deflateStream.CopyTo(output); 45 | deflateStream.Close(); 46 | output.Seek(0, SeekOrigin.Begin); 47 | 48 | BinaryFormatter binaryFormatter = new BinaryFormatter(); 49 | message = (PackingData) binaryFormatter.Deserialize(output); 50 | } 51 | } 52 | } 53 | 54 | return message; 55 | } 56 | } 57 | } -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/Packing/PackingDataSerializer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fa9b5a8bc0d045a490ff00571d285e24 3 | timeCreated: 1613070217 -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/Packing/PackingInOneFile.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Runtime.Serialization; 4 | using System.Runtime.Serialization.Formatters.Binary; 5 | using UnityEngine; 6 | 7 | namespace RemoteSceneMonitor 8 | { 9 | [CreateAssetMenu(menuName = "PackingInOneFile/" + nameof(PackingInOneFile))] 10 | public class PackingInOneFile : ScriptableObject 11 | { 12 | [SerializeField] 13 | private TextAsset packingDataAsset; 14 | 15 | private string textFromAsset; 16 | private PackingData _packingData; 17 | public PackingData PackingData 18 | { 19 | get 20 | { 21 | if (_packingData == null) 22 | { 23 | lock (this) 24 | { 25 | _packingData = LoadingPackingData(); 26 | } 27 | } 28 | 29 | return _packingData; 30 | } 31 | } 32 | 33 | private void OnEnable() 34 | { 35 | textFromAsset = packingDataAsset.text; 36 | _packingData = null; 37 | } 38 | 39 | private PackingData LoadingPackingData() 40 | { 41 | var data = PackingDataSerializer.DeserializeFromString(textFromAsset); 42 | textFromAsset = ""; 43 | return data; 44 | } 45 | 46 | public byte[] GetFileBytes(string fileName) 47 | { 48 | byte[] bytes = null; 49 | PackingData?.filesDictionary.TryGetValue(fileName, out bytes); 50 | return bytes; 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/Packing/PackingInOneFile.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e8143133259c4d8db054eaaaeb848b08 3 | timeCreated: 1613033602 -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/ReadResourceFileUtils.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Threading.Tasks; 4 | using TaskLib; 5 | using UnityEngine; 6 | using UnityEngine.Networking; 7 | 8 | namespace RemoteSceneMonitor 9 | { 10 | public class ReadResourceFileUtils 11 | { 12 | private static string GetPlatformPathToStreamingAssets(string path) 13 | { 14 | string finalPath = Path.Combine(Application.streamingAssetsPath, path); 15 | 16 | if (Application.platform == RuntimePlatform.IPhonePlayer) 17 | { 18 | finalPath = "file://" + finalPath; 19 | } 20 | 21 | return finalPath; 22 | } 23 | 24 | public static async Task ReadFileFromStreamingAssetsWithPlatform(string fileName) 25 | { 26 | await TaskSwitcher.SwitchToMainThread(); 27 | 28 | var finalPath = GetPlatformPathToStreamingAssets(fileName); 29 | var fileReadResult = new FileReadResult(); 30 | 31 | UnityWebRequest loadFile = null; 32 | try 33 | { 34 | loadFile = UnityWebRequest.Get(finalPath); 35 | var asyncOperation = loadFile.SendWebRequest(); 36 | while (!asyncOperation.isDone) 37 | { 38 | await Task.Delay(25); 39 | } 40 | } 41 | catch (Exception) 42 | { 43 | fileReadResult.IsError = true; 44 | Debug.LogError($"UnityWebRequest {fileName}"); 45 | } 46 | 47 | if (loadFile != null && loadFile.isDone) 48 | { 49 | if (loadFile.isNetworkError || loadFile.isHttpError) 50 | { 51 | fileReadResult = new FileReadResult() 52 | { 53 | error = loadFile.error, 54 | IsError = true, 55 | }; 56 | } 57 | else 58 | { 59 | fileReadResult = new FileReadResult() 60 | { 61 | text = loadFile.downloadHandler.text, 62 | data = loadFile.downloadHandler.data, 63 | }; 64 | } 65 | } 66 | 67 | return fileReadResult; 68 | } 69 | } 70 | } -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/ReadResourceFileUtils.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 71b355d1bebe431dbc38324f60fd06b0 3 | timeCreated: 1595772898 -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/RemoteSceneMonitor.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "RemoteSceneMonitor", 3 | "references": [ 4 | "GUID:20b12d4d20bb6bc48b650ec2f85b57b3" 5 | ], 6 | "includePlatforms": [], 7 | "excludePlatforms": [], 8 | "allowUnsafeCode": false, 9 | "overrideReferences": false, 10 | "precompiledReferences": [], 11 | "autoReferenced": true, 12 | "defineConstraints": [], 13 | "versionDefines": [], 14 | "noEngineReferences": false 15 | } -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/RemoteSceneMonitor.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e9f1ea3ded6d30848bc63770714b7550 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/RemoteSceneMonitor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Specialized; 3 | using System.Threading.Tasks; 4 | using Newtonsoft.Json; 5 | using RemoteSceneMonitor.HierarchyScene; 6 | using RemoteSceneMonitor.Http; 7 | using TaskLib; 8 | using UnityEngine; 9 | using Debug = UnityEngine.Debug; 10 | 11 | namespace RemoteSceneMonitor 12 | { 13 | public class RemoteSceneMonitor : IDisposable 14 | { 15 | private HttpServer _httpServer; 16 | private ResponseFactory _responseFactory; 17 | private int _port; 18 | 19 | public RemoteSceneMonitor(int port, PackingInOneFile packingInOneFile) 20 | { 21 | UnityCallbackUpdate.CreateInstanceIfNeed(); 22 | 23 | _port = port; 24 | _responseFactory = new ResponseFactory(packingInOneFile); 25 | 26 | _httpServer = new HttpServer(_port ,OnResponseHandler); 27 | _httpServer.StartAsync(); 28 | } 29 | 30 | private async Task OnResponseHandler(HttpServerContext context) 31 | { 32 | ResponseData responseData = null; 33 | 34 | try 35 | { 36 | responseData = await CreateResponse(context); 37 | } 38 | catch (Exception e) 39 | { 40 | responseData = new ResponseData 41 | { 42 | data = ResponseTools.ConvertStringToResponseData(e.Message) 43 | }; 44 | Debug.LogWarning(e.Message); 45 | } 46 | 47 | return responseData; 48 | } 49 | 50 | private async Task CreateResponse(HttpServerContext context) 51 | { 52 | var pathWithoutParams = context.AbsolutePath; 53 | if(LogToConsoleConfig.IsLogToConsole) 54 | { 55 | Debug.Log(context.HttpListenerContext.Request.RawUrl); 56 | } 57 | 58 | _responseFactory.SetData(context); 59 | 60 | var response = await _responseFactory.CreateResponse(pathWithoutParams); 61 | response.SetInfo(context); 62 | return await response.MakeResponseData(); 63 | } 64 | 65 | public void Dispose() 66 | { 67 | _httpServer?.Dispose(); 68 | } 69 | } 70 | } -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/RemoteSceneMonitor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 541d25f54eac5f549859480da76aa00e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/RemoteSceneMonitorComponent.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using UnityEngine; 3 | using UnityEngine.Serialization; 4 | 5 | namespace RemoteSceneMonitor 6 | { 7 | public class RemoteSceneMonitorComponent : MonoBehaviour 8 | { 9 | [SerializeField] private int port = 1234; 10 | [SerializeField] private PackingInOneFile packingInOneFile; 11 | 12 | [Header("Debug")] [SerializeField] private bool openBrowserAfterPressPlayEditor = true; 13 | [SerializeField] private bool logToConsole = true; 14 | 15 | private RemoteSceneMonitor _remoteSceneMonitor; 16 | private static RemoteSceneMonitorComponent instance; 17 | 18 | private void Awake() 19 | { 20 | if (instance != null) 21 | { 22 | Destroy(gameObject); 23 | return; 24 | } 25 | 26 | instance = this; 27 | 28 | LogToConsoleConfig.IsLogToConsole = logToConsole; 29 | _remoteSceneMonitor = new RemoteSceneMonitor(port , packingInOneFile); 30 | 31 | #if UNITY_EDITOR 32 | if (openBrowserAfterPressPlayEditor) 33 | { 34 | Process.Start($"http://localhost:{port}"); 35 | } 36 | #endif 37 | DontDestroyOnLoad(gameObject); 38 | } 39 | 40 | 41 | private void OnDestroy() 42 | { 43 | _remoteSceneMonitor?.Dispose(); 44 | } 45 | } 46 | } -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/RemoteSceneMonitorComponent.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1fb1b00cefce47a4b066b7225142ff59 3 | timeCreated: 1596256133 -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/ResourceFileStorage.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Threading.Tasks; 3 | 4 | namespace RemoteSceneMonitor 5 | { 6 | public class ResourceFileStorage 7 | { 8 | private Dictionary _dictCatch = new Dictionary(); 9 | private string _rootResourceFolder; 10 | private PackingInOneFile _packingInOneFile; 11 | 12 | public ResourceFileStorage(string rootResourceFolder, PackingInOneFile packingInOneFile) 13 | { 14 | _rootResourceFolder = rootResourceFolder; 15 | _packingInOneFile = packingInOneFile; 16 | } 17 | 18 | public async Task ReadFileFromResource(string fileName) 19 | { 20 | FileReadResult fileResult = null; 21 | 22 | if (_packingInOneFile != null) 23 | { 24 | var data = _packingInOneFile.GetFileBytes(fileName); 25 | fileResult = new FileReadResult {data = data, IsError = data == null}; 26 | } 27 | else 28 | { 29 | string fullPath = _rootResourceFolder + "/" + fileName; 30 | 31 | fileResult = await ReadResourceFileUtils.ReadFileFromStreamingAssetsWithPlatform(fullPath); 32 | if (!fileResult.IsError) 33 | { 34 | _dictCatch[fullPath] = fileResult; 35 | } 36 | } 37 | 38 | return fileResult; 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/ResourceFileStorage.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 466fc6fccad84cc39acd50be7f1a021b 3 | timeCreated: 1595772967 -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/Response.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 557fabbb73c94730869110d9f20ee2d2 3 | timeCreated: 1598449219 -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/Response/ActionResponse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Specialized; 3 | using System.Threading.Tasks; 4 | using RemoteSceneMonitor.HierarchyScene; 5 | using RemoteSceneMonitor.Http; 6 | using TaskLib; 7 | using UnityEngine; 8 | 9 | namespace RemoteSceneMonitor 10 | { 11 | public class ActionResponse : Response 12 | { 13 | public override async Task MakeResponseData() 14 | { 15 | var queryString = context.HttpListenerContext.Request.QueryString; 16 | return new ResponseData() 17 | { 18 | data = await ActionRequestHandler(queryString) 19 | }; 20 | } 21 | 22 | public async Task ActionRequestHandler(NameValueCollection queryString) 23 | { 24 | var actionType = queryString.Get("type"); 25 | 26 | if (string.IsNullOrEmpty(actionType)) 27 | { 28 | throw new Exception("Dont find tag \"type\" in query string"); 29 | } 30 | 31 | byte[] finalArray = new byte[0]; 32 | 33 | switch (actionType) 34 | { 35 | case "delete": 36 | finalArray = await ActionDelete(queryString); 37 | break; 38 | case "move": 39 | finalArray = await ActionMove(queryString); 40 | break; 41 | case "changeTransform": 42 | finalArray = await ActionChangeTransform(queryString); 43 | break; 44 | case "changeEnableGameObject": 45 | finalArray = await ActionChangeEnableGameObject(queryString); 46 | break; 47 | } 48 | 49 | return finalArray; 50 | } 51 | 52 | private async Task ActionChangeEnableGameObject(NameValueCollection queryString) 53 | { 54 | await TaskSwitcher.SwitchToMainThread(); 55 | 56 | bool activeGameObject = ParseStringToBool(queryString.Get("activeSelf")); 57 | var changeGameObject = GetGameObjectById(queryString.Get("id")); 58 | 59 | changeGameObject.SetActive(activeGameObject); 60 | 61 | return ResponseTools.CreateOkResponse(); 62 | } 63 | 64 | private async Task ActionChangeTransform(NameValueCollection queryString) 65 | { 66 | var vector = new Vector3( 67 | ParseStringToFloat(queryString.Get("x")), 68 | ParseStringToFloat(queryString.Get("y")), 69 | ParseStringToFloat(queryString.Get("z"))); 70 | 71 | await TaskSwitcher.SwitchToMainThread(); 72 | 73 | var changeGameObject = GetGameObjectById(queryString.Get("id")); 74 | 75 | var fieldChange = queryString.Get("transformType"); 76 | switch (fieldChange) 77 | { 78 | case "position": 79 | changeGameObject.transform.position = vector; 80 | break; 81 | case "rotation": 82 | changeGameObject.transform.rotation = Quaternion.Euler(vector); 83 | break; 84 | case "scale": 85 | changeGameObject.transform.localScale = vector; 86 | break; 87 | } 88 | 89 | return ResponseTools.CreateOkResponse(); 90 | } 91 | 92 | private GameObject GetGameObjectById(string id) 93 | { 94 | return GetGameObjectById(int.Parse(id)); 95 | } 96 | 97 | private GameObject GetGameObjectById(int id) 98 | { 99 | var hierarchy = HierarchyTools.GetHierarchyActiveScene(); 100 | hierarchy.gameobjectsDictonary.TryGetValue(id, out var changeGameObject); 101 | return changeGameObject; 102 | } 103 | 104 | private bool ParseStringToBool(string value) 105 | { 106 | return bool.Parse(value); 107 | } 108 | 109 | private float ParseStringToFloat(string value) 110 | { 111 | value = value.Replace(".", ","); 112 | return float.Parse(value); 113 | } 114 | 115 | private async Task ActionDelete(NameValueCollection queryString) 116 | { 117 | var idString = queryString.Get("id"); 118 | if (string.IsNullOrEmpty(idString)) 119 | { 120 | throw new Exception("Dont find id in ActionDelete action"); 121 | } 122 | 123 | if (int.TryParse(idString, out var idDelete)) 124 | { 125 | await DeleteGameObjectById(idDelete); 126 | return ResponseTools.CreateOkResponse(); 127 | } 128 | 129 | return new byte[0]; 130 | } 131 | 132 | private async Task ActionMove(NameValueCollection queryString) 133 | { 134 | var idSourceString = queryString.Get("idSource"); 135 | var idDestinationString = queryString.Get("idDestination"); 136 | 137 | if (string.IsNullOrEmpty(idSourceString)) 138 | { 139 | throw new Exception("Dont find idSource in ActionMove action"); 140 | } 141 | 142 | if (string.IsNullOrEmpty(idDestinationString)) 143 | { 144 | throw new Exception("Dont find idDestination in ActionMove action"); 145 | } 146 | 147 | var idSourceInt = int.Parse(idSourceString); 148 | var idDestinationInt = int.Parse(idDestinationString); 149 | 150 | await MoveChildren(idSourceInt , idDestinationInt); 151 | 152 | return ResponseTools.CreateOkResponse(); 153 | } 154 | 155 | private async Task DeleteGameObjectById(int idDeleteObject) 156 | { 157 | await TaskSwitcher.SwitchToMainThread(); 158 | 159 | var hierarchy = HierarchyTools.GetHierarchyActiveScene(); 160 | hierarchy.gameobjectsDictonary.TryGetValue(idDeleteObject, out var deleteObject); 161 | if (deleteObject != null) 162 | { 163 | UnityEngine.Object.DestroyImmediate(deleteObject.gameObject); 164 | } 165 | } 166 | 167 | private async Task MoveChildren(int idMove, int idTarget) 168 | { 169 | await TaskSwitcher.SwitchToMainThread(); 170 | 171 | var hierarchy = HierarchyTools.GetHierarchyActiveScene(); 172 | 173 | hierarchy.gameobjectsDictonary.TryGetValue(idMove, out var moveObject); 174 | hierarchy.gameobjectsDictonary.TryGetValue(idTarget, out var targetObject); 175 | 176 | 177 | if(moveObject != null) 178 | { 179 | if (targetObject != null) 180 | { 181 | moveObject.transform.parent = targetObject.transform; 182 | } 183 | else 184 | { 185 | moveObject.transform.parent = null; 186 | } 187 | } 188 | } 189 | } 190 | } -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/Response/ActionResponse.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 348ed57df0ab4802a187513afa3fcd1b 3 | timeCreated: 1598450503 -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/Response/FileGetResponse.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using RemoteSceneMonitor.Http; 3 | using UnityEngine; 4 | 5 | namespace RemoteSceneMonitor 6 | { 7 | public class FileGetResponse : Response 8 | { 9 | private ResourceFileStorage _resourceFileStorage; 10 | 11 | public FileGetResponse(ResourceFileStorage resourceFileStorage) 12 | { 13 | _resourceFileStorage = resourceFileStorage; 14 | } 15 | 16 | public override async Task MakeResponseData() 17 | { 18 | var pathWithoutParams = context.AbsolutePath; 19 | ResponseData responseData = new ResponseData(); 20 | 21 | string filePath = pathWithoutParams.Remove(0, 1); 22 | 23 | if (string.IsNullOrEmpty(filePath)) 24 | { 25 | filePath = "index.html"; 26 | } 27 | 28 | FileReadResult fileReadResult = await _resourceFileStorage.ReadFileFromResource(filePath); 29 | 30 | if (!fileReadResult.IsError) 31 | { 32 | responseData.data = fileReadResult.data; 33 | } 34 | else 35 | { 36 | Debug.LogError($"Error load file - {filePath}"); 37 | responseData.data = ResponseTools.ConvertStringToResponseData($"Error load file {filePath}"); 38 | } 39 | 40 | return responseData; 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/Response/FileGetResponse.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: edfb21290b0c4e20ba753114de27256f 3 | timeCreated: 1598451345 -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/Response/GameObjectInfoResponse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | using Newtonsoft.Json; 4 | using RemoteSceneMonitor.HierarchyScene; 5 | using RemoteSceneMonitor.Http; 6 | using TaskLib; 7 | using UnityEngine; 8 | 9 | namespace RemoteSceneMonitor 10 | { 11 | public class GameObjectInfoResponse : Response 12 | { 13 | private SceneHierarchyData _sceneHierarchyData; 14 | 15 | public GameObjectInfoResponse(SceneHierarchyData sceneHierarchyData) 16 | { 17 | _sceneHierarchyData = sceneHierarchyData; 18 | } 19 | 20 | public override async Task MakeResponseData() 21 | { 22 | var idString = context.HttpListenerContext.Request.QueryString.Get("id"); 23 | 24 | if (string.IsNullOrEmpty(idString)) 25 | { 26 | throw new Exception("Dont find tag \"id\" in query string"); 27 | } 28 | 29 | var idInt = int.Parse(idString); 30 | byte[] finalArray = new byte[0]; 31 | 32 | if (_sceneHierarchyData == null) 33 | { 34 | _sceneHierarchyData = HierarchyTools.GetHierarchyActiveScene(); 35 | } 36 | 37 | if (_sceneHierarchyData.gameobjectsDictonary.TryGetValue(idInt, out GameObject go)) 38 | { 39 | await TaskSwitcher.SwitchToMainThread(); 40 | 41 | Vector3 position = go.transform.position; 42 | Vector3 rotation = go.transform.rotation.eulerAngles; 43 | Vector3 scale = go.transform.localScale; 44 | 45 | 46 | GameObjectInfo objectInfo = new GameObjectInfo() 47 | { 48 | activeSelf = go.activeSelf, 49 | name = go.name, 50 | position = position, 51 | rotation = rotation, 52 | scale = scale, 53 | }; 54 | 55 | var json = JsonConvert.SerializeObject(objectInfo , Formatting.Indented , new JsonSerializerSettings() { 56 | ReferenceLoopHandling = ReferenceLoopHandling.Ignore 57 | }); 58 | finalArray = ResponseTools.ConvertStringToResponseData(json); 59 | 60 | if (LogToConsoleConfig.IsLogToConsole) 61 | { 62 | Debug.Log(json); 63 | } 64 | } 65 | else 66 | { 67 | throw new Exception("Dont find id object " + idInt); 68 | } 69 | 70 | return new ResponseData() 71 | { 72 | data = finalArray, 73 | }; 74 | } 75 | } 76 | } -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/Response/GameObjectInfoResponse.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a4bd25201d674052905ea84a3f9fa676 3 | timeCreated: 1598450322 -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/Response/HierarchyResponse.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using Newtonsoft.Json; 3 | using RemoteSceneMonitor.HierarchyScene; 4 | using RemoteSceneMonitor.Http; 5 | 6 | namespace RemoteSceneMonitor 7 | { 8 | public class HierarchyResponse : Response 9 | { 10 | private SceneHierarchyData _sceneHierarchyData; 11 | public HierarchyResponse(SceneHierarchyData sceneHierarchyData) 12 | { 13 | _sceneHierarchyData = sceneHierarchyData; 14 | } 15 | 16 | public override async Task MakeResponseData() 17 | { 18 | if (_sceneHierarchyData == null) 19 | { 20 | _sceneHierarchyData = HierarchyTools.GetHierarchyActiveScene(); 21 | } 22 | 23 | var json = JsonConvert.SerializeObject(_sceneHierarchyData , Formatting.Indented); 24 | return new ResponseData() 25 | { 26 | data = ResponseTools.ConvertStringToResponseData(json) 27 | }; 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/Response/HierarchyResponse.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3e8b75460f0d4c7c934ba9f4a730dca2 3 | timeCreated: 1598449231 -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/Response/Response.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using RemoteSceneMonitor.HierarchyScene; 3 | using RemoteSceneMonitor.Http; 4 | 5 | namespace RemoteSceneMonitor 6 | { 7 | public abstract class Response 8 | { 9 | protected HttpServerContext context; 10 | 11 | public void SetInfo(HttpServerContext context) 12 | { 13 | this.context = context; 14 | } 15 | 16 | public virtual async Task MakeResponseData() 17 | { 18 | return null; 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/Response/Response.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ecc96f393ed44de5b0a4e3324b3cc6ef 3 | timeCreated: 1598449251 -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/Response/ResponseFactory.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using RemoteSceneMonitor.HierarchyScene; 3 | using RemoteSceneMonitor.Http; 4 | using TaskLib; 5 | 6 | namespace RemoteSceneMonitor 7 | { 8 | public class ResponseFactory 9 | { 10 | private const string RootResourceFolder = "RemoteSceneMonitorResources"; 11 | 12 | private SceneHierarchyData _sceneHierarchyData; 13 | private HttpServerContext _context; 14 | private ResourceFileStorage _resourceFileStorage; 15 | 16 | public ResponseFactory(PackingInOneFile packingInOneFile = null) 17 | { 18 | _resourceFileStorage = new ResourceFileStorage(RootResourceFolder , packingInOneFile); 19 | } 20 | 21 | public void SetData(HttpServerContext context) 22 | { 23 | _context = context; 24 | } 25 | 26 | public async Task CreateResponse(string pathWithoutParams) 27 | { 28 | Response response = null; 29 | 30 | if(pathWithoutParams.StartsWith("/json/hierarchy")) 31 | { 32 | await TaskSwitcher.SwitchToMainThread(); 33 | _sceneHierarchyData = HierarchyTools.GetHierarchyActiveScene(); 34 | response = new HierarchyResponse(_sceneHierarchyData); 35 | } 36 | else if(pathWithoutParams.StartsWith("/action")) 37 | { 38 | response = new ActionResponse(); 39 | } 40 | else if (pathWithoutParams.StartsWith("/gameObjectInfo")) 41 | { 42 | response = new GameObjectInfoResponse(_sceneHierarchyData); 43 | } 44 | else 45 | { 46 | response = new FileGetResponse(_resourceFileStorage); 47 | } 48 | 49 | response?.SetInfo(_context); 50 | return response; 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/Response/ResponseFactory.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 86d7cb62c4e441e19fd4053366cee4d0 3 | timeCreated: 1598450630 -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/ResponseTools.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | 3 | namespace RemoteSceneMonitor 4 | { 5 | public static class ResponseTools 6 | { 7 | public static byte[] CreateOkResponse() 8 | { 9 | return ConvertStringToResponseData("200"); 10 | } 11 | 12 | public static byte[] ConvertStringToResponseData(string text) 13 | { 14 | return Encoding.UTF8.GetBytes(text);; 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/ResponseTools.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1146e615983d4ecabfd2b824de2927e6 3 | timeCreated: 1596255265 -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/TaskLib.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 29af2736853e40347883ff23f9bc4172 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/TaskLib/TaskLib.cs: -------------------------------------------------------------------------------- 1 | namespace TaskLib 2 | { 3 | public static class TaskSwitcher 4 | { 5 | public static TaskToMainThreadAwaitable SwitchToMainThread() 6 | { 7 | return new TaskToMainThreadAwaitable(); 8 | } 9 | 10 | public static TaskToThreadPoolAwaitable SwitchToThreadPool() 11 | { 12 | return new TaskToThreadPoolAwaitable(); 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/TaskLib/TaskLib.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7a2ede6660a04a5db9e77f075ec8a956 3 | timeCreated: 1605659973 -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/TaskLib/TaskToMainThreadAwaitable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.CompilerServices; 3 | using System.Threading; 4 | 5 | namespace TaskLib 6 | { 7 | public struct TaskToMainThreadAwaitable 8 | { 9 | readonly CancellationToken cancellationToken; 10 | 11 | public TaskToMainThreadAwaitable(CancellationToken cancellationToken) 12 | { 13 | this.cancellationToken = cancellationToken; 14 | } 15 | 16 | public Awaiter GetAwaiter() => new Awaiter(cancellationToken); 17 | 18 | public struct Awaiter : ICriticalNotifyCompletion 19 | { 20 | readonly CancellationToken cancellationToken; 21 | 22 | public Awaiter(CancellationToken cancellationToken) 23 | { 24 | this.cancellationToken = cancellationToken; 25 | } 26 | 27 | public bool IsCompleted => false; 28 | 29 | public void GetResult() { cancellationToken.ThrowIfCancellationRequested(); } 30 | 31 | public void OnCompleted(Action continuation) 32 | { 33 | UnityCallbackUpdate.AddListener(continuation); 34 | } 35 | 36 | public void UnsafeOnCompleted(Action continuation) 37 | { 38 | UnityCallbackUpdate.AddListener(continuation); 39 | } 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/TaskLib/TaskToMainThreadAwaitable.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7ade89a5f89143b1985e9ef693d02633 3 | timeCreated: 1605657919 -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/TaskLib/TaskToThreadPoolAwaitable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.CompilerServices; 3 | using System.Threading; 4 | 5 | namespace TaskLib 6 | { 7 | public struct TaskToThreadPoolAwaitable 8 | { 9 | public Awaiter GetAwaiter() => new Awaiter(); 10 | 11 | public struct Awaiter : ICriticalNotifyCompletion 12 | { 13 | static readonly WaitCallback switchToCallback = Callback; 14 | 15 | public bool IsCompleted => false; 16 | 17 | public void GetResult() 18 | { 19 | } 20 | 21 | public void OnCompleted(Action continuation) 22 | { 23 | ThreadPool.QueueUserWorkItem(switchToCallback, continuation); 24 | } 25 | 26 | public void UnsafeOnCompleted(Action continuation) 27 | { 28 | ThreadPool.UnsafeQueueUserWorkItem(switchToCallback, continuation); 29 | } 30 | 31 | static void Callback(object state) 32 | { 33 | var continuation = (Action) state; 34 | continuation(); 35 | } 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/TaskLib/TaskToThreadPoolAwaitable.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0a8051c0673f4dd78d7038d2d70bba9c 3 | timeCreated: 1605659522 -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/TaskLib/UnityCallbackUpdate.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace TaskLib 6 | { 7 | public class UnityCallbackUpdate : MonoBehaviour 8 | { 9 | private static Stack listListeners = new Stack(); 10 | private static UnityCallbackUpdate instance; 11 | 12 | public static void AddListener(Action OnUpdate) 13 | { 14 | CreateInstanceIfNeed(); 15 | lock (listListeners) 16 | { 17 | listListeners.Push(OnUpdate); 18 | } 19 | } 20 | 21 | public static void CreateInstanceIfNeed() 22 | { 23 | if (instance == null) 24 | { 25 | GameObject updater = new GameObject("UnityCallbackUpdate"); 26 | DontDestroyOnLoad(updater); 27 | instance = updater.AddComponent(); 28 | } 29 | } 30 | void Update() 31 | { 32 | if (listListeners == null) 33 | return; 34 | 35 | try 36 | { 37 | Action[] arrayActions = null; 38 | lock (listListeners) 39 | { 40 | arrayActions = listListeners.ToArray(); 41 | listListeners.Clear(); 42 | } 43 | 44 | foreach (var listListener in arrayActions) 45 | { 46 | try 47 | { 48 | listListener?.Invoke(); 49 | } 50 | catch (Exception e) 51 | { 52 | UnityEngine.Debug.LogException(e); 53 | } 54 | } 55 | } 56 | catch (Exception e) 57 | { 58 | 59 | } 60 | } 61 | } 62 | } -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/TaskLib/UnityCallbackUpdate.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0efcff7fdc484175b3f368dcd5762bf8 3 | timeCreated: 1605658304 -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/TemplateFileNames.cs: -------------------------------------------------------------------------------- 1 | namespace RemoteSceneMonitor 2 | { 3 | public static class TemplateFileNames 4 | { 5 | public const string treeHtmlFile = "treeHtmlFile"; 6 | } 7 | } -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/TemplateFileNames.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2b6e41a513fa416683a70ba9838ceca3 3 | timeCreated: 1595441839 -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/TestAddGameObject.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace RemoteSceneMonitor 4 | { 5 | public class TestAddGameObject : MonoBehaviour 6 | { 7 | public void OnAddGameObject() 8 | { 9 | GameObject newGameObject = GameObject.CreatePrimitive(PrimitiveType.Cube); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/TestAddGameObject.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 878a5e06aadf0a949867fd501bc0b635 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/TreeHtmlMake.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using System.Text; 3 | using RemoteSceneMonitor.HierarchyScene; 4 | using UnityEngine; 5 | 6 | namespace RemoteSceneMonitor 7 | { 8 | public static class TreeHtmlMake 9 | { 10 | public static string InsertCodeInHtml(HierarchyNode rootNode , string templateHtml) 11 | { 12 | string treeHtml = CreateHtmlTree(rootNode); 13 | return templateHtml.Replace("{treeview_insert}", treeHtml); 14 | } 15 | 16 | private static string CreateHtmlTree(HierarchyNode rootNode) 17 | { 18 | StringBuilder finalHtml = new StringBuilder(); 19 | finalHtml.Append("
    "); 20 | { 21 | CreateHtmlNode(rootNode , finalHtml); 22 | } 23 | 24 | finalHtml.Append("
"); 25 | return finalHtml.ToString(); 26 | } 27 | 28 | private static void CreateHtmlNode(HierarchyNode node , StringBuilder sb) 29 | { 30 | StringBuilder nodeBuilder = new StringBuilder(); 31 | 32 | bool isDisable = node.gameObject == null || !node.gameObject.activeInHierarchy; 33 | Color colorLine = Color.black; 34 | 35 | if (isDisable) 36 | { 37 | colorLine = Color.gray; 38 | } 39 | 40 | string colorLineHtml = ColorUtility.ToHtmlStringRGB(colorLine); 41 | 42 | string nameObject = node.name; 43 | int id = node.id; 44 | string startLine = $"
  • " + 45 | $"
    " + 46 | $"

    " + 47 | $"" + 48 | $"{nameObject}" + 49 | $"

    " + 50 | $"
    "; 51 | 52 | /* 53 | if (node.gameObject == null || !node.gameObject.activeInHierarchy) 54 | { 55 | startLine = $"
  • {node.name}"; 56 | } 57 | */ 58 | 59 | nodeBuilder.Append(startLine); 60 | { 61 | if (node.children.Any()) 62 | { 63 | nodeBuilder.AppendLine("
      "); 64 | { 65 | foreach (var hierarchyNode in node.children) 66 | { 67 | CreateHtmlNode(hierarchyNode , nodeBuilder); 68 | } 69 | } 70 | nodeBuilder.AppendLine("
    "); 71 | } 72 | } 73 | nodeBuilder.Append($"
  • "); 74 | sb.AppendLine(nodeBuilder.ToString()); 75 | } 76 | } 77 | } -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/TreeHtmlMake.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d1b69685d35349c68f71912b45ab128a 3 | timeCreated: 1595443202 -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/Utils.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b0ad95b7fdf122e4ca3c348db4d1f0b1 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/Utils/PrettyJson.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace RemoteSceneMonitor.Utils 7 | { 8 | public static class PrettyJson 9 | { 10 | private const string INDENT_STRING = " "; 11 | 12 | public static string FormatJson(string str) 13 | { 14 | if (string.IsNullOrEmpty(str)) 15 | return str; 16 | 17 | #if !UNITY_EDITOR 18 | return str; 19 | #endif 20 | var indent = 0; 21 | var quoted = false; 22 | var sb = new StringBuilder(); 23 | 24 | for (var i = 0; i < str.Length; i++) 25 | { 26 | var ch = str[i]; 27 | switch (ch) 28 | { 29 | case '{': 30 | case '[': 31 | sb.Append(ch); 32 | if (!quoted) 33 | { 34 | sb.AppendLine(); 35 | Enumerable.Range(0, ++indent).ForEach(item => sb.Append(INDENT_STRING)); 36 | } 37 | 38 | break; 39 | case '}': 40 | case ']': 41 | if (!quoted) 42 | { 43 | sb.AppendLine(); 44 | Enumerable.Range(0, --indent).ForEach(item => sb.Append(INDENT_STRING)); 45 | } 46 | 47 | sb.Append(ch); 48 | break; 49 | case '"': 50 | sb.Append(ch); 51 | var escaped = false; 52 | var index = i; 53 | while (index > 0 && str[--index] == '\\') 54 | escaped = !escaped; 55 | if (!escaped) 56 | quoted = !quoted; 57 | break; 58 | case ',': 59 | sb.Append(ch); 60 | if (!quoted) 61 | { 62 | sb.AppendLine(); 63 | Enumerable.Range(0, indent).ForEach(item => sb.Append(INDENT_STRING)); 64 | } 65 | 66 | break; 67 | case ':': 68 | sb.Append(ch); 69 | if (!quoted) 70 | sb.Append(" "); 71 | break; 72 | default: 73 | sb.Append(ch); 74 | break; 75 | } 76 | } 77 | 78 | return sb.ToString(); 79 | } 80 | 81 | private static void ForEach(this IEnumerable enumeration, Action action) 82 | { 83 | foreach (var item in enumeration) 84 | { 85 | action(item); 86 | } 87 | 88 | } 89 | } 90 | } -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/Scripts/Utils/PrettyJson.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7a14b6efb8269ad479bfac9b99020046 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "com.shda.remote-scene-monitor", 3 | "displayName": "RemoteSceneMonitor", 4 | "version": "0.1.4", 5 | "unity": "2019.2", 6 | "keywords": [ 7 | "Debug" 8 | ], 9 | "description": "Web interface for debug object to scene Unity.", 10 | "dependencies": { 11 | "com.unity.nuget.newtonsoft-json": "2.0.0" 12 | } 13 | } -------------------------------------------------------------------------------- /Assets/RemoteSceneMonitor/package.json.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7559e88e20031d641b204aca549ee988 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/StreamingAssets.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 36fe914497c209f459e7b216edd442fd 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/StreamingAssets/RemoteSceneMonitorResources.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2fd9c87c0d7cc9e42be3e7f7312dee35 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/StreamingAssets/RemoteSceneMonitorResources/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shda/RemoteSceneMonitor/06d6eeeee256a916fe0f1f04c7216b27ca84d222/Assets/StreamingAssets/RemoteSceneMonitorResources/favicon.ico -------------------------------------------------------------------------------- /Assets/StreamingAssets/RemoteSceneMonitorResources/favicon.ico.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5c5a57aa5d138c7449e646d9932ce3df 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/StreamingAssets/RemoteSceneMonitorResources/images.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 072b6066c2799404499a03b17b461d3f 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/StreamingAssets/RemoteSceneMonitorResources/images/object_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shda/RemoteSceneMonitor/06d6eeeee256a916fe0f1f04c7216b27ca84d222/Assets/StreamingAssets/RemoteSceneMonitorResources/images/object_icon.png -------------------------------------------------------------------------------- /Assets/StreamingAssets/RemoteSceneMonitorResources/images/object_icon.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 36816f20c21d33547aa35aaa107e20d0 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/StreamingAssets/RemoteSceneMonitorResources/images/scene_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shda/RemoteSceneMonitor/06d6eeeee256a916fe0f1f04c7216b27ca84d222/Assets/StreamingAssets/RemoteSceneMonitorResources/images/scene_icon.png -------------------------------------------------------------------------------- /Assets/StreamingAssets/RemoteSceneMonitorResources/images/scene_icon.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1bf3185ea614a414495726eeba2eaae5 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/StreamingAssets/RemoteSceneMonitorResources/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Remote scene monitor 5 | 6 | 7 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 51 | 52 | 53 | 54 | 55 | 56 | 57 |

    58 | 61 | 62 | 92 | 93 | 94 | 95 |
    59 |
      60 |
      63 | 64 | 65 | 66 | 67 |

      68 | 69 |

      70 | 71 |

      72 | 73 |
      74 | 75 | 76 |
      77 | 78 |
      79 | 80 | 81 |
      82 | 83 |
      84 | 85 | 86 |
      87 | 88 | 89 | 90 |
      91 |
      96 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /Assets/StreamingAssets/RemoteSceneMonitorResources/index.html.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3aacd43363b0b0d43945a4e6d6932c20 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/StreamingAssets/RemoteSceneMonitorResources/js.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fafa4e7c11b76c6478de5e6fd11776e8 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/StreamingAssets/RemoteSceneMonitorResources/js/hierarchyObjects.js: -------------------------------------------------------------------------------- 1 | var zTree; 2 | var demoIframe; 3 | 4 | var setting = { 5 | view: { 6 | dblClickExpand: false, 7 | showLine: true, 8 | selectedMulti: false, 9 | 10 | fontCss: getFont, 11 | nameIsHTML: true 12 | }, 13 | data: { 14 | simpleData: { 15 | enable: true, 16 | idKey: "id", 17 | pIdKey: "pId", 18 | rootPId: "" 19 | } 20 | }, 21 | edit: { 22 | enable: true, 23 | showRemoveBtn: showRemoveBtn, 24 | showRenameBtn: false, 25 | drag: { 26 | isCopy: false, 27 | isMove: true, 28 | prev: true, 29 | iner: true, 30 | next: true, 31 | } 32 | }, 33 | callback: { 34 | beforeClick: beforeClick, 35 | beforeDrag: beforeDrag, 36 | beforeDrop: beforeDrop, 37 | 38 | onRemove: onRemove, 39 | 40 | onCollapse: onCollapse, 41 | onExpand: onExpand, 42 | } 43 | }; 44 | 45 | var openNodes = new Set(); 46 | 47 | function getFont(treeId, node) { 48 | return node.font ? node.font : {}; 49 | } 50 | 51 | function onCollapse(event, treeId, treeNode) { 52 | openNodes.delete(treeNode.id); 53 | } 54 | 55 | function showRemoveBtn(treeId, treeNode){ 56 | return treeNode.drag; 57 | } 58 | 59 | function onExpand(event, treeId, treeNode) { 60 | openNodes.add(treeNode.id); 61 | } 62 | 63 | function beforeClick(treeId, treeNode) 64 | { 65 | var zTree = $.fn.zTree.getZTreeObj("tree"); 66 | if (treeNode.isParent) { 67 | ShowDataToGameObjectById(treeNode.id); 68 | return false; 69 | } else { 70 | ShowDataToGameObjectById(treeNode.id); 71 | return true; 72 | } 73 | } 74 | 75 | function onRemove(e, treeId, treeNode) { 76 | 77 | var url = CreateAction({ 78 | type : "delete", 79 | id : treeNode.id 80 | }); 81 | 82 | var xhr = new XMLHttpRequest(); 83 | xhr.open('GET', url); 84 | xhr.send(); 85 | xhr.onload = function() { 86 | ReloadTree(); 87 | } 88 | } 89 | 90 | function CreateAction(dataParams){ 91 | return "/action?" + CreateParams(dataParams); 92 | } 93 | 94 | function CreateParams(dataParams){ 95 | return new URLSearchParams(dataParams); 96 | } 97 | 98 | function beforeDrag(treeId, treeNodes) { 99 | for (var i=0,l=treeNodes.length; i")},showNode:function(e,i,o){h.isHidden(e,i,!1),h.initShowForExCheck(e,i),d(i,e).show()},showNodes:function(e,i,o){if(i&&0!=i.length){var d,t,n={};for(d=0,t=i.length;d