├── .gitignore
├── LICENSE
├── README.md
├── client
└── unity
│ ├── Assets
│ ├── Libraries.meta
│ ├── Libraries
│ │ ├── websocket-sharp.dll
│ │ └── websocket-sharp.dll.meta
│ ├── Scenes.meta
│ ├── Scenes
│ │ ├── NetworkModel.meta
│ │ └── NetworkModel
│ │ │ ├── ExampleScene.unity
│ │ │ └── ExampleScene.unity.meta
│ ├── Scripts.meta
│ └── Scripts
│ │ ├── NetworkModel.meta
│ │ └── NetworkModel
│ │ ├── Dependency.meta
│ │ ├── Dependency
│ │ ├── AbstractInjector.cs
│ │ ├── AbstractInjector.cs.meta
│ │ ├── Injector.cs
│ │ └── Injector.cs.meta
│ │ ├── Editor.meta
│ │ ├── Editor
│ │ ├── ConfigurationEditor.cs
│ │ ├── ConfigurationEditor.cs.meta
│ │ ├── RuleEditor.cs
│ │ └── RuleEditor.cs.meta
│ │ ├── Enum.meta
│ │ ├── Enum
│ │ ├── Extension.meta
│ │ ├── Extension
│ │ │ ├── RuleTypeExtension.cs
│ │ │ └── RuleTypeExtension.cs.meta
│ │ ├── LogType.cs
│ │ ├── LogType.cs.meta
│ │ ├── RuleType.cs
│ │ ├── RuleType.cs.meta
│ │ ├── UpdateType.cs
│ │ └── UpdateType.cs.meta
│ │ ├── Model.meta
│ │ ├── Model
│ │ ├── Component.meta
│ │ ├── Component
│ │ │ ├── AbstractComponent.cs
│ │ │ ├── AbstractComponent.cs.meta
│ │ │ ├── BoxColliderSerializable.cs
│ │ │ ├── BoxColliderSerializable.cs.meta
│ │ │ ├── CameraSerializable.cs
│ │ │ ├── CameraSerializable.cs.meta
│ │ │ ├── LightSerializable.cs
│ │ │ ├── LightSerializable.cs.meta
│ │ │ ├── LineRendererSerializable.cs
│ │ │ ├── LineRendererSerializable.cs.meta
│ │ │ ├── MeshColliderSerializable.cs
│ │ │ ├── MeshColliderSerializable.cs.meta
│ │ │ ├── MeshFilterSerializable.cs
│ │ │ ├── MeshFilterSerializable.cs.meta
│ │ │ ├── MeshRendererSerializable.cs
│ │ │ ├── MeshRendererSerializable.cs.meta
│ │ │ ├── ScriptSerializable.cs
│ │ │ ├── ScriptSerializable.cs.meta
│ │ │ ├── SphereColliderSerializable.cs
│ │ │ ├── SphereColliderSerializable.cs.meta
│ │ │ ├── TransformSerializable.cs
│ │ │ └── TransformSerializable.cs.meta
│ │ ├── Model.cs
│ │ ├── Model.cs.meta
│ │ ├── Resource.meta
│ │ ├── Resource
│ │ │ ├── AbstractResource.cs
│ │ │ ├── AbstractResource.cs.meta
│ │ │ ├── MaterialSerializable.cs
│ │ │ ├── MaterialSerializable.cs.meta
│ │ │ ├── MeshSerializable.cs
│ │ │ ├── MeshSerializable.cs.meta
│ │ │ ├── Texture2DSerializable.cs
│ │ │ └── Texture2DSerializable.cs.meta
│ │ ├── Serializer.cs
│ │ ├── Serializer.cs.meta
│ │ ├── Store.meta
│ │ ├── Store
│ │ │ ├── ObjectNode.cs
│ │ │ ├── ObjectNode.cs.meta
│ │ │ ├── ObjectStore.cs
│ │ │ ├── ObjectStore.cs.meta
│ │ │ ├── ResourceNode.cs
│ │ │ ├── ResourceNode.cs.meta
│ │ │ ├── ResourceStore.cs
│ │ │ └── ResourceStore.cs.meta
│ │ ├── Struct.meta
│ │ ├── Struct
│ │ │ ├── HierarchyUpdate.cs
│ │ │ ├── HierarchyUpdate.cs.meta
│ │ │ ├── NameTypePair.cs
│ │ │ └── NameTypePair.cs.meta
│ │ ├── Subscriptions.cs
│ │ └── Subscriptions.cs.meta
│ │ ├── Network.meta
│ │ ├── Network
│ │ ├── Connection.cs
│ │ ├── Connection.cs.meta
│ │ ├── Request.cs
│ │ └── Request.cs.meta
│ │ ├── NetworkModelConfiguration.cs
│ │ ├── NetworkModelConfiguration.cs.meta
│ │ ├── NetworkModelRule.cs
│ │ ├── NetworkModelRule.cs.meta
│ │ ├── Utilities.meta
│ │ └── Utilities
│ │ ├── CompressionUtility.cs
│ │ ├── CompressionUtility.cs.meta
│ │ ├── HashUtility.cs
│ │ ├── HashUtility.cs.meta
│ │ ├── LogUtility.cs
│ │ ├── LogUtility.cs.meta
│ │ ├── RuleUtility.cs
│ │ └── RuleUtility.cs.meta
│ └── ProjectSettings
│ ├── AudioManager.asset
│ ├── ClusterInputManager.asset
│ ├── DynamicsManager.asset
│ ├── EditorBuildSettings.asset
│ ├── EditorSettings.asset
│ ├── GraphicsSettings.asset
│ ├── InputManager.asset
│ ├── NavMeshAreas.asset
│ ├── Physics2DSettings.asset
│ ├── PresetManager.asset
│ ├── ProjectSettings.asset
│ ├── ProjectVersion.txt
│ ├── QualitySettings.asset
│ ├── TagManager.asset
│ ├── TimeManager.asset
│ ├── UnityConnectSettings.asset
│ ├── VFXManager.asset
│ └── XRSettings.asset
├── server
└── nodejs
│ ├── config.json
│ ├── package.json
│ └── server.js
└── showcase
├── nodejs-console.jpg
├── unity-config.jpg
└── unity-rules.jpg
/.gitignore:
--------------------------------------------------------------------------------
1 | # Package files
2 | *.7z
3 | *.dmg
4 | *.gz
5 | *.iso
6 | *.jar
7 | *.rar
8 | *.tar
9 | *.zip
10 |
11 | # Log files
12 | logs
13 | *.log
14 |
15 | # Build files
16 | *.apk
17 | *.unitypackage
18 |
19 | # OS files
20 | .DS_Store
21 | .DS_Store?
22 | ._*
23 | .Spotlight-V100
24 | .Trashes
25 | ehthumbs.db
26 | Thumbs.db
27 |
28 | # NodeJS files
29 | server/nodejs/node_modules/
30 | server/nodejs/package-lock.json
31 | .npm
32 | npm-debug.log*
33 |
34 | # Visual Studio files
35 | client/unity/.vs/
36 | client/unity/.vscode/
37 | *.csproj
38 | *.unityproj
39 | *.sln
40 | *.suo
41 | *.tmp
42 | *.user
43 | *.userprefs
44 | *.pidb
45 | *.booproj
46 | *.svd
47 | *.pdb
48 | *.opendb
49 | *.VC.db
50 |
51 | # Unity files
52 | client/unity/[Bb]uild/
53 | client/unity/[Bb]uilds/
54 | client/unity/[Ll]ibrary/
55 | client/unity/[Ll]ogs/
56 | client/unity/[Oo]bj/
57 | client/unity/[Pp]ackages/
58 | client/unity/[Tt]emp/
59 | client/unity/Assets/AssetStoreTools*
60 | client/unity/sysinfo.txt
61 | *.pidb.meta
62 | *.pdb.meta
63 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Uwe Gruenefeld, Tobias Lunte
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Unity Network Model
2 | Package for Unity3D, which allows synchronizing GameObjects, Resources, and Components with multiple Unity clients over WebSockets. On the server-side, a NodeJS script opens a WebSocket connection, stores the incoming GameObjects, Resources, and Components as JSON objects and sends updates to the Unity clients to keep them sync.
3 |
4 | > Ideal for beginners, to synchronize multiple Unity clients without any knowledge
5 | > about network programming. Perfect as well, to rapidly prototype
6 | > multi-user experiences with a large number of supported devices.
7 |
8 | [](http://www.youtube.com/watch?v=fQcbDtgZxLE)
9 |
10 | *Demonstration of Unity Network Model*
11 |
12 | ## Features
13 | * Bidirectional updates between Unity client and NodeJS server
14 | - Every Unity client shares the same synchronized hierarchy of GameObjects and their Components and Resources
15 | * Unidirectional updates (only receive updates or only send updates)
16 | - One Unity client, for example, can be used to show the copy of GameObjects without sending changes to the NodeJS server
17 | * Selected updates (specify which Components and Resources can send or receive updates)
18 | - Supported components are BoxCollider, Camera, Light, LineRenderer, MeshCollider, MeshFilter, MeshRenderer, Script, SphereCollider, and Transform
19 | - Supported resources are Material, Mesh, and Texture2D
20 | - Extendable to support more components and resources
21 | * Supports multiple channel to synchronize different hierarchies on client and server at the same time
22 | * Synchronizes any hierarchy depth of GameObjects
23 | * Update frequency and decimal places adjustable
24 | * Updates only changed GameObjects, Components and Resources
25 |
26 | ## Install
27 | To install the UnityNetworkModel follow these five simple steps:
28 | 1. Clone this repository to your computer
29 | 2. Install the NodeJS package inside the nodejs folder
30 | ```sh
31 | npm install
32 | ```
33 | 3. Start node.js server
34 | ```sh
35 | node server.js
36 | ```
37 | 4. Import UnityNetworkModel.unitypackage in Unity3D
38 | 5. Add the script NetworkModelConfiguration.cs to a GameObject
39 |
40 | ## Requirements
41 | * NodeJS version 4.5 or higher *required*
42 | * Unity version 2017.4 or higher *required*
43 | * Tested on Unity version 2019.3 and 2018.4
44 | * If Clients (Unity) are deployed on different machines and compare timestamps is activated, a clock synchronization on all Clients is required
45 |
46 | ## Platforms
47 | * Windows (including Hololens und VR headsets)
48 | * Linux
49 | * MacOS
50 | * Android (Oculus Go, Quest)
51 | * iOS
52 |
53 | ## External Libraries
54 | * WebSocket-Sharp (see https://github.com/sta/websocket-sharp)
55 |
56 |
57 | -----
58 | ## Screenshots
59 |
60 | 
61 | *UnityNetworkModel Configuration Component*
62 |
63 | 
64 | *UnityNetworkModel Rule Component*
65 |
66 | 
67 | *NodeJS server console output*
--------------------------------------------------------------------------------
/client/unity/Assets/Libraries.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: ce33360cbbe5a4f3590b63db34c66adb
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/client/unity/Assets/Libraries/websocket-sharp.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/UweGruenefeld/UnityNetworkModel/94a54c7a660293f18a1e948befd0e3aa0726d518/client/unity/Assets/Libraries/websocket-sharp.dll
--------------------------------------------------------------------------------
/client/unity/Assets/Libraries/websocket-sharp.dll.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: d0f84885e3c5944fb8b785dc1c12e9fd
3 | PluginImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | iconMap: {}
7 | executionOrder: {}
8 | defineConstraints: []
9 | isPreloaded: 0
10 | isOverridable: 0
11 | isExplicitlyReferenced: 0
12 | validateReferences: 1
13 | platformData:
14 | - first:
15 | Any:
16 | second:
17 | enabled: 1
18 | settings: {}
19 | - first:
20 | Editor: Editor
21 | second:
22 | enabled: 0
23 | settings:
24 | DefaultValueInitialized: true
25 | - first:
26 | Windows Store Apps: WindowsStoreApps
27 | second:
28 | enabled: 0
29 | settings:
30 | CPU: AnyCPU
31 | userData:
32 | assetBundleName:
33 | assetBundleVariant:
34 |
--------------------------------------------------------------------------------
/client/unity/Assets/Scenes.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 9e3c243fe8aa44a1fb05b21d593a8982
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/client/unity/Assets/Scenes/NetworkModel.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 56bfa8e48257a284cbf9633b29d1d206
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/client/unity/Assets/Scenes/NetworkModel/ExampleScene.unity:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!29 &1
4 | OcclusionCullingSettings:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 2
7 | m_OcclusionBakeSettings:
8 | smallestOccluder: 5
9 | smallestHole: 0.25
10 | backfaceThreshold: 100
11 | m_SceneGUID: 00000000000000000000000000000000
12 | m_OcclusionCullingData: {fileID: 0}
13 | --- !u!104 &2
14 | RenderSettings:
15 | m_ObjectHideFlags: 0
16 | serializedVersion: 9
17 | m_Fog: 0
18 | m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
19 | m_FogMode: 3
20 | m_FogDensity: 0.01
21 | m_LinearFogStart: 0
22 | m_LinearFogEnd: 300
23 | m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
24 | m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
25 | m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
26 | m_AmbientIntensity: 1
27 | m_AmbientMode: 0
28 | m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
29 | m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
30 | m_HaloStrength: 0.5
31 | m_FlareStrength: 1
32 | m_FlareFadeSpeed: 3
33 | m_HaloTexture: {fileID: 0}
34 | m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
35 | m_DefaultReflectionMode: 0
36 | m_DefaultReflectionResolution: 128
37 | m_ReflectionBounces: 1
38 | m_ReflectionIntensity: 1
39 | m_CustomReflection: {fileID: 0}
40 | m_Sun: {fileID: 705507994}
41 | m_IndirectSpecularColor: {r: 0.44657898, g: 0.4964133, b: 0.5748178, a: 1}
42 | m_UseRadianceAmbientProbe: 0
43 | --- !u!157 &3
44 | LightmapSettings:
45 | m_ObjectHideFlags: 0
46 | serializedVersion: 11
47 | m_GIWorkflowMode: 0
48 | m_GISettings:
49 | serializedVersion: 2
50 | m_BounceScale: 1
51 | m_IndirectOutputScale: 1
52 | m_AlbedoBoost: 1
53 | m_EnvironmentLightingMode: 0
54 | m_EnableBakedLightmaps: 1
55 | m_EnableRealtimeLightmaps: 0
56 | m_LightmapEditorSettings:
57 | serializedVersion: 12
58 | m_Resolution: 2
59 | m_BakeResolution: 40
60 | m_AtlasSize: 1024
61 | m_AO: 0
62 | m_AOMaxDistance: 1
63 | m_CompAOExponent: 1
64 | m_CompAOExponentDirect: 0
65 | m_ExtractAmbientOcclusion: 0
66 | m_Padding: 2
67 | m_LightmapParameters: {fileID: 0}
68 | m_LightmapsBakeMode: 1
69 | m_TextureCompression: 1
70 | m_FinalGather: 0
71 | m_FinalGatherFiltering: 1
72 | m_FinalGatherRayCount: 256
73 | m_ReflectionCompression: 2
74 | m_MixedBakeMode: 2
75 | m_BakeBackend: 1
76 | m_PVRSampling: 1
77 | m_PVRDirectSampleCount: 32
78 | m_PVRSampleCount: 500
79 | m_PVRBounces: 2
80 | m_PVREnvironmentSampleCount: 500
81 | m_PVREnvironmentReferencePointCount: 2048
82 | m_PVRFilteringMode: 2
83 | m_PVRDenoiserTypeDirect: 0
84 | m_PVRDenoiserTypeIndirect: 0
85 | m_PVRDenoiserTypeAO: 0
86 | m_PVRFilterTypeDirect: 0
87 | m_PVRFilterTypeIndirect: 0
88 | m_PVRFilterTypeAO: 0
89 | m_PVREnvironmentMIS: 0
90 | m_PVRCulling: 1
91 | m_PVRFilteringGaussRadiusDirect: 1
92 | m_PVRFilteringGaussRadiusIndirect: 5
93 | m_PVRFilteringGaussRadiusAO: 2
94 | m_PVRFilteringAtrousPositionSigmaDirect: 0.5
95 | m_PVRFilteringAtrousPositionSigmaIndirect: 2
96 | m_PVRFilteringAtrousPositionSigmaAO: 1
97 | m_ExportTrainingData: 0
98 | m_TrainingDataDestination: TrainingData
99 | m_LightProbeSampleCountMultiplier: 4
100 | m_LightingDataAsset: {fileID: 0}
101 | m_UseShadowmask: 1
102 | --- !u!196 &4
103 | NavMeshSettings:
104 | serializedVersion: 2
105 | m_ObjectHideFlags: 0
106 | m_BuildSettings:
107 | serializedVersion: 2
108 | agentTypeID: 0
109 | agentRadius: 0.5
110 | agentHeight: 2
111 | agentSlope: 45
112 | agentClimb: 0.4
113 | ledgeDropHeight: 0
114 | maxJumpAcrossDistance: 0
115 | minRegionArea: 2
116 | manualCellSize: 0
117 | cellSize: 0.16666667
118 | manualTileSize: 0
119 | tileSize: 256
120 | accuratePlacement: 0
121 | debug:
122 | m_Flags: 0
123 | m_NavMeshData: {fileID: 0}
124 | --- !u!1 &79726451
125 | GameObject:
126 | m_ObjectHideFlags: 0
127 | m_CorrespondingSourceObject: {fileID: 0}
128 | m_PrefabInstance: {fileID: 0}
129 | m_PrefabAsset: {fileID: 0}
130 | serializedVersion: 6
131 | m_Component:
132 | - component: {fileID: 79726453}
133 | - component: {fileID: 79726454}
134 | - component: {fileID: 79726452}
135 | m_Layer: 0
136 | m_Name: NetworkModel
137 | m_TagString: Untagged
138 | m_Icon: {fileID: 0}
139 | m_NavMeshLayer: 0
140 | m_StaticEditorFlags: 0
141 | m_IsActive: 1
142 | --- !u!114 &79726452
143 | MonoBehaviour:
144 | m_ObjectHideFlags: 0
145 | m_CorrespondingSourceObject: {fileID: 0}
146 | m_PrefabInstance: {fileID: 0}
147 | m_PrefabAsset: {fileID: 0}
148 | m_GameObject: {fileID: 79726451}
149 | m_Enabled: 1
150 | m_EditorHideFlags: 0
151 | m_Script: {fileID: 11500000, guid: d07266e346aa1d4408de093c015f09d6, type: 3}
152 | m_Name:
153 | m_EditorClassIdentifier:
154 | applyToObject: 0
155 | applyToChildren: 1
156 | decimalPlaces: 1
157 | enableBoxCollider: 1
158 | sendBoxCollider: 1
159 | receiveBoxCollider: 1
160 | enableCamera: 1
161 | sendCamera: 1
162 | receiveCamera: 1
163 | enableLight: 1
164 | sendLight: 1
165 | receiveLight: 1
166 | enableLineRenderer: 1
167 | sendLineRenderer: 1
168 | receiveLineRenderer: 1
169 | enableMeshCollider: 1
170 | sendMeshCollider: 1
171 | receiveMeshCollider: 1
172 | enableMeshFilter: 1
173 | sendMeshFilter: 1
174 | receiveMeshFilter: 1
175 | enableMeshRenderer: 1
176 | sendMeshRenderer: 1
177 | receiveMeshRenderer: 1
178 | enableScript: 1
179 | sendScript: 1
180 | receiveScript: 1
181 | enableSphereCollider: 1
182 | sendSphereCollider: 1
183 | receiveSphereCollider: 1
184 | enableTransform: 1
185 | sendTransform: 1
186 | receiveTransform: 1
187 | --- !u!4 &79726453
188 | Transform:
189 | m_ObjectHideFlags: 0
190 | m_CorrespondingSourceObject: {fileID: 0}
191 | m_PrefabInstance: {fileID: 0}
192 | m_PrefabAsset: {fileID: 0}
193 | m_GameObject: {fileID: 79726451}
194 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
195 | m_LocalPosition: {x: 0, y: 0, z: 0}
196 | m_LocalScale: {x: 1, y: 1, z: 1}
197 | m_Children: []
198 | m_Father: {fileID: 0}
199 | m_RootOrder: 2
200 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
201 | --- !u!114 &79726454
202 | MonoBehaviour:
203 | m_ObjectHideFlags: 0
204 | m_CorrespondingSourceObject: {fileID: 0}
205 | m_PrefabInstance: {fileID: 0}
206 | m_PrefabAsset: {fileID: 0}
207 | m_GameObject: {fileID: 79726451}
208 | m_Enabled: 1
209 | m_EditorHideFlags: 0
210 | m_Script: {fileID: 11500000, guid: 93b7197a2cb765943aa63b41f39958a3, type: 3}
211 | m_Name:
212 | m_EditorClassIdentifier:
213 | IP: 127.0.0.1
214 | PORT: 8080
215 | RECONNECT: 1
216 | DELAY: 0.1
217 | TIME: 0
218 | SEND: 1
219 | RECEIVE: 1
220 | EXISTINGOBJECTS: 0
221 | EXISTINGRESOURCES: 0
222 | SENDCHANNELS: default
223 | RECEIVECHANNELS: default
224 | enableMaterial: 1
225 | sendMaterial: 1
226 | receiveMaterial: 1
227 | enableMesh: 1
228 | sendMesh: 1
229 | receiveMesh: 1
230 | enableTexture2D: 1
231 | sendTexture2D: 1
232 | receiveTexture2D: 1
233 | DEBUGLEVEL: 0
234 | DEBUGSEND: 0
235 | DEBUGRECEIVE: 0
236 | --- !u!1 &705507993
237 | GameObject:
238 | m_ObjectHideFlags: 0
239 | m_CorrespondingSourceObject: {fileID: 0}
240 | m_PrefabInstance: {fileID: 0}
241 | m_PrefabAsset: {fileID: 0}
242 | serializedVersion: 6
243 | m_Component:
244 | - component: {fileID: 705507995}
245 | - component: {fileID: 705507994}
246 | m_Layer: 0
247 | m_Name: Directional Light
248 | m_TagString: Untagged
249 | m_Icon: {fileID: 0}
250 | m_NavMeshLayer: 0
251 | m_StaticEditorFlags: 0
252 | m_IsActive: 1
253 | --- !u!108 &705507994
254 | Light:
255 | m_ObjectHideFlags: 0
256 | m_CorrespondingSourceObject: {fileID: 0}
257 | m_PrefabInstance: {fileID: 0}
258 | m_PrefabAsset: {fileID: 0}
259 | m_GameObject: {fileID: 705507993}
260 | m_Enabled: 1
261 | serializedVersion: 10
262 | m_Type: 1
263 | m_Shape: 0
264 | m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1}
265 | m_Intensity: 1
266 | m_Range: 10
267 | m_SpotAngle: 30
268 | m_InnerSpotAngle: 21.802082
269 | m_CookieSize: 10
270 | m_Shadows:
271 | m_Type: 2
272 | m_Resolution: -1
273 | m_CustomResolution: -1
274 | m_Strength: 1
275 | m_Bias: 0.05
276 | m_NormalBias: 0.4
277 | m_NearPlane: 0.2
278 | m_CullingMatrixOverride:
279 | e00: 1
280 | e01: 0
281 | e02: 0
282 | e03: 0
283 | e10: 0
284 | e11: 1
285 | e12: 0
286 | e13: 0
287 | e20: 0
288 | e21: 0
289 | e22: 1
290 | e23: 0
291 | e30: 0
292 | e31: 0
293 | e32: 0
294 | e33: 1
295 | m_UseCullingMatrixOverride: 0
296 | m_Cookie: {fileID: 0}
297 | m_DrawHalo: 0
298 | m_Flare: {fileID: 0}
299 | m_RenderMode: 0
300 | m_CullingMask:
301 | serializedVersion: 2
302 | m_Bits: 4294967295
303 | m_RenderingLayerMask: 1
304 | m_Lightmapping: 1
305 | m_LightShadowCasterMode: 0
306 | m_AreaSize: {x: 1, y: 1}
307 | m_BounceIntensity: 1
308 | m_ColorTemperature: 6570
309 | m_UseColorTemperature: 0
310 | m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0}
311 | m_UseBoundingSphereOverride: 0
312 | m_ShadowRadius: 0
313 | m_ShadowAngle: 0
314 | --- !u!4 &705507995
315 | Transform:
316 | m_ObjectHideFlags: 0
317 | m_CorrespondingSourceObject: {fileID: 0}
318 | m_PrefabInstance: {fileID: 0}
319 | m_PrefabAsset: {fileID: 0}
320 | m_GameObject: {fileID: 705507993}
321 | m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
322 | m_LocalPosition: {x: 0, y: 3, z: 0}
323 | m_LocalScale: {x: 1, y: 1, z: 1}
324 | m_Children: []
325 | m_Father: {fileID: 0}
326 | m_RootOrder: 1
327 | m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
328 | --- !u!1 &963194225
329 | GameObject:
330 | m_ObjectHideFlags: 0
331 | m_CorrespondingSourceObject: {fileID: 0}
332 | m_PrefabInstance: {fileID: 0}
333 | m_PrefabAsset: {fileID: 0}
334 | serializedVersion: 6
335 | m_Component:
336 | - component: {fileID: 963194228}
337 | - component: {fileID: 963194227}
338 | - component: {fileID: 963194226}
339 | m_Layer: 0
340 | m_Name: Main Camera
341 | m_TagString: MainCamera
342 | m_Icon: {fileID: 0}
343 | m_NavMeshLayer: 0
344 | m_StaticEditorFlags: 0
345 | m_IsActive: 1
346 | --- !u!81 &963194226
347 | AudioListener:
348 | m_ObjectHideFlags: 0
349 | m_CorrespondingSourceObject: {fileID: 0}
350 | m_PrefabInstance: {fileID: 0}
351 | m_PrefabAsset: {fileID: 0}
352 | m_GameObject: {fileID: 963194225}
353 | m_Enabled: 1
354 | --- !u!20 &963194227
355 | Camera:
356 | m_ObjectHideFlags: 0
357 | m_CorrespondingSourceObject: {fileID: 0}
358 | m_PrefabInstance: {fileID: 0}
359 | m_PrefabAsset: {fileID: 0}
360 | m_GameObject: {fileID: 963194225}
361 | m_Enabled: 1
362 | serializedVersion: 2
363 | m_ClearFlags: 1
364 | m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
365 | m_projectionMatrixMode: 1
366 | m_GateFitMode: 2
367 | m_FOVAxisMode: 0
368 | m_SensorSize: {x: 36, y: 24}
369 | m_LensShift: {x: 0, y: 0}
370 | m_FocalLength: 50
371 | m_NormalizedViewPortRect:
372 | serializedVersion: 2
373 | x: 0
374 | y: 0
375 | width: 1
376 | height: 1
377 | near clip plane: 0.3
378 | far clip plane: 1000
379 | field of view: 60
380 | orthographic: 0
381 | orthographic size: 5
382 | m_Depth: -1
383 | m_CullingMask:
384 | serializedVersion: 2
385 | m_Bits: 4294967295
386 | m_RenderingPath: -1
387 | m_TargetTexture: {fileID: 0}
388 | m_TargetDisplay: 0
389 | m_TargetEye: 3
390 | m_HDR: 1
391 | m_AllowMSAA: 1
392 | m_AllowDynamicResolution: 0
393 | m_ForceIntoRT: 0
394 | m_OcclusionCulling: 1
395 | m_StereoConvergence: 10
396 | m_StereoSeparation: 0.022
397 | --- !u!4 &963194228
398 | Transform:
399 | m_ObjectHideFlags: 0
400 | m_CorrespondingSourceObject: {fileID: 0}
401 | m_PrefabInstance: {fileID: 0}
402 | m_PrefabAsset: {fileID: 0}
403 | m_GameObject: {fileID: 963194225}
404 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
405 | m_LocalPosition: {x: 0, y: 1, z: -10}
406 | m_LocalScale: {x: 1, y: 1, z: 1}
407 | m_Children: []
408 | m_Father: {fileID: 0}
409 | m_RootOrder: 0
410 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
411 |
--------------------------------------------------------------------------------
/client/unity/Assets/Scenes/NetworkModel/ExampleScene.unity.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 9fc0d4010bbf28b4594072e72b8655ab
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 7cac8840454fd47e29127251f6738d4c
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: f8b83fbc2459b4174b40aa8f356206d4
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Dependency.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 91a536c0c41a30b4c9047940f773e8a4
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Dependency/AbstractInjector.cs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Abstract Injector for Dependencies of Unity Network Model
4 | *
5 | * @file AbstractInjector.cs
6 | * @author Uwe Gruenefeld
7 | * @version 2020-05-03
8 | **/
9 | namespace UnityNetworkModel
10 | {
11 | ///
12 | /// Abstract Injector to handle Dependencies for Network Model Configuration
13 | ///
14 | internal abstract class AbstractInjector
15 | {
16 | // Reference to Injector
17 | protected Injector injector;
18 |
19 | ///
20 | /// Creates Injektor-based class with injector reference
21 | ///
22 | ///
23 | internal AbstractInjector(Injector injector)
24 | {
25 | // Asign the Injector Reference
26 | this.injector = injector;
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Dependency/AbstractInjector.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: f600e2a97acfa0c44bd422e8053678de
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Dependency/Injector.cs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Injector Script of Unity Network Model
4 | *
5 | * @file Injector.cs
6 | * @author Uwe Gruenefeld
7 | * @version 2020-05-03
8 | **/
9 | namespace UnityNetworkModel
10 | {
11 | ///
12 | /// Injector that handles Dependencies for Network Model Configuration
13 | ///
14 | internal class Injector
15 | {
16 | // Configuration script visible in Inspector
17 | public NetworkModelConfiguration configuration;
18 |
19 | // Store for Objects representations
20 | public ObjectStore objectStore;
21 | // Store for Resource representations
22 | public ResourceStore resourceStore;
23 |
24 | // Model of the current Instance
25 | public Model model;
26 |
27 | // Serializer allows to serialize and deserialize Unity components and resources
28 | public Serializer serializer;
29 |
30 | // Handles subscriptions on send and receive channels
31 | public Subscriptions subscriptions;
32 |
33 | // Handles connection to server
34 | public Connection connection;
35 |
36 | ///
37 | /// Constructs an Injektor containing references to interfaces
38 | ///
39 | ///
40 | internal Injector(NetworkModelConfiguration configuration)
41 | {
42 | this.configuration = configuration;
43 | }
44 | }
45 | }
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Dependency/Injector.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 7f850016c169aaf418b2b54ac530eecd
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Editor.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 2bc2a185f8b71314a827c3dd8c1d8419
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Editor/ConfigurationEditor.cs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * ConfigEditor Script of Unity Network Model
4 | *
5 | * @file ConfigEditor.cs
6 | * @author Uwe Gruenefeld, Tobias Lunte
7 | * @version 2020-05-03
8 | **/
9 | using UnityEngine;
10 | using UnityEditor;
11 |
12 | namespace UnityNetworkModel
13 | {
14 | ///
15 | /// Editor interface for Network Model Configuration
16 | ///
17 | #if UNITY_EDITOR
18 | [CustomEditor(typeof(NetworkModelConfiguration))]
19 | [CanEditMultipleObjects]
20 | public class ConfigurationEditor : Editor
21 | {
22 | // Save toggle state of groups
23 | bool toggleGroupConnection = true;
24 | bool toggleGroupSettings = true;
25 | bool toggleGroupChannel = true;
26 | bool toggleGroupRules = true;
27 | bool toggleGroupDebugging = true;
28 |
29 | float currentWidth = 70;
30 |
31 | ///
32 | /// Override method to show custom editor
33 | ///
34 | public override void OnInspectorGUI()
35 | {
36 | // Data object of Unity component
37 | serializedObject.Update();
38 | var networkModelConfiguration = target as NetworkModelConfiguration;
39 |
40 | // Ensure no NetworkModelConfiguration in parent
41 | Transform pointer = networkModelConfiguration.transform;
42 | while (pointer.parent != null)
43 | {
44 | pointer = pointer.parent;
45 | if (pointer.GetComponent() != null)
46 | {
47 | EditorGUILayout.HelpBox("Another NetworkModelConfiguration found in parent GameObject. Therefore, this component is disabled.", MessageType.Error);
48 | networkModelConfiguration.enabled = false;
49 | }
50 | }
51 |
52 | // Ensure a NetworkModel Rule is attached to GameObject as well
53 | if (networkModelConfiguration.GetComponent() == null)
54 | networkModelConfiguration.gameObject.AddComponent();
55 |
56 | // Hover text for Help
57 | string serverIP = "Specify the IP address of the server.";
58 | string serverPort = "Specify the port of the server.";
59 | string reconnectTime = "Minimum time in seconds before next reconnect attempt. Will never be faster than the time between updates.";
60 | string updateDelay = "Minimum time in seconds between two updates.";
61 |
62 | string compareTime = "If checked, every update must contain a more recent timestamp than the last update.";
63 | string allowSend = "If checked, the network model will send updates to the server.";
64 | string allowReceive = "If checked, the network model will receive updates from the server.";
65 | string existingObjects = "Attempt to find existing GameObjects of the correct name before creating new ones. Names of GameObject descendants of NetworkModel must be unique when using this option.";
66 | string existingResources = "Attempt to find existing Resources of the correct name and type in \"/Resources/NetworkModel\" before creating new ones. Names of Resources in the folder must be unique when using this option.";
67 |
68 | string sendChannel = "List of channels on which to broadcast changes, seperated by \",\".";
69 | string receiveChannel = "List of channels from which to receive changes, separated by \",\".";
70 |
71 | string enableText = "Enable/Disable Resource";
72 | string sendText = "Enable/Disable Sending Resource";
73 | string receiveText = "Enable/Disable Receiving Resource";
74 |
75 | string debugLevel = "Show all debug messages with regard to specified log level.";
76 | string debugSend = "Debug messages sent to the server.";
77 | string debugReceive = "Debug messages received from server.";
78 |
79 | // Set GUILayout mode
80 | GUILayout.FlexibleSpace();
81 |
82 | // Textures
83 | Texture2D textureDark = new Texture2D(1, 1);
84 | textureDark.SetPixels(new Color[] { new Color(.6f, .6f, .6f) });
85 | textureDark.Apply();
86 |
87 | Texture2D textureLight = new Texture2D(1, 1);
88 | textureLight.SetPixels(new Color[] { new Color(.8f, .8f, .8f) });
89 | textureLight.Apply();
90 |
91 | // GUIStyles
92 | GUIStyle foldout = EditorStyles.foldoutHeader;
93 | foldout.fontStyle = FontStyle.Bold;
94 |
95 | GUIStyle header = new GUIStyle();
96 | header.normal.background = textureDark;
97 |
98 | GUIStyle empty = new GUIStyle();
99 |
100 | GUIStyle rowOdd = new GUIStyle();
101 | GUIStyle rowEven = new GUIStyle();
102 | rowEven.normal.background = textureLight;
103 |
104 | // Connection
105 | this.toggleGroupConnection = EditorGUILayout.BeginFoldoutHeaderGroup(this.toggleGroupConnection, "Connection", foldout);
106 | if (this.toggleGroupConnection)
107 | {
108 | EditorGUI.indentLevel++;
109 |
110 | if (EditorApplication.isPlaying)
111 | {
112 | EditorGUILayout.TextField(new GUIContent("Server IP", serverIP), networkModelConfiguration.IP, EditorStyles.label);
113 | EditorGUILayout.IntField(new GUIContent("Server Port", serverPort), networkModelConfiguration.PORT, EditorStyles.label);
114 | }
115 | else
116 | {
117 | networkModelConfiguration.IP = EditorGUILayout.TextField(new GUIContent("Server IP", serverIP), networkModelConfiguration.IP);
118 | networkModelConfiguration.PORT = EditorGUILayout.IntField(new GUIContent("Server Port", serverPort), networkModelConfiguration.PORT);
119 | }
120 | networkModelConfiguration.RECONNECT = EditorGUILayout.Slider(new GUIContent("Seconds to reconnect", reconnectTime), networkModelConfiguration.RECONNECT, 0.0f, 10.0f);
121 | networkModelConfiguration.DELAY = EditorGUILayout.Slider(new GUIContent("Seconds bet. updates", updateDelay), networkModelConfiguration.DELAY, 0.0f, 1.0f);
122 | EditorGUI.indentLevel--;
123 | }
124 | EditorGUILayout.EndFoldoutHeaderGroup();
125 | EditorGUILayout.Space();
126 |
127 | // Caluclate Editor width
128 | var windowVisibleRect = GUILayoutUtility.GetLastRect();
129 | if (windowVisibleRect.width > 1)
130 | this.currentWidth = windowVisibleRect.width;
131 |
132 | // GUILayoutOptions
133 | GUILayoutOption[] optionsLeftField = { GUILayout.MinWidth(70), GUILayout.Width((this.currentWidth * 0.45f) - 45) };
134 | GUILayoutOption[] optionsRightFields = { GUILayout.MaxWidth(65.0f), GUILayout.MinWidth(65.0f), GUILayout.Width(65.0f) };
135 |
136 | // Settings
137 | this.toggleGroupSettings = EditorGUILayout.BeginFoldoutHeaderGroup(this.toggleGroupSettings, "Settings", foldout);
138 | if (this.toggleGroupSettings)
139 | {
140 | EditorGUI.indentLevel++;
141 | networkModelConfiguration.TIME = EditorGUILayout.Toggle(new GUIContent("Compare timestamps", compareTime), networkModelConfiguration.TIME);
142 | networkModelConfiguration.SEND = EditorGUILayout.Toggle(new GUIContent("Allow to send updates", allowSend), networkModelConfiguration.SEND);
143 | networkModelConfiguration.RECEIVE = EditorGUILayout.Toggle(new GUIContent("Allow to receive updates", allowReceive), networkModelConfiguration.RECEIVE);
144 | networkModelConfiguration.EXISTINGOBJECTS = EditorGUILayout.Toggle(new GUIContent("Use existing objects", existingObjects), networkModelConfiguration.EXISTINGOBJECTS);
145 | networkModelConfiguration.EXISTINGRESOURCES = EditorGUILayout.Toggle(new GUIContent("Use existing resources", existingResources), networkModelConfiguration.EXISTINGRESOURCES);
146 | EditorGUI.indentLevel--;
147 | }
148 | EditorGUILayout.EndFoldoutHeaderGroup();
149 | EditorGUILayout.Space();
150 |
151 | // Channel
152 | this.toggleGroupChannel = EditorGUILayout.BeginFoldoutHeaderGroup(this.toggleGroupChannel, "Channel", foldout);
153 | if (this.toggleGroupChannel)
154 | {
155 | EditorGUI.indentLevel++;
156 | if (EditorApplication.isPlaying)
157 | {
158 | EditorGUILayout.TextField(new GUIContent("Send on channels", sendChannel), networkModelConfiguration.SENDCHANNELS, EditorStyles.label);
159 | EditorGUILayout.TextField(new GUIContent("Receive on channels", receiveChannel), networkModelConfiguration.RECEIVECHANNELS, EditorStyles.label);
160 | }
161 | else
162 | {
163 | networkModelConfiguration.SENDCHANNELS = EditorGUILayout.TextField(new GUIContent("Send on channels", sendChannel), networkModelConfiguration.SENDCHANNELS);
164 | networkModelConfiguration.RECEIVECHANNELS = EditorGUILayout.TextField(new GUIContent("Receive on channels", receiveChannel), networkModelConfiguration.RECEIVECHANNELS);
165 | }
166 | EditorGUI.indentLevel--;
167 | }
168 | EditorGUILayout.EndFoldoutHeaderGroup();
169 | EditorGUILayout.Space();
170 |
171 | // Rules
172 | this.toggleGroupRules = EditorGUILayout.BeginFoldoutHeaderGroup(this.toggleGroupRules, "Rules", foldout);
173 | if (this.toggleGroupRules)
174 | {
175 | EditorGUI.indentLevel++;
176 |
177 | // Rules Resources
178 | EditorGUILayout.BeginHorizontal(header);
179 | EditorGUILayout.LabelField(new GUIContent("Resources", "For which resources should updates be sent"), optionsLeftField);
180 | EditorGUILayout.LabelField("Send", optionsRightFields);
181 | EditorGUILayout.LabelField("Receive", optionsRightFields);
182 | EditorGUILayout.EndHorizontal();
183 |
184 | // Resource Material
185 | EditorGUILayout.BeginHorizontal(rowOdd);
186 | networkModelConfiguration.enableMaterial = EditorGUILayout.ToggleLeft(new GUIContent("Material", enableText),
187 | networkModelConfiguration.enableMaterial, EditorStyles.label, optionsLeftField);
188 | EditorGUI.BeginDisabledGroup(networkModelConfiguration.enableMaterial == false);
189 | networkModelConfiguration.sendMaterial = EditorGUILayout.ToggleLeft(new GUIContent("", sendText), networkModelConfiguration.sendMaterial, optionsRightFields);
190 | networkModelConfiguration.receiveMaterial = EditorGUILayout.ToggleLeft(new GUIContent("", receiveText), networkModelConfiguration.receiveMaterial, optionsRightFields);
191 | EditorGUI.EndDisabledGroup();
192 | EditorGUILayout.EndHorizontal();
193 |
194 | // Resource Mesh
195 | EditorGUILayout.BeginHorizontal(rowEven);
196 | networkModelConfiguration.enableMesh = EditorGUILayout.ToggleLeft(new GUIContent("Mesh", enableText),
197 | networkModelConfiguration.enableMesh, EditorStyles.label, optionsLeftField);
198 | EditorGUI.BeginDisabledGroup(networkModelConfiguration.enableMesh == false);
199 | networkModelConfiguration.sendMesh = EditorGUILayout.ToggleLeft(new GUIContent("", sendText), networkModelConfiguration.sendMesh, optionsRightFields);
200 | networkModelConfiguration.receiveMesh = EditorGUILayout.ToggleLeft(new GUIContent("", receiveText), networkModelConfiguration.receiveMesh, optionsRightFields);
201 | EditorGUI.EndDisabledGroup();
202 | EditorGUILayout.EndHorizontal();
203 |
204 | // Resource Texture2D
205 | EditorGUILayout.BeginHorizontal(rowOdd);
206 | networkModelConfiguration.enableTexture2D = EditorGUILayout.ToggleLeft(new GUIContent("Texture2D", enableText),
207 | networkModelConfiguration.enableTexture2D, EditorStyles.label, optionsLeftField);
208 | EditorGUI.BeginDisabledGroup(networkModelConfiguration.enableTexture2D == false);
209 | networkModelConfiguration.sendTexture2D = EditorGUILayout.ToggleLeft(new GUIContent("", sendText), networkModelConfiguration.sendTexture2D, optionsRightFields);
210 | networkModelConfiguration.receiveTexture2D = EditorGUILayout.ToggleLeft(new GUIContent("", receiveText), networkModelConfiguration.receiveTexture2D, optionsRightFields);
211 | EditorGUI.EndDisabledGroup();
212 | EditorGUILayout.EndHorizontal();
213 |
214 | EditorGUI.indentLevel--;
215 | }
216 | EditorGUILayout.EndFoldoutHeaderGroup();
217 | EditorGUILayout.Space();
218 |
219 | // Debugging
220 | this.toggleGroupDebugging = EditorGUILayout.BeginFoldoutHeaderGroup(this.toggleGroupDebugging, "Debugging", foldout);
221 | if (this.toggleGroupDebugging)
222 | {
223 | EditorGUI.indentLevel++;
224 | networkModelConfiguration.DEBUGLEVEL = (LogType)EditorGUILayout.EnumPopup(new GUIContent("Debug Level", debugLevel), networkModelConfiguration.DEBUGLEVEL);
225 |
226 | if (networkModelConfiguration.SEND)
227 | networkModelConfiguration.DEBUGSEND = EditorGUILayout.Toggle(new GUIContent("Log outgoing messages", debugSend), networkModelConfiguration.DEBUGSEND);
228 | else
229 | {
230 | EditorGUI.BeginDisabledGroup(true);
231 | EditorGUILayout.Toggle(new GUIContent("Log outgoing messages", debugSend), networkModelConfiguration.DEBUGSEND);
232 | EditorGUI.EndDisabledGroup();
233 | }
234 |
235 | if (networkModelConfiguration.RECEIVE)
236 | networkModelConfiguration.DEBUGRECEIVE = EditorGUILayout.Toggle(new GUIContent("Log incoming messages", debugReceive), networkModelConfiguration.DEBUGRECEIVE);
237 | else
238 | {
239 | EditorGUI.BeginDisabledGroup(true);
240 | EditorGUILayout.Toggle(new GUIContent("Log incoming messages", debugReceive), networkModelConfiguration.DEBUGRECEIVE);
241 | EditorGUI.EndDisabledGroup();
242 | }
243 |
244 | EditorGUI.indentLevel--;
245 | }
246 | EditorGUILayout.EndFoldoutHeaderGroup();
247 |
248 | // Apply changes
249 | serializedObject.ApplyModifiedProperties();
250 | }
251 | }
252 | #endif
253 | }
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Editor/ConfigurationEditor.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e5538ca461eb1e04f9a405334f0619a4
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Editor/RuleEditor.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 7305baec7f4467a43bc49d03f867cfdd
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Enum.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 59fdfa283be801946ab4aa9920a5ab3a
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Enum/Extension.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 36c7a8ffeaf5ea944a81329cfb36ec76
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Enum/Extension/RuleTypeExtension.cs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Extension of Rule Type Enum of Unity Network Model
4 | *
5 | * @file RuleTypeExtension.cs
6 | * @author Uwe Gruenefeld
7 | * @version 2020-05-04
8 | *
9 | **/
10 | namespace UnityNetworkModel
11 | {
12 | ///
13 | /// Extension of Enum RuleType
14 | ///
15 | internal static class RuleTypeExtension
16 | {
17 | ///
18 | /// Transform Enum RuleType into a boolean
19 | ///
20 | ///
21 | ///
22 | internal static bool ToBool(this RuleType ruleType)
23 | {
24 | switch (ruleType)
25 | {
26 | case RuleType.TRUE:
27 | return true;
28 | default:
29 | return false;
30 | }
31 | }
32 |
33 | ///
34 | /// Transform boolean into Enum RuleType
35 | ///
36 | ///
37 | ///
38 | internal static RuleType FromBool(bool boolValue)
39 | {
40 | if(boolValue)
41 | return RuleType.TRUE;
42 |
43 | return RuleType.FALSE;
44 | }
45 | }
46 | }
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Enum/Extension/RuleTypeExtension.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 5590d053d3435644c838939ef7bd216d
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Enum/LogType.cs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Log Type Enum of Unity Network Model
4 | *
5 | * @file LogType.cs
6 | * @author Uwe Gruenefeld
7 | * @version 2020-05-05
8 | *
9 | **/
10 | namespace UnityNetworkModel
11 | {
12 | ///
13 | /// Enum of RuleType
14 | ///
15 | public enum LogType : ushort
16 | {
17 | DISABLED = 0, ERROR = 1, WARNING = 2, INFORMATION = 3
18 | }
19 | }
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Enum/LogType.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: af48eb32ba845a64694c66f0b62093a2
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Enum/RuleType.cs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Rule Type Enum of Unity Network Model
4 | *
5 | * @file RuleType.cs
6 | * @author Uwe Gruenefeld
7 | * @version 2020-05-04
8 | *
9 | **/
10 | namespace UnityNetworkModel
11 | {
12 | ///
13 | /// Enum of RuleType
14 | ///
15 | internal enum RuleType
16 | {
17 | DISABLED, TRUE, FALSE
18 | }
19 | }
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Enum/RuleType.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 9f6494c7e088812448f185d28f600b4f
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Enum/UpdateType.cs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Update Type of Unity Network Model
4 | *
5 | * @file UpdateType.cs
6 | * @author Uwe Gruenefeld
7 | * @version 2020-05-04
8 | *
9 | **/
10 | namespace UnityNetworkModel
11 | {
12 | ///
13 | /// Enum of UpdateType
14 | ///
15 | internal enum UpdateType
16 | {
17 | SEND, RECEIVE
18 | }
19 | }
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Enum/UpdateType.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 461aa57630b81a04cb590c8b6eb4b012
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Model.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 233b2d4894e6d4f3187e7ebae69f3232
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Model/Component.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: bced543e2540b834eae7a16b9cc4babf
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Model/Component/AbstractComponent.cs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Abstract Component Script of Unity Network Model
4 | *
5 | * @file AbstractComponent.cs
6 | * @author Uwe Gruenefeld, Tobias Lunte
7 | * @version 2020-04-30
8 | *
9 | **/
10 | using System;
11 | using UnityEngine;
12 |
13 | namespace UnityNetworkModel
14 | {
15 | ///
16 | /// Abstract class for all serializable Components
17 | ///
18 | [Serializable]
19 | internal abstract class AbstractComponent
20 | {
21 | protected Injector injector;
22 |
23 | ///
24 | /// Creates serializable Component from Unity component
25 | ///
26 | ///
27 | ///
28 | public AbstractComponent(Injector injector, Component component)
29 | {
30 | this.injector = injector;
31 | }
32 |
33 | ///
34 | /// Return common type of component
35 | ///
36 | ///
37 | abstract public Type commonType { get; }
38 |
39 | ///
40 | /// Applies parameters saved in the serialized component to a unity component
41 | ///
42 | ///
43 | ///
44 | ///
45 | abstract public bool Apply(Injector injector, Component component);
46 |
47 | ///
48 | /// Returns value-based, order-dependent hash. Needs to be overwritten for components
49 | ///
50 | ///
51 | abstract public long GetHash();
52 | }
53 | }
54 |
55 | /*
56 | * TEMPLATE FOR NEW COMPONENT
57 | *
58 | * [Serializable]
59 | * internal class NAMEOFCOMPONENTSerializable : AbstractComponent
60 | * {
61 | * CLASS VARIABLES TO SYNCHRONIZE
62 | *
63 | * // Prepare component for sending to server
64 | * public NAMEOFCOMPONENTSerializable(Injector injector, Component component) : base(injector, component)
65 | * {
66 | * SAVE VARIABLES FROM COMPONENT IN CLASS VARIABLES
67 | * }
68 | *
69 | * // Apply received values to component
70 | * public override void Apply (Injector injector, Component component) : base(injector, component)
71 | * {
72 | * RESTORE CLASS VARIABLES INTO VARIABLES FROM COMPONENT
73 | * }
74 | *
75 | * // Returns value-based, order-dependent hash. Needs to be overwritten for components
76 | * // public override long GetHash()
77 | * // {
78 | * // COMBINE ALL VARIABLE HASHES
79 | * // }
80 | * }
81 | *
82 | */
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Model/Component/AbstractComponent.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: b41dad4818173473793c206be5b43246
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Model/Component/BoxColliderSerializable.cs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Serializable BoxCollider of Unity Network Model
4 | *
5 | * @file BoxColliderSerializable.cs
6 | * @author Uwe Gruenefeld
7 | * @version 2020-05-02
8 | *
9 | **/
10 | using System;
11 | using UnityEngine;
12 |
13 | namespace UnityNetworkModel
14 | {
15 | ///
16 | /// Serializable BoxCollider
17 | ///
18 | [Serializable]
19 | internal class BoxColliderSerializable : AbstractComponent
20 | {
21 | public Vector3 c, s; // Center, Size
22 |
23 | ///
24 | /// Creates serializable BoxCollider from Unity component
25 | ///
26 | ///
27 | ///
28 | public BoxColliderSerializable(Injector injector, Component component) : base(injector, component)
29 | {
30 | BoxCollider boxcollider = (BoxCollider)component;
31 |
32 | this.c = CompressionUtility.Compress(component.gameObject, boxcollider.center);
33 | this.s = CompressionUtility.Compress(component.gameObject, boxcollider.size);
34 | }
35 |
36 | ///
37 | /// Return common type of component
38 | ///
39 | ///
40 | public override Type commonType { get { return typeof(BoxCollider); } }
41 |
42 | ///
43 | /// Applies parameters saved in the serialized BoxCollider to a Unity BoxCollider
44 | ///
45 | ///
46 | ///
47 | ///
48 | public override bool Apply(Injector injector, Component component)
49 | {
50 | BoxCollider boxcollider = (BoxCollider)component;
51 |
52 | boxcollider.center = this.c;
53 | boxcollider.size = this.s;
54 |
55 | return true;
56 | }
57 |
58 | ///
59 | /// Returns Hash value of this serializable class
60 | ///
61 | ///
62 | public override long GetHash()
63 | {
64 | // Combine the Hashes of all variables
65 | return HashUtility.CombineHashes(
66 | this.c.GetHashCode(),
67 | this.s.GetHashCode()
68 | );
69 | }
70 | }
71 | }
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Model/Component/BoxColliderSerializable.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e4270dcf682845d4c8a23914d03a8eb1
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Model/Component/CameraSerializable.cs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Serializable Camera of Unity Network Model
4 | *
5 | * @file CameraSerializable.cs
6 | * @author Uwe Gruenefeld
7 | * @version 2020-05-02
8 | *
9 | **/
10 | using System;
11 | using UnityEngine;
12 |
13 | namespace UnityNetworkModel
14 | {
15 | ///
16 | /// Serializable Camera
17 | ///
18 | [Serializable]
19 | internal class CameraSerializable : AbstractComponent
20 | {
21 | public float d, n, f, v; // Depth, NearClipPlane, FarClipPlane, FieldOfView
22 | public Color b; // BackgroundColor
23 | public CameraClearFlags c; // ClearFlags
24 |
25 | ///
26 | /// Creates serializable Camera from Unity component
27 | ///
28 | ///
29 | ///
30 | public CameraSerializable(Injector injector, Component component) : base(injector, component)
31 | {
32 | Camera camera = (Camera)component;
33 |
34 | this.d = CompressionUtility.Compress(component.gameObject, camera.depth);
35 | this.n = CompressionUtility.Compress(component.gameObject, camera.nearClipPlane);
36 | this.f = CompressionUtility.Compress(component.gameObject, camera.farClipPlane);
37 | this.v = CompressionUtility.Compress(component.gameObject, camera.fieldOfView);
38 | this.b = CompressionUtility.Compress(component.gameObject, camera.backgroundColor);
39 | this.c = camera.clearFlags;
40 | }
41 |
42 | ///
43 | /// Return common type of component
44 | ///
45 | ///
46 | public override Type commonType { get { return typeof(Camera); } }
47 |
48 | ///
49 | /// Applies parameters saved in the serialized Camera to a Unity Camera
50 | ///
51 | ///
52 | ///
53 | ///
54 | public override bool Apply(Injector injector, Component component)
55 | {
56 | Camera camera = (Camera)component;
57 |
58 | camera.depth = this.d;
59 | camera.nearClipPlane = this.n;
60 | camera.farClipPlane = this.f;
61 | camera.fieldOfView = this.v;
62 | camera.backgroundColor = this.b;
63 | camera.clearFlags = this.c;
64 |
65 | return true;
66 | }
67 |
68 | ///
69 | /// Returns Hash value of this serializable class
70 | ///
71 | ///
72 | public override long GetHash()
73 | {
74 | // Combine the Hashes of all variables
75 | return HashUtility.CombineHashes(
76 | this.d.GetHashCode(),
77 | this.n.GetHashCode(),
78 | this.f.GetHashCode(),
79 | this.v.GetHashCode(),
80 | this.b.GetHashCode(),
81 | this.c.GetHashCode()
82 | );
83 | }
84 | }
85 | }
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Model/Component/CameraSerializable.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 5bd43f60259efc1438e9a46417fac543
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Model/Component/LightSerializable.cs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Serializable Light of Unity Network Model
4 | *
5 | * @file LightSerializable.cs
6 | * @author Uwe Gruenefeld
7 | * @version 2020-05-02
8 | *
9 | **/
10 | using System;
11 | using UnityEngine;
12 |
13 | namespace UnityNetworkModel
14 | {
15 | ///
16 | /// Serializable Light
17 | ///
18 | [Serializable]
19 | internal class LightSerializable : AbstractComponent
20 | {
21 | public LightType t; // Type
22 | public Color c; // Color
23 | public float i, b; // Intensity, BounceIntensity
24 |
25 | ///
26 | /// Creates serializable Light from Unity component
27 | ///
28 | ///
29 | ///
30 | public LightSerializable(Injector injector, Component component) : base(injector, component)
31 | {
32 | Light light = (Light)component;
33 |
34 | this.t = light.type;
35 | this.c = CompressionUtility.Compress(component.gameObject, light.color);
36 | this.i = CompressionUtility.Compress(component.gameObject, light.intensity);
37 | this.b = CompressionUtility.Compress(component.gameObject, light.bounceIntensity);
38 | }
39 |
40 | ///
41 | /// Return common type of component
42 | ///
43 | ///
44 | public override Type commonType { get { return typeof(Light); } }
45 |
46 | ///
47 | /// Applies parameters saved in the serialized Light to a Unity Light
48 | ///
49 | ///
50 | ///
51 | ///
52 | public override bool Apply(Injector injector, Component component)
53 | {
54 | Light light = (Light)component;
55 |
56 | light.type = this.t;
57 | light.color = this.c;
58 | light.intensity = this.i;
59 | light.bounceIntensity = this.b;
60 |
61 | return true;
62 | }
63 |
64 | ///
65 | /// Returns Hash value of this serializable class
66 | ///
67 | ///
68 | public override long GetHash()
69 | {
70 | // Combine the Hashes of all variables
71 | return HashUtility.CombineHashes(
72 | this.t.GetHashCode(),
73 | this.c.GetHashCode(),
74 | this.i.GetHashCode(),
75 | this.b.GetHashCode()
76 | );
77 | }
78 | }
79 | }
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Model/Component/LightSerializable.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: c6fe9b0d33c131a41a0cf4291cf69a67
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Model/Component/LineRendererSerializable.cs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Serializable LineRenderer of Unity Network Model
4 | *
5 | * @file LineRendererSerializable.cs
6 | * @author Uwe Gruenefeld, Tobias Lunte
7 | * @version 2020-05-02
8 | *
9 | **/
10 | using System;
11 | using UnityEngine;
12 |
13 | namespace UnityNetworkModel
14 | {
15 | ///
16 | /// Serializable LineRenderer
17 | ///
18 | [Serializable]
19 | internal class LineRendererSerializable : AbstractComponent
20 | {
21 | public string m; // SharedMaterial
22 | public Vector3[] p; // ArrayOfPositions
23 | public float w; // WidthMultiplier
24 | public bool l; // Loop
25 | public int ca, co; // NumberOfCapVertices, NumberOfCornerVertices
26 | public LineTextureMode t; // TextureMode
27 | public Color cs, ce; // StartColor, EndColor
28 |
29 | ///
30 | /// Creates serializable LineRenderer from Unity component
31 | ///
32 | ///
33 | ///
34 | public LineRendererSerializable(Injector injector, Component component) : base(injector, component)
35 | {
36 | LineRenderer lineRenderer = (LineRenderer)component;
37 |
38 | // Save the used Shared Material
39 | if (lineRenderer.sharedMaterial == null)
40 | this.m = "null"; // No Material set
41 | else
42 | {
43 | // Get reference or unique name for the material resource
44 | lineRenderer.sharedMaterial.name = injector.resourceStore.GetReferenceName(lineRenderer.sharedMaterial);
45 |
46 | // Check if resource is already in ResourceStore
47 | if (!injector.resourceStore.Contains(lineRenderer.sharedMaterial.name))
48 | injector.resourceStore.Add(lineRenderer.sharedMaterial);
49 |
50 | // Store the new Material name
51 | this.m = lineRenderer.sharedMaterial.name;
52 | }
53 |
54 | this.p = new Vector3[lineRenderer.positionCount];
55 | lineRenderer.GetPositions(this.p);
56 |
57 | this.p = CompressionUtility.Compress(component.gameObject, this.p);
58 | this.w = CompressionUtility.Compress(component.gameObject, lineRenderer.widthMultiplier);
59 | this.l = lineRenderer.loop;
60 | this.ca = lineRenderer.numCapVertices;
61 | this.co = lineRenderer.numCornerVertices;
62 | this.t = lineRenderer.textureMode;
63 | this.cs = CompressionUtility.Compress(component.gameObject, lineRenderer.startColor);
64 | this.ce = CompressionUtility.Compress(component.gameObject, lineRenderer.endColor);
65 | }
66 |
67 | ///
68 | /// Return common type of component
69 | ///
70 | ///
71 | public override Type commonType { get { return typeof(LineRenderer); } }
72 |
73 | ///
74 | /// Applies parameters saved in the serialized LineRenderer to a Unity LineRenderer
75 | ///
76 | ///
77 | ///
78 | ///
79 | public override bool Apply(Injector injector, Component component)
80 | {
81 | // Get reference to component
82 | LineRenderer lineRenderer = (LineRenderer)component;
83 |
84 | lineRenderer.positionCount = this.p.Length;
85 | lineRenderer.SetPositions(this.p);
86 | lineRenderer.widthMultiplier = this.w;
87 | lineRenderer.loop = this.l;
88 | lineRenderer.numCapVertices = this.ca;
89 | lineRenderer.numCornerVertices = this.co;
90 | lineRenderer.textureMode = this.t;
91 | lineRenderer.startColor = this.cs;
92 | lineRenderer.endColor = this.ce;
93 |
94 | // Check if Material is null
95 | if(this.m == null || this.m == "null")
96 | {
97 | lineRenderer.material = null;
98 | lineRenderer.sharedMaterial = null;
99 | return true;
100 | }
101 |
102 | // Find resource in Store
103 | ResourceNode resourceNode;
104 | if (!injector.resourceStore.TryGet(this.m, typeof(Material), out resourceNode))
105 | {
106 | // If resource not found, then Unity component cannot be created
107 | return false;
108 | }
109 |
110 | // Apply the Material to the Component
111 | lineRenderer.material = (Material)resourceNode.resource;
112 |
113 | return true;
114 | }
115 |
116 | ///
117 | /// Returns Hash value of this serializable class
118 | ///
119 | ///
120 | public override long GetHash()
121 | {
122 | // Combine the Hashes of all variables
123 | long hash = HashUtility.CombineHashes(
124 | this.m.GetHashCode(),
125 | this.w.GetHashCode(),
126 | this.l.GetHashCode(),
127 | this.ca.GetHashCode(),
128 | this.co.GetHashCode(),
129 | this.t.GetHashCode(),
130 | this.cs.GetHashCode(),
131 | this.ce.GetHashCode()
132 | );
133 |
134 | foreach (Vector3 position in this.p)
135 | hash = HashUtility.Combine2Hashes(hash, position.GetHashCode());
136 |
137 | return hash;
138 | }
139 | }
140 | }
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Model/Component/LineRendererSerializable.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: eb6486c8ddc7c31478209d8c381e8553
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Model/Component/MeshColliderSerializable.cs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Mesh Collider Clone Script of Unity Network Model
4 | *
5 | * @file MeshColliderClone.cs
6 | * @author Uwe Gruenefeld
7 | * @version 2020-04-30
8 | *
9 | **/
10 | using System;
11 | using UnityEngine;
12 |
13 | namespace UnityNetworkModel
14 | {
15 | ///
16 | /// Serializable MeshCollider
17 | ///
18 | [Serializable]
19 | internal class MeshColliderSerializable : AbstractComponent
20 | {
21 | public string m; // SharedMesh
22 |
23 | ///
24 | /// Creates serializable MeshCollider from Unity component
25 | ///
26 | ///
27 | ///
28 | public MeshColliderSerializable(Injector injector, Component component) : base(injector, component)
29 | {
30 | MeshCollider meshCollider = (MeshCollider)component;
31 |
32 | // Check if Mesh is attached to MeshCollider
33 | if (meshCollider.sharedMesh == null)
34 | this.m = "null";
35 | else
36 | {
37 | // If mesh is attached, then get reference or unique name from ResourceStore
38 | meshCollider.sharedMesh.name = injector.resourceStore.GetReferenceName(meshCollider.sharedMesh);
39 | if (!injector.resourceStore.Contains(meshCollider.sharedMesh.name))
40 | {
41 | // If Mesh resource does not exist add it to the ResourceStore
42 | injector.resourceStore.Add(meshCollider.sharedMesh);
43 | }
44 | // Store the new Material name
45 | this.m = meshCollider.sharedMesh.name;
46 | }
47 | }
48 |
49 | ///
50 | /// Return common type of component
51 | ///
52 | ///
53 | public override Type commonType { get { return typeof(MeshCollider); } }
54 |
55 | ///
56 | /// Applies parameters saved in the serialized MeshCollider to a Unity MeshCollider
57 | ///
58 | ///
59 | ///
60 | ///
61 | public override bool Apply(Injector injector, Component component)
62 | {
63 | // Get reference to component
64 | MeshCollider meshCollider = (MeshCollider)component;
65 |
66 | // Check if Mesh is null
67 | if(this.m == null || this.m == "null")
68 | {
69 | meshCollider.material = null;
70 | meshCollider.sharedMaterial = null;
71 | return true;
72 | }
73 |
74 | // Find resource in Store
75 | ResourceNode resourceNode;
76 | if (!injector.resourceStore.TryGet(this.m, typeof(Mesh), out resourceNode))
77 | {
78 | // If resource not found, then Unity component cannot be created
79 | return false;
80 | }
81 |
82 | // Apply the Material to the Component
83 | meshCollider.sharedMesh = (Mesh)resourceNode.resource;
84 |
85 | return true;
86 | }
87 |
88 | ///
89 | /// Returns Hash value of this serializable class
90 | ///
91 | ///
92 | public override long GetHash()
93 | {
94 | // Combine the Hashes of all variables
95 | return HashUtility.CombineHashes(
96 | this.m.GetHashCode()
97 | );
98 | }
99 | }
100 | }
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Model/Component/MeshColliderSerializable.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 02ff4f67c0936e64eb252a07881d2cf6
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Model/Component/MeshFilterSerializable.cs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Mesh Filter Clone Script of Unity Network Model
4 | *
5 | * @file MeshFilterClone.cs
6 | * @author Uwe Gruenefeld
7 | * @version 2020-05-04
8 | *
9 | **/
10 | using System;
11 | using UnityEngine;
12 |
13 | namespace UnityNetworkModel
14 | {
15 | ///
16 | /// Serializable MeshFilter
17 | ///
18 | [Serializable]
19 | internal class MeshFilterSerializable : AbstractComponent
20 | {
21 | public string m; // SharedMesh
22 |
23 | ///
24 | /// Creates serializable MeshFilter from Unity component
25 | ///
26 | ///
27 | ///
28 | public MeshFilterSerializable(Injector injector, Component component) : base(injector, component)
29 | {
30 | // Check if Mesh is attached to MeshFilter
31 | MeshFilter meshFilter = (MeshFilter)component;
32 | if (meshFilter.sharedMesh == null)
33 | this.m = "null";
34 | else
35 | {
36 | // If mesh is attached, then get reference or unique name from ResourceStore
37 | meshFilter.sharedMesh.name = injector.resourceStore.GetReferenceName(meshFilter.sharedMesh);
38 | if (!injector.resourceStore.Contains(meshFilter.sharedMesh.name))
39 | {
40 | // If Mesh resource does not exist add it to the ResourceStore
41 | injector.resourceStore.Add(meshFilter.sharedMesh);
42 | }
43 | // Store the new Material name
44 | this.m = meshFilter.sharedMesh.name;
45 | }
46 | }
47 |
48 | ///
49 | /// Return common type of component
50 | ///
51 | ///
52 | public override Type commonType { get { return typeof(MeshFilter); } }
53 |
54 | ///
55 | /// Applies parameters saved in the serialized MeshFilter to a Unity MeshFilter
56 | ///
57 | ///
58 | ///
59 | ///
60 | public override bool Apply(Injector injector, Component component)
61 | {
62 | // Get reference to component
63 | MeshFilter meshFilter = (MeshFilter)component;
64 |
65 | // Check if Mesh is null
66 | if(this.m == null || this.m == "null")
67 | {
68 | meshFilter.mesh = null;
69 | meshFilter.sharedMesh = null;
70 | return true;
71 | }
72 |
73 | // Find resource in Store
74 | ResourceNode resourceNode;
75 | if (!injector.resourceStore.TryGet(this.m, typeof(Mesh), out resourceNode))
76 | {
77 | // If Mesh resource not found, then Unity component cannot be created
78 | return false;
79 | }
80 |
81 | // Apply the Mesh to the Component
82 | meshFilter.sharedMesh = (Mesh)resourceNode.resource;
83 |
84 | return true;
85 | }
86 |
87 | ///
88 | /// Returns Hash value of this serializable class
89 | ///
90 | ///
91 | public override long GetHash()
92 | {
93 | // Combine the Hashes of all variables
94 | return HashUtility.CombineHashes(
95 | this.m.GetHashCode()
96 | );
97 | }
98 | }
99 | }
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Model/Component/MeshFilterSerializable.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 45dd0749dfeb275489a52f74cb690fff
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Model/Component/MeshRendererSerializable.cs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Mesh Renderer Clone Script of Unity Network Model
4 | *
5 | * @file MeshRendererClone.cs
6 | * @author Uwe Gruenefeld, Tobias Lunte
7 | * @version 2020-05-04
8 | *
9 | **/
10 | using System;
11 | using UnityEngine;
12 |
13 | namespace UnityNetworkModel
14 | {
15 | ///
16 | /// Serializable MeshRenderer
17 | ///
18 | [Serializable]
19 | internal class MeshRendererSerializable : AbstractComponent
20 | {
21 | public string m; // SharedMesh
22 |
23 | ///
24 | /// Creates serializable MeshRenderer from Unity component
25 | ///
26 | ///
27 | ///
28 | public MeshRendererSerializable(Injector injector, Component component) : base(injector, component)
29 | {
30 | // Check if Mesh is attached to MeshFilter
31 | MeshRenderer meshRenderer = (MeshRenderer)component;
32 | if (meshRenderer.sharedMaterial == null)
33 | this.m = "null";
34 | else
35 | {
36 | // If mesh is attached, then get reference or unique name from ResourceStore
37 | meshRenderer.sharedMaterial.name = injector.resourceStore.GetReferenceName(meshRenderer.sharedMaterial);
38 | if (!injector.resourceStore.Contains(meshRenderer.sharedMaterial.name))
39 | {
40 | // If Mesh resource does not exist add it to the ResourceStore
41 | injector.resourceStore.Add(meshRenderer.sharedMaterial);
42 | }
43 | // Store the new Material name
44 | this.m = meshRenderer.sharedMaterial.name;
45 | }
46 | }
47 |
48 | ///
49 | /// Return common type of component
50 | ///
51 | ///
52 | public override Type commonType { get { return typeof(MeshRenderer); } }
53 |
54 | ///
55 | /// Applies parameters saved in the serialized MeshRenderer to a Unity MeshRenderer
56 | ///
57 | ///
58 | ///
59 | ///
60 | public override bool Apply(Injector injector, Component component)
61 | {
62 | // Get reference to component
63 | MeshRenderer meshRenderer = (MeshRenderer)component;
64 |
65 | // Check if Material is null
66 | if(this.m == null || this.m == "null")
67 | {
68 | meshRenderer.material = null;
69 | meshRenderer.sharedMaterial = null;
70 | return true;
71 | }
72 |
73 | // Find resource in Store
74 | ResourceNode resourceNode;
75 | if (!injector.resourceStore.TryGet(this.m, typeof(Material), out resourceNode))
76 | {
77 | // If resource not found, then Unity component cannot be created
78 | return false;
79 | }
80 |
81 | // Apply the Material to the Component
82 | meshRenderer.material = (Material)resourceNode.resource;
83 |
84 | return true;
85 | }
86 |
87 | ///
88 | /// Returns Hash value of this serializable class
89 | ///
90 | ///
91 | public override long GetHash()
92 | {
93 | // Combine the Hashes of all variables
94 | return HashUtility.CombineHashes(
95 | this.m.GetHashCode()
96 | );
97 | }
98 | }
99 | }
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Model/Component/MeshRendererSerializable.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: b334b126990dbe848a98b806a4a574e1
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Model/Component/ScriptSerializable.cs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Script Clone Script of Unity Network Model
4 | *
5 | * @file ScriptClone.cs
6 | * @author Uwe Gruenefeld
7 | * @version 2020-05-04
8 | *
9 | **/
10 | using System;
11 | using UnityEngine;
12 |
13 | namespace UnityNetworkModel
14 | {
15 | ///
16 | /// Serializable Script
17 | ///
18 | [Serializable]
19 | internal class ScriptSerializable : AbstractComponent
20 | {
21 | public string t; // Type
22 | public string v; // Values
23 |
24 | ///
25 | /// Creates serializable Script from Unity component
26 | ///
27 | ///
28 | ///
29 | public ScriptSerializable(Injector injector, Component component) : base(injector, component)
30 | {
31 | this.t = component.GetType().AssemblyQualifiedName;
32 | this.v = JsonUtility.ToJson(component);
33 | }
34 |
35 | ///
36 | /// Return common type of component
37 | ///
38 | ///
39 | public override Type commonType { get { return typeof(MonoBehaviour); } }
40 |
41 | ///
42 | /// Applies parameters saved in the serialized MonoBehaviour to a Unity MonoBehaviour
43 | ///
44 | ///
45 | ///
46 | ///
47 | public override bool Apply(Injector injector, Component component)
48 | {
49 | JsonUtility.FromJsonOverwrite(this.v, component);
50 | return true;
51 | }
52 |
53 | ///
54 | /// Return Script type
55 | ///
56 | ///
57 | public string ScriptType()
58 | {
59 | return this.t;
60 | }
61 |
62 | ///
63 | /// Returns Hash value of this serializable class
64 | ///
65 | ///
66 | public override long GetHash()
67 | {
68 | // Combine the Hashes of all variables
69 | return HashUtility.CombineHashes(
70 | this.t.GetHashCode(),
71 | this.v.GetHashCode()
72 | );
73 | }
74 | }
75 | }
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Model/Component/ScriptSerializable.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 15c127918ec8dd1498996b1a2f40614d
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Model/Component/SphereColliderSerializable.cs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Sphere Collider Clone Script of Unity Network Model
4 | *
5 | * @file SphereColliderClone.cs
6 | * @author Tobias Lunte, Uwe Gruenefeld
7 | * @version 2020-05-04
8 | *
9 | **/
10 | using System;
11 | using UnityEngine;
12 |
13 | namespace UnityNetworkModel
14 | {
15 | ///
16 | /// Serializable SphereCollider
17 | ///
18 | internal class SphereColliderSerializable : AbstractComponent
19 | {
20 | public Vector3 c; // Center
21 | public float r; // Radius
22 |
23 | ///
24 | /// Creates serializable SphereCollider from Unity component
25 | ///
26 | ///
27 | ///
28 | public SphereColliderSerializable(Injector injector, Component component) : base(injector, component)
29 | {
30 | SphereCollider spherecollider = (SphereCollider)component;
31 |
32 | this.c = CompressionUtility.Compress(component.gameObject, spherecollider.center);
33 | this.r = CompressionUtility.Compress(component.gameObject, spherecollider.radius);
34 | }
35 |
36 | ///
37 | /// Return common type of component
38 | ///
39 | ///
40 | public override Type commonType { get { return typeof(SphereCollider); } }
41 |
42 | ///
43 | /// Applies parameters saved in the serialized SphereCollider to a Unity SphereCollider
44 | ///
45 | ///
46 | ///
47 | ///
48 | public override bool Apply(Injector injector, Component component)
49 | {
50 | SphereCollider spherecollider = (SphereCollider)component;
51 |
52 | spherecollider.center = this.c;
53 | spherecollider.radius = this.r;
54 |
55 | return true;
56 | }
57 |
58 | ///
59 | /// Returns Hash value of this serializable class
60 | ///
61 | ///
62 | public override long GetHash()
63 | {
64 | // Combine the Hashes of all variables
65 | return HashUtility.CombineHashes(
66 | this.c.GetHashCode(),
67 | this.r.GetHashCode()
68 | );
69 | }
70 | }
71 | }
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Model/Component/SphereColliderSerializable.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: ae893a9111a999b459e8cf58ea402454
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Model/Component/TransformSerializable.cs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Transform Clone Script of Unity Network Model
4 | *
5 | * @file TransformClone.cs
6 | * @author Uwe Gruenefeld
7 | * @version 2020-05-04
8 | *
9 | **/
10 | using System;
11 | using UnityEngine;
12 |
13 | namespace UnityNetworkModel
14 | {
15 | ///
16 | /// Serializable Transform
17 | ///
18 | [Serializable]
19 | internal class TransformSerializable : AbstractComponent
20 | {
21 | public Vector3 p, s; // LocalPosition, LocalScale
22 | public Quaternion r; // LocalRotation
23 | public string t; // Tags
24 |
25 | ///
26 | /// Creates serializable Transform from Unity component
27 | ///
28 | ///
29 | ///
30 | public TransformSerializable(Injector injector, Component component) : base(injector, component)
31 | {
32 | Transform transform = (Transform)component;
33 |
34 | this.p = CompressionUtility.Compress(component.gameObject, transform.localPosition);
35 | this.s = CompressionUtility.Compress(component.gameObject, transform.localScale);
36 | this.r = transform.localRotation;
37 | this.t = transform.tag;
38 | }
39 |
40 | ///
41 | /// Return common type of component
42 | ///
43 | ///
44 | public override Type commonType { get { return typeof(Transform); } }
45 |
46 | ///
47 | /// Applies parameters saved in the serialized Transform to a Unity Transform
48 | ///
49 | ///
50 | ///
51 | ///
52 | public override bool Apply(Injector injector, Component component)
53 | {
54 | Transform transform = (Transform)component;
55 |
56 | // If there was no change on client side then use server values
57 | if (!transform.hasChanged)
58 | {
59 | transform.localPosition = this.p;
60 | transform.localRotation = this.r;
61 | transform.localScale = this.s;
62 | transform.tag = this.t;
63 |
64 | // Avoid triggering update of changes
65 | transform.hasChanged = false;
66 | }
67 | return true;
68 | }
69 |
70 | ///
71 | /// Returns Hash value of this serializable class
72 | ///
73 | ///
74 | public override long GetHash()
75 | {
76 | // Combine the Hashes of all variables
77 | return HashUtility.CombineHashes(
78 | this.p.GetHashCode(),
79 | this.s.GetHashCode(),
80 | this.r.GetHashCode(),
81 | this.t.GetHashCode()
82 | );
83 | }
84 | }
85 | }
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Model/Component/TransformSerializable.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: f3fba1f1f47700c47928501ea94203f7
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Model/Model.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e4f921afd0a2f4922ba79a83fb7b68ba
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Model/Resource.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: c1d04abf194ad7149a877b3be92e2fa1
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Model/Resource/AbstractResource.cs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Abstract Resource Script of Unity Network Model
4 | *
5 | * @file AbstractResourceClone.cs
6 | * @author Tobias Lunte, Uwe Gruenefeld
7 | * @version 2020-05-04
8 | *
9 | **/
10 | using System;
11 | using UnityEngine;
12 |
13 | namespace UnityNetworkModel
14 | {
15 | ///
16 | /// Abstract class for all serializable Resources
17 | ///
18 | [Serializable]
19 | internal abstract class AbstractResource
20 | {
21 | protected Injector injector;
22 |
23 | ///
24 | /// Creates serializable Resource from Unity Resource
25 | ///
26 | ///
27 | ///
28 | public AbstractResource(Injector injector, UnityEngine.Object resource)
29 | {
30 | this.injector = injector;
31 | }
32 |
33 | ///
34 | /// Return common type of resource
35 | ///
36 | ///
37 | abstract public Type commonType { get; }
38 |
39 | ///
40 | /// Applies parameters stored in serialized Resource to Unity Resource
41 | ///
42 | ///
43 | ///
44 | ///
45 | abstract public bool Apply(Injector injector, UnityEngine.Object resource);
46 |
47 | ///
48 | /// Create Unity resource of matching type, setting final parameters where necessary. Needs to be overwritten for resources using final parameters
49 | ///
50 | ///
51 | public virtual UnityEngine.Object Construct()
52 | {
53 | return (UnityEngine.Object)Activator.CreateInstance(commonType);
54 | }
55 |
56 | ///
57 | /// Returns value-based, order-dependent hash. Needs to be overwritten for resources
58 | ///
59 | ///
60 | abstract public long GetHash();
61 | }
62 | }
63 |
64 | /*
65 | * TEMPLATE FOR NEW RESOURCE
66 | *
67 | * [Serializable]
68 | * internal class NAMEOFRESOURCEClone : AbstractResource
69 | * {
70 | * protected override Type commonType { get { return typeof(UnityEngine.NAMEOFRESOURCE); } }
71 | *
72 | * CLASS VARIABLES TO SYNCHRONIZE
73 | *
74 | * // Prepare resource for sending to server
75 | * public NAMEOFRESOURCEClone(Injector injector, System.Object resource) : base(injector, resource)
76 | * {
77 | * SAVE VARIABLES FROM RESOURCE IN CLASS VARIABLES
78 | * }
79 | *
80 | * // Apply received values to resource
81 | * public override void Apply (Injector injector, System.Object resource)
82 | * {
83 | * RESTORE CLASS VARIABLES INTO VARIABLES FROM RESOURCE
84 | * }
85 | *
86 | * // Override if parameters need to be set during initialization
87 | * // public override Object Construct()
88 | * // {
89 | * //
90 | * // }
91 | *
92 | * // Returns value-based, order-dependent hash. Needs to be overwritten for resources
93 | * public override long GetHash()
94 | * {
95 | * COMBINE ALL VARIABLE HASHES
96 | * }
97 | * }
98 | *
99 | */
100 |
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Model/Resource/AbstractResource.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: f59e5ccff02e6b44e8b3224a0d0e1c0e
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Model/Resource/MaterialSerializable.cs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Material Clone Script of Unity Network Model
4 | *
5 | * @file MaterialClone.cs
6 | * @author Tobias Lunte, Uwe Gruenefeld
7 | * @version 2020-05-04
8 | **/
9 | using System;
10 | using UnityEngine;
11 |
12 | namespace UnityNetworkModel
13 | {
14 | [Serializable]
15 | internal class MaterialSerializable : AbstractResource
16 | {
17 | public Color c; // Color of Material
18 | public string t; // Reference name for texture resource
19 | public Vector2 o, s; // Texture offset and scale
20 | public string n; // Shader name
21 | public string[] k; // Shader keywords
22 |
23 | ///
24 | /// Creates serializable Material from Unity resource
25 | ///
26 | ///
27 | ///
28 | public MaterialSerializable(Injector injector, UnityEngine.Object resource) : base(injector, resource)
29 | {
30 | Material material = (Material)resource;
31 |
32 | // Check if Color attribute exists
33 | if (material.HasProperty("_Color"))
34 | this.c = material.color;
35 |
36 | // Save the used Main Texture
37 | if (!material.HasProperty("_MainTex") || material.mainTexture == null)
38 | this.t = "null";
39 | else
40 | {
41 | // Get reference or unique name for the material resource
42 | material.mainTexture.name = injector.resourceStore.GetReferenceName(material.mainTexture);
43 |
44 | // Check if resource is already in ResourceStore
45 | if (!injector.resourceStore.Contains(material.mainTexture.name))
46 | injector.resourceStore.Add(material.mainTexture);
47 |
48 | // Store the Texture name
49 | this.t = material.mainTexture.name;
50 | }
51 |
52 | // Check if TextureOffset attribute exists
53 | if(material.HasProperty("_TextureOffset"))
54 | this.o = CompressionUtility.Compress(this.injector.configuration.gameObject, material.mainTextureOffset);
55 |
56 | // Check if TextureScale exists
57 | if(material.HasProperty("_TextureScale"))
58 | this.s = CompressionUtility.Compress(this.injector.configuration.gameObject, material.mainTextureScale);
59 |
60 | this.n = material.shader.name;
61 | this.k = material.shaderKeywords;
62 | }
63 |
64 | ///
65 | /// Return common type of resource
66 | ///
67 | ///
68 | public override Type commonType { get { return typeof(Material); } }
69 |
70 | ///
71 | /// Applies parameters saved in the serialized Material to a Unity Material
72 | ///
73 | ///
74 | ///
75 | ///
76 | public override bool Apply(Injector injector, UnityEngine.Object resource)
77 | {
78 | Material material = (Material)resource;
79 |
80 | // Find Texture2D resource in Store
81 | ResourceNode node = null;
82 | if (this.t != "null" && !injector.resourceStore.TryGet(this.t, typeof(Texture2D), out node))
83 | {
84 | // If Texture2D resource that belongs to this Material is not found, then Unity component cannot be created
85 | return false;
86 | }
87 |
88 | // Apply Material color
89 | if (material.HasProperty("_Color"))
90 | {
91 | material.color = this.c;
92 | }
93 |
94 | // Apply texture
95 | if (this.t != "null")
96 | {
97 | material.mainTextureOffset = this.o;
98 | material.mainTextureScale = this.s;
99 | material.mainTexture = (Texture2D)node.resource;
100 | }
101 |
102 | // Apply shader values
103 | Shader shader = Shader.Find(this.n);
104 | if (shader != null)
105 | {
106 | material.shader = shader;
107 | material.shaderKeywords = this.k;
108 | }
109 |
110 | return true;
111 | }
112 |
113 | ///
114 | /// Construct a Unity Material
115 | ///
116 | ///
117 | public override UnityEngine.Object Construct()
118 | {
119 | Shader shader = Shader.Find(this.n);
120 | if (shader == null)
121 | {
122 | shader = Shader.Find("Standard");
123 | }
124 | System.Object[] args = new System.Object[] { shader };
125 | return (UnityEngine.Object)Activator.CreateInstance(commonType, args);
126 | }
127 |
128 |
129 | ///
130 | /// Returns Hash value of this serializable class
131 | ///
132 | ///
133 | public override long GetHash()
134 | {
135 | // Combine the Hashes of all variables
136 | long hash = HashUtility.CombineHashes(
137 | this.c.GetHashCode(),
138 | this.t.GetHashCode(),
139 | this.o.GetHashCode(),
140 | this.s.GetHashCode(),
141 | this.n.GetHashCode()
142 | );
143 |
144 | foreach (string keyword in this.k)
145 | hash = HashUtility.Combine2Hashes(hash, keyword.GetHashCode());
146 |
147 | return hash;
148 | }
149 | }
150 | }
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Model/Resource/MaterialSerializable.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 09a1121791648d3418dd2a1a393e4bca
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Model/Resource/MeshSerializable.cs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Mesh Clone Script of Unity Network Model
4 | *
5 | * @file MeshClone.cs
6 | * @author Tobias Lunte, Uwe Gruenefeld
7 | * @version 2020-05-04
8 | *
9 | **/
10 | using System;
11 | using UnityEngine;
12 |
13 | namespace UnityNetworkModel
14 | {
15 | ///
16 | /// Serializable Mesh
17 | ///
18 | internal class MeshSerializable : AbstractResource
19 | {
20 | public Vector3[] v, n; // Vertices, Normals
21 | public Vector2[] u; // UV-Texture Coordinates
22 | public int[] t; // Triangles
23 |
24 | ///
25 | /// Creates serializable Mesh from Unity resource
26 | ///
27 | ///
28 | ///
29 | public MeshSerializable(Injector injector, UnityEngine.Object resource) : base(injector, resource)
30 | {
31 | Mesh mesh = (Mesh)resource;
32 |
33 | this.v = CompressionUtility.Compress(this.injector.configuration.gameObject, mesh.vertices);
34 | this.n = CompressionUtility.Compress(this.injector.configuration.gameObject, mesh.normals);
35 | this.u = CompressionUtility.Compress(this.injector.configuration.gameObject, mesh.uv);
36 | this.t = mesh.triangles;
37 | }
38 |
39 | ///
40 | /// Return common type of resource
41 | ///
42 | ///
43 | public override Type commonType { get { return typeof(Mesh); } }
44 |
45 | ///
46 | /// Applies parameters saved in the serialized Mesh to a Unity Mesh
47 | ///
48 | ///
49 | ///
50 | ///
51 | public override bool Apply(Injector injector, UnityEngine.Object resource)
52 | {
53 | Mesh mesh = (Mesh)resource;
54 |
55 | mesh.vertices = this.v;
56 | mesh.normals = this.n;
57 | mesh.uv = this.u;
58 | mesh.triangles = this.t;
59 |
60 | return true;
61 | }
62 |
63 | ///
64 | /// Returns Hash value of this serializable class
65 | ///
66 | ///
67 | public override long GetHash()
68 | {
69 | // Combine the Hashes of all variables
70 | long hash = 17;
71 | foreach (Vector3 val in this.v)
72 | {
73 | hash = HashUtility.Combine2Hashes(hash, val.GetHashCode());
74 | }
75 | foreach (Vector3 val in this.n)
76 | {
77 | hash = HashUtility.Combine2Hashes(hash, val.GetHashCode());
78 | }
79 | foreach (Vector2 val in this.u)
80 | {
81 | hash = HashUtility.Combine2Hashes(hash, val.GetHashCode());
82 | }
83 | foreach (int val in this.t)
84 | {
85 | hash = HashUtility.Combine2Hashes(hash, val.GetHashCode());
86 | }
87 | return hash;
88 | }
89 | }
90 | }
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Model/Resource/MeshSerializable.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 2cefe2e4497f2a54f882b7d02a2f2815
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Model/Resource/Texture2DSerializable.cs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Texture2D Clone Script of Unity Network Model
4 | *
5 | * @file Texture2DClone.cs
6 | * @author Tobias Lunte, Uwe Gruenefeld
7 | * @version 2020-05-04
8 | *
9 | **/
10 | using System;
11 | using UnityEngine;
12 |
13 | namespace UnityNetworkModel
14 | {
15 | [Serializable]
16 | internal class Texture2DSerializable : AbstractResource
17 | {
18 | public int w, h; // Width, Height
19 | public Color[] p; // Pixels
20 |
21 | ///
22 | /// Creates serializable Texture2D from Unity resource
23 | ///
24 | ///
25 | ///
26 | public Texture2DSerializable(Injector injector, UnityEngine.Object resource) : base(injector, resource)
27 | {
28 | Texture2D texture = (Texture2D)resource;
29 |
30 | this.w = texture.width;
31 | this.h = texture.height;
32 |
33 | try
34 | {
35 | this.p = CompressionUtility.Compress(this.injector.configuration.gameObject, texture.GetPixels());
36 | }
37 | catch(Exception) {}
38 | }
39 |
40 | ///
41 | /// Return common type of resource
42 | ///
43 | ///
44 | public override Type commonType { get { return typeof(Texture2D); } }
45 |
46 | ///
47 | /// Applies parameters saved in the serialized Texture2D to a Unity Texture2D
48 | ///
49 | ///
50 | ///
51 | ///
52 | public override bool Apply(Injector injector, UnityEngine.Object resource)
53 | {
54 | Texture2D texture = (Texture2D)resource;
55 |
56 | if(this.p != null && this.p.Length > 0)
57 | {
58 | texture.SetPixels(this.p);
59 | texture.Apply();
60 | }
61 |
62 | return true;
63 | }
64 |
65 | ///
66 | /// Construct a Unity Texture2D
67 | ///
68 | ///
69 | public override UnityEngine.Object Construct()
70 | {
71 | return new Texture2D(this.w, this.h);
72 | }
73 |
74 | ///
75 | /// Returns Hash value of this serializable class
76 | ///
77 | ///
78 | public override long GetHash()
79 | {
80 | // Combine the Hashes of all variables
81 | long hash = HashUtility.CombineHashes(
82 | this.w.GetHashCode(),
83 | this.h.GetHashCode()
84 | );
85 |
86 | if(this.p != null)
87 | foreach (Color color in this.p)
88 | hash = HashUtility.Combine2Hashes(hash, color.GetHashCode());
89 |
90 | return hash;
91 | }
92 | }
93 | }
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Model/Resource/Texture2DSerializable.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: a7d7e126fe4c2bb449434cf109100d53
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Model/Serializer.cs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Serializer Script of Unity Network Model
4 | *
5 | * @file Serializer.cs
6 | * @author Uwe Gruenefeld, Tobias Lunte
7 | * @version 2020-05-05
8 | *
9 | **/
10 | using System;
11 | using UnityEngine;
12 |
13 | namespace UnityNetworkModel
14 | {
15 | ///
16 | /// Handles conversion between serializable and non-serializable types of Components and Resources
17 | ///
18 | internal class Serializer : AbstractInjector
19 | {
20 | // Injector for dependency injection
21 | internal Serializer(Injector injector) : base(injector) {}
22 |
23 | ///
24 | /// Convert a Unity Component type to a AbstractComponent type
25 | ///
26 | /// Type of Unity Component
27 | /// Type of AbstractComponent
28 | internal Type ToSerializableType(Type type)
29 | {
30 | return Type.GetType("UnityNetworkModel." + type.Name + "Serializable");
31 | }
32 |
33 | ///
34 | /// Convert a NetworkModel AbstractComponent type to a Unity Component type
35 | ///
36 | /// Type of AbstractComponent
37 | /// Type of Unity Component
38 | internal Type ToCommonType(Type type)
39 | {
40 | return Type.GetType("UnityEngine." + type.Name.Replace("Serializable", "") + ", UnityEngine");
41 | }
42 |
43 | ///
44 | /// Get the matching Unity Component type from a AbstractComponent; Returns Script type if Component is script
45 | ///
46 | ///
47 | /// Type of Unity Component
48 | internal Type GetCommonType(AbstractComponent component)
49 | {
50 | Type type = component.GetType();
51 | if (type == typeof(ScriptSerializable))
52 | {
53 | ScriptSerializable script = (ScriptSerializable)component;
54 | type = Type.GetType(script.ScriptType());
55 | }
56 | else
57 | type = ToCommonType(type);
58 |
59 | return type;
60 | }
61 |
62 | ///
63 | /// Convert a Unity Component to a NetworkModel AbstractComponent
64 | ///
65 | /// Unity Component
66 | /// AbstractComponent
67 | internal AbstractComponent ToSerializableComponent(Component component)
68 | {
69 | Type type = component.GetType();
70 |
71 | if (type.IsSubclassOf(typeof(MonoBehaviour)))
72 | type = typeof(ScriptSerializable);
73 | else
74 | type = ToSerializableType(type);
75 |
76 | if (type != null)
77 | return (AbstractComponent)Activator.CreateInstance(type, new System.Object[] { this.injector, component });
78 |
79 | return null;
80 | }
81 |
82 | ///
83 | /// Convert a UnityEngine Object to a NetworkModel AbstractResource
84 | ///
85 | /// UnityEngine Object
86 | /// AbstractResource
87 | internal AbstractResource ToSerializableResource(UnityEngine.Object resource)
88 | {
89 | Type type = ToSerializableType(resource.GetType());
90 | if (type != null)
91 | return (AbstractResource)Activator.CreateInstance(type, new System.Object[] { this.injector, resource });
92 |
93 | return null;
94 | }
95 | }
96 | }
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Model/Serializer.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e26de2eac3f914c8a96b56c37e9c0d08
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Model/Store.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: dbe9af36578616149909cd325b0052b7
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Model/Store/ObjectNode.cs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Object Node Script of Unity Network Model
4 | *
5 | * @file ObjectNode.cs
6 | * @author Uwe Gruenefeld, Tobias Lunte
7 | * @version 2020-05-04
8 | **/
9 | using System;
10 | using System.Collections.Generic;
11 | using UnityEngine;
12 |
13 | namespace UnityNetworkModel
14 | {
15 | ///
16 | /// Stores specific GameObject, tracking its last known parent and components
17 | ///
18 | internal class ObjectNode : AbstractInjector
19 | {
20 | public GameObject gameObject;
21 | public int parentID;
22 | public Dictionary hashes;
23 |
24 | ///
25 | /// Wraps a GameObject into a Node
26 | ///
27 | ///
28 | ///
29 | internal ObjectNode(Injector injector, GameObject gameObject) : base(injector)
30 | {
31 | this.gameObject = gameObject;
32 | this.hashes = new Dictionary();
33 | }
34 |
35 | ///
36 | /// Update ObjectNode with current values from represented GameObject
37 | ///
38 | internal void Update()
39 | {
40 | // Update stored parent with current parent ID
41 | this.parentID = gameObject.transform.parent.GetInstanceID();
42 |
43 | // Add all Components to Dictonary containing hashes
44 | foreach (Component component in gameObject.GetComponents(typeof(Component)))
45 | {
46 | // If Component does not exist in Dictonary, then add it
47 | if (!this.hashes.ContainsKey(component.GetType()))
48 | this.hashes.Add(component.GetType(), 0);
49 | }
50 | }
51 |
52 | ///
53 | /// Update specific component hash to current state
54 | ///
55 | /// Type of component to update
56 | internal void UpdateComponent(Type type)
57 | {
58 | // Get Component from GameObject
59 | Component component = gameObject.GetComponent(type);
60 |
61 | // If no component was found, then return
62 | if (component == null)
63 | return;
64 |
65 | // Transform UnityEngine Component to NetworkModel AbstractComponent
66 | AbstractComponent abstractComponent = this.injector.serializer.ToSerializableComponent(component);
67 |
68 | // If Component does not exist as a serializable Component
69 | if(abstractComponent != null)
70 | this.hashes[type] = abstractComponent.GetHash();
71 | }
72 |
73 | ///
74 | /// Remove tracking for component of specific Type
75 | ///
76 | ///
77 | internal void RemoveComponent(Type type)
78 | {
79 | this.hashes.Remove(type);
80 | }
81 |
82 |
83 |
84 | /*
85 | ///
86 | /// Add missing hashes to component Dictionary as empty == unknown
87 | ///
88 | internal void PopulateHashes()
89 | {
90 | foreach (Component component in gameObject.GetComponents(typeof(Component)))
91 | {
92 | if (HierarchyUtility.FindRule(this.injector, this.gameObject, component.GetType(), UpdateType.SEND) && !hashes.ContainsKey(component.GetType()))
93 | {
94 | hashes.Add(component.GetType(), 0);
95 | }
96 | }
97 | }
98 |
99 | ///
100 | /// Update stored parent to current state
101 | ///
102 | internal void UpdateParent()
103 | {
104 | this.parent = gameObject.transform.parent.GetInstanceID();
105 | }
106 |
107 | ///
108 | /// Update specific component hash to current state
109 | ///
110 | /// Type of component to update
111 | internal void UpdateHash(Type type)
112 | {
113 | if (HierarchyUtility.FindRule(this.injector, this.gameObject, type, UpdateType.SEND))
114 | {
115 | Component component = gameObject.GetComponent(type);
116 | if (component != null)
117 | {
118 | hashes[type] = this.injector.serializer.ToSerializableComponent(component).GetHash();
119 | }
120 | }
121 | }
122 |
123 | ///
124 | /// Update specific component hash to current state
125 | /// UpdateHash(Type type) should always be preferred, if possible.
126 | ///
127 | /// serialized component to update
128 | internal void UpdateHash(AbstractComponent component)
129 | {
130 | hashes[this.injector.serializer.GetCommonType(component)] = component.GetHash();
131 | }
132 |
133 |
134 | */
135 |
136 | ///
137 | /// Returns matching Component by priority
138 | /// 1) Existing matching component from the gameObject
139 | /// 2) New matching component added to the gameObject
140 | ///
141 | ///
142 | /// Component of matching Type
143 | internal Component GetOrCreateComponent(Type type)
144 | {
145 | // Get component of specified type
146 | Component component = gameObject.GetComponent(type);
147 |
148 | // If no component was found, then add component
149 | if (component == null)
150 | component = gameObject.AddComponent(type);
151 |
152 | // Return the component
153 | return component;
154 | }
155 | }
156 | }
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Model/Store/ObjectNode.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 44f1e8bfb9beb429badc75f9c6abcfa9
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Model/Store/ObjectStore.cs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Object Store Script of Unity Network Model
4 | *
5 | * @file ObjectStore.cs
6 | * @author Uwe Gruenefeld, Tobias Lunte
7 | * @version 2020-04-30
8 | *
9 | **/
10 | using System.Collections.Generic;
11 | using UnityEngine;
12 |
13 | namespace UnityNetworkModel
14 | {
15 | ///
16 | /// Collects all known GameObjects and tracks the last known state of their parent and components.
17 | ///
18 | internal class ObjectStore : Dictionary
19 | {
20 | private Injector injector;
21 |
22 | ///
23 | /// Create a new ObjectStore
24 | ///
25 | ///
26 | internal ObjectStore(Injector injector)
27 | {
28 | this.injector = injector;
29 | }
30 |
31 | ///
32 | /// Adds GameObject to store
33 | ///
34 | ///
35 | internal void Add(GameObject gameObject)
36 | {
37 | this.Add(gameObject.name, gameObject);
38 | }
39 |
40 | ///
41 | /// Adds GameObject to store with specific name
42 | ///
43 | ///
44 | ///
45 | internal void Add(string name, GameObject gameObject)
46 | {
47 | this.Add(name, new ObjectNode(this.injector, gameObject));
48 | }
49 |
50 | ///
51 | /// Return a GameObject of the correct name by priority
52 | /// 1) A matching tracked GameObject from the store.
53 | /// 2) A matching GameObject from tracked part of the scene (if using existing components is enabled).
54 | /// 3) A new empty GameObject of the correct name.
55 | ///
56 | /// Name of the gameObject
57 | /// GameObject of matching name
58 | internal ObjectNode GetOrCreate(string name)
59 | {
60 | ObjectNode node;
61 |
62 | // Check if name of Gameobject is not existing
63 | if (!this.TryGetValue(name, out node))
64 | {
65 | // Create a new GameObject
66 | GameObject gameObject = null;
67 |
68 | // Should exisitng objects be preferred
69 | if (this.injector.configuration.EXISTINGOBJECTS)
70 | {
71 | // Try to find transform of specified GameObject
72 | Transform transform = FindTransform(this.injector.configuration.transform, name);
73 | if (transform != null)
74 | gameObject = transform.gameObject;
75 | }
76 |
77 | // If no GameObject was found
78 | if (gameObject == null)
79 | {
80 | // Create new GameOBject
81 | gameObject = new GameObject();
82 | gameObject.SetActive(false);
83 | gameObject.name = name;
84 |
85 | // Attach new GameObject to root GameObject that contains the NetworkModel Configuration
86 | gameObject.transform.parent = this[Model.ROOT_NAME].gameObject.transform;
87 | }
88 |
89 | // Create new ObjectNode for GameObject
90 | node = new ObjectNode(this.injector, gameObject);
91 |
92 | // Add it to the ObjectStore
93 | this.Add(name, node);
94 | }
95 |
96 | return node;
97 | }
98 |
99 | ///
100 | /// Performs a depth-first search for a Transform of the correct Name among all descendants of parent transform.
101 | ///
102 | ///
103 | ///
104 | /// Transform of matching name
105 | private Transform FindTransform(Transform parent, string name)
106 | {
107 | // Is the name of the parent equal to the name of the searched GameObject
108 | if (parent.name.Equals(name))
109 | return parent;
110 |
111 | // Search through all children
112 | foreach (Transform child in parent)
113 | {
114 | // Recrusive find transform
115 | Transform result = FindTransform(child, name);
116 | if (result != null)
117 | return result;
118 | }
119 |
120 | // No Transform found
121 | return null;
122 | }
123 |
124 | ///
125 | /// Determine name that a gameObject should be stored under in the store. Will return current storage name if gameObject is already present or new free name if not.
126 | /// GameObject's name should be set to returned name if it is to be stored.
127 | ///
128 | ///
129 | /// Name the GameObject should be stored under
130 | internal string GetReferenceName(GameObject gameObject)
131 | {
132 | // Check if object is null
133 | if (gameObject == null)
134 | return "null";
135 |
136 | // Find the name of the Object
137 | string referenceName = gameObject.name;
138 | while (this.ContainsKey(referenceName) && this[referenceName].gameObject.GetInstanceID() != gameObject.GetInstanceID())
139 | referenceName = referenceName + "_" + gameObject.GetInstanceID().ToString();
140 |
141 | // Return the Object name
142 | return referenceName;
143 | }
144 | }
145 | }
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Model/Store/ObjectStore.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 96e31bb398d7848a7b758be2fc7b5060
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Model/Store/ResourceNode.cs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Resource Node Script of Unity Network Model
4 | *
5 | * @file ResourceNode.cs
6 | * @author Tobias Lunte, Uwe Gruenefeld
7 | * @version 2020-04-30
8 | *
9 | **/
10 | using System;
11 |
12 | namespace UnityNetworkModel
13 | {
14 | ///
15 | /// Stores specific Resource, tracking its last known state through a hash
16 | ///
17 | internal class ResourceNode : AbstractInjector
18 | {
19 | public UnityEngine.Object resource;
20 | public string name;
21 | public Type type;
22 | public long hash = 0;
23 |
24 | ///
25 | /// Wraps a Resource into a Node
26 | ///
27 | ///
28 | ///
29 | ///
30 | internal ResourceNode(Injector injector, UnityEngine.Object resource, string name) : base(injector)
31 | {
32 | // Check if resource is null
33 | if (resource != null)
34 | {
35 | // Store resource information
36 | this.resource = resource;
37 | this.type = resource.GetType();
38 | }
39 | this.name = name;
40 | }
41 |
42 | ///
43 | /// Updates stored hash of Resource to match current hash
44 | ///
45 | internal void UpdateHash()
46 | {
47 | this.hash = this.injector.serializer.ToSerializableResource(this.resource).GetHash();
48 | }
49 | }
50 | }
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Model/Store/ResourceNode.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 169e51395598d564a8ffe26b8ea20bcd
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Model/Store/ResourceStore.cs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Resource Store Script of Unity Network Model
4 | *
5 | * @file ResourceStore.cs
6 | * @author Tobias Lunte, Uwe Gruenefeld
7 | * @version 2020-05-05
8 | *
9 | **/
10 | using System;
11 | using System.Collections.Specialized;
12 | using UnityEngine;
13 |
14 | namespace UnityNetworkModel
15 | {
16 | ///
17 | /// Collects all known Resources and tracks their last known state.
18 | ///
19 | internal class ResourceStore : OrderedDictionary
20 | {
21 | private Injector injector;
22 |
23 | ///
24 | /// Create a new ResourceStore
25 | ///
26 | ///
27 | internal ResourceStore(Injector injector)
28 | {
29 | this.injector = injector;
30 | }
31 |
32 | ///
33 | /// Adds Resource to store
34 | ///
35 | ///
36 | internal ResourceNode Add(UnityEngine.Object resource)
37 | {
38 | ResourceNode node = new ResourceNode(this.injector, resource, resource.name);
39 | this.Add(resource.name, node);
40 | return node;
41 | }
42 |
43 | ///
44 | /// Adds Resource to store with specific name
45 | ///
46 | ///
47 | ///
48 | ///
49 | internal ResourceNode Add(string name, UnityEngine.Object resource)
50 | {
51 | ResourceNode node = new ResourceNode(this.injector, resource, name);
52 | this.Add(name, node);
53 | return node;
54 | }
55 |
56 | ///
57 | /// Tries to find a Resource of correct name and type by priority
58 | /// 1) A matching tracked Resource from the store.
59 | /// 2) A matching Resource of the correct type from the Resources folder (if using existing resources is enabled).
60 | ///
61 | ///
62 | ///
63 | ///
64 | /// Returns true if a matching Resource was found.
65 | internal bool TryGet(string resourceName, Type type, out ResourceNode node)
66 | {
67 | // Check if ResourceStore contains Resource with name
68 | if (this.Contains(resourceName))
69 | {
70 | // Get ResourceNode for resource with name
71 | ResourceNode resource = (ResourceNode)this[resourceName];
72 |
73 | // Check if ResourceNode is of the correct type
74 | if (resource.resource != null && resource.resource.GetType() == type)
75 | {
76 | node = resource;
77 | return true;
78 | }
79 | }
80 |
81 | // Should existing resources be preferred
82 | if (this.injector.configuration.EXISTINGRESOURCES)
83 | {
84 | // Try to load exsting resource
85 | UnityEngine.Object resource = Resources.Load("NetworkModel/" + resourceName, type);
86 |
87 | // Check if loading of resource failed
88 | if (resource != null)
89 | {
90 | // Create a new ResourceNode
91 | node = new ResourceNode(this.injector, resource, resourceName);
92 | Add(resourceName, node);
93 | return true;
94 | }
95 | }
96 |
97 | // No ResourceNode found
98 | node = null;
99 | return false;
100 | }
101 |
102 | ///
103 | /// Determine name that a Resource should be stored under in the store. Will return current storage name if Resource is already present or new free name if not.
104 | /// Resource's name should be set to returned name if it is to be stored.
105 | ///
106 | ///
107 | /// Name the Resource should be stored under
108 | internal string GetReferenceName(UnityEngine.Object resource)
109 | {
110 | // Check if resource is null
111 | if (resource == null)
112 | return "null";
113 |
114 | // Find the name of the Resource
115 | string referenceName = resource.name;
116 | while (this.Contains(referenceName) && ((ResourceNode)this[referenceName]).resource.GetInstanceID() != resource.GetInstanceID())
117 | referenceName = referenceName + "_" + resource.GetInstanceID().ToString();
118 |
119 | // Return the Resource name
120 | return referenceName;
121 | }
122 | }
123 |
124 | }
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Model/Store/ResourceStore.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 7e30a13f8ab758d4184098c802675e81
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Model/Struct.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 96c7b1dbe7e97ff4aa3331bd2087762c
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Model/Struct/HierarchyUpdate.cs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Hierarchy Update Struct of Unity Network Model
4 | *
5 | * @file HierarchyUpdate.cs
6 | * @author Uwe Gruenefeld
7 | * @version 2020-05-04
8 | *
9 | **/
10 | namespace UnityNetworkModel
11 | {
12 | internal struct HierarchyUpdate
13 | {
14 | public ObjectNode node;
15 | public string parent;
16 |
17 | ///
18 | /// Describes a changed parent for a GameObject
19 | ///
20 | /// ObjectNode
21 | /// The name of the new parent GameObject
22 | internal HierarchyUpdate(ObjectNode node, string parent)
23 | {
24 | this.node = node;
25 | this.parent = parent;
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Model/Struct/HierarchyUpdate.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 72f2565fc7d50a84fb3ab799d096d2d2
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Model/Struct/NameTypePair.cs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Name Type Pair Struct of Unity Network Model
4 | *
5 | * @file NameTypePair.cs
6 | * @author Uwe Gruenefeld
7 | * @version 2020-05-06
8 | *
9 | **/
10 | using System;
11 |
12 | namespace UnityNetworkModel
13 | {
14 | ///
15 | /// Struct to contain a Resource or Component
16 | ///
17 | internal struct NameTypePair : IEquatable
18 | {
19 | public string name { get; }
20 | public Type type { get; }
21 |
22 | ///
23 | /// Creates a NameTypePair
24 | ///
25 | ///
26 | ///
27 | internal NameTypePair(string name, Type type)
28 | {
29 | this.name = name;
30 | this.type = type;
31 | }
32 |
33 | ///
34 | /// Compares NameTypePair to another instance
35 | ///
36 | ///
37 | ///
38 | public bool Equals(NameTypePair other)
39 | {
40 | return this.name.Equals(other.name) && this.type.Equals(other.type);
41 | }
42 |
43 | ///
44 | /// Creates a Hash for NameTypePair
45 | ///
46 | ///
47 | public override int GetHashCode()
48 | {
49 | return this.name.GetHashCode() ^ this.type.GetHashCode();
50 | }
51 |
52 | ///
53 | /// Transforms NameTypePair into string
54 | ///
55 | ///
56 | public override string ToString()
57 | {
58 | return string.Concat("{", this.name, ":", this.type, "}");
59 | }
60 | }
61 | }
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Model/Struct/NameTypePair.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: eb64a98f1d5e7854abb55e95d9368b6d
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Model/Subscriptions.cs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Subscriptions Script of Unity Network Model
4 | *
5 | * @file Subscriptions.cs
6 | * @author Uwe Gruenefeld
7 | * @version 2020-05-05
8 | *
9 | **/
10 | using System.Collections.Generic;
11 | using UnityEngine;
12 |
13 | namespace UnityNetworkModel
14 | {
15 | ///
16 | /// Class to manage subscriptions for sending and receiving updates
17 | ///
18 | internal class Subscriptions : AbstractInjector
19 | {
20 | private string sendChannels;
21 | private string receiveChannels;
22 |
23 | public ISet sendChannelList;
24 | public ISet receiveChannelList;
25 |
26 | public bool isInitialized;
27 |
28 | ///
29 | /// Constructor for new Subscriptions class
30 | ///
31 | ///
32 | // Injector for dependency injection
33 | internal Subscriptions(Injector injector) : base(injector)
34 | {
35 | this.sendChannels = "";
36 | this.receiveChannels = "";
37 |
38 | this.sendChannelList = null;
39 | this.receiveChannelList = null;
40 |
41 | this.isInitialized = false;
42 | }
43 |
44 | ///
45 | /// Method to initialize subscriptions (afterwards channels cannot be changed)
46 | ///
47 | internal void Initialize()
48 | {
49 | this.sendChannels = this.injector.configuration.SENDCHANNELS;
50 | this.receiveChannels = this.injector.configuration.RECEIVECHANNELS;
51 |
52 | this.EnableSend();
53 | this.EnableReceive();
54 |
55 | this.isInitialized = true;
56 |
57 | LogUtility.Log(this.injector, LogType.INFORMATION, "Successful subscribed to channels");
58 | }
59 |
60 | ///
61 | /// Enable/Disable sending updates
62 | ///
63 | internal void UpdateSendingChannel()
64 | {
65 | // If sending updates is enabled and send channels contains none, then add all channel
66 | if(this.injector.configuration.SEND && this.sendChannelList.Count <= 0)
67 | this.EnableSend();
68 |
69 | // If sending updates is disabled and send channels contains some, then remove all channel
70 | if(!this.injector.configuration.SEND && this.sendChannelList.Count > 0)
71 | this.DisableSend();
72 | }
73 |
74 | ///
75 | /// Enable/Disable receiving updates
76 | ///
77 | internal void UpdateReceivingChannel()
78 | {
79 | // If receiving updates is enabled and receive channels is subscribed to none, then subscribe to all channel
80 | if(this.injector.configuration.RECEIVE && this.receiveChannelList.Count <= 0)
81 | this.EnableReceive();
82 |
83 | // If receiving updates is disabled and receive channels is subscribed to some, then unsubscribe from all channel
84 | if(!this.injector.configuration.RECEIVE && this.receiveChannelList.Count > 0)
85 | this.DisableReceive();
86 | }
87 |
88 | ///
89 | /// Enable sending updates
90 | ///
91 | private void EnableSend()
92 | {
93 | this.sendChannelList = new HashSet(this.sendChannels.Split(','));
94 | }
95 |
96 | ///
97 | /// Disable sending updates
98 | ///
99 | private void DisableSend()
100 | {
101 | this.sendChannelList = new HashSet();
102 | }
103 |
104 | ///
105 | /// Enable receiving updates
106 | ///
107 | private void EnableReceive()
108 | {
109 | this.receiveChannelList = new HashSet(this.receiveChannels.Split(','));
110 |
111 | foreach (string channel in this.receiveChannelList)
112 | this.Subscribe(channel);
113 | }
114 |
115 | ///
116 | /// Disable receiving updates
117 | ///
118 | private void DisableReceive()
119 | {
120 | foreach (string channel in this.receiveChannelList)
121 | this.Unsubscribe(channel);
122 | this.receiveChannelList = new HashSet();
123 | }
124 |
125 | ///
126 | /// Subscribe to channel on server
127 | ///
128 | ///
129 | private void Subscribe(string channel)
130 | {
131 | if (channel != "")
132 | this.injector.connection.SendAsync("{\"type\":\"cs\", \"channel\":\"" + channel + "\"}", null);
133 | }
134 |
135 | ///
136 | /// Unsubscribe from channel on server
137 | ///
138 | ///
139 | private void Unsubscribe(string channel)
140 | {
141 | if (channel != "")
142 | this.injector.connection.SendAsync("{\"type\":\"cl\", \"channel\":\"" + channel + "\"}", null);
143 | }
144 | }
145 | }
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Model/Subscriptions.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 8fd57bad369ed774cb136bd5e4cb8557
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Network.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 61eae8581dd6b45c1a91071810c5e612
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Network/Connection.cs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Connection Script of Unity Network Model
4 | *
5 | * @file Connection.cs
6 | * @author Uwe Gruenefeld, Tobias Lunte
7 | * @version 2020-04-30
8 | *
9 | **/
10 | using System;
11 | using WebSocketSharp;
12 | using UnityEngine;
13 |
14 | namespace UnityNetworkModel
15 | {
16 | ///
17 | /// Manages connection to webserver. Provides Sender and Receiver capabilities.
18 | ///
19 | internal class Connection : WebSocket
20 | {
21 | private Injector injector;
22 |
23 | // Variables for websocket connection
24 | private float lastAttempt;
25 | private bool connectingAttempt;
26 |
27 | ///
28 | /// Constructor used to create a new Connection
29 | ///
30 | ///
31 | internal Connection(Injector injector) : base("ws://" + injector.configuration.IP + ":" + injector.configuration.PORT)
32 | {
33 | this.injector = injector;
34 |
35 | this.lastAttempt = -this.injector.configuration.RECONNECT;
36 | this.connectingAttempt = false;
37 | }
38 |
39 | ///
40 | /// Checks whether connection is alive and tries to connect if it isn't. Then returns whether the connection is alive
41 | ///
42 | ///
43 | internal bool EnsureIsAlive()
44 | {
45 | // If the websocket is not alive try to connect to the server
46 | if (!this.IsAlive)
47 | {
48 | this.connectingAttempt = true;
49 |
50 | // Check if last attempt to connect is at least one Reconnect Period ago
51 | if (Time.realtimeSinceStartup > this.lastAttempt + this.injector.configuration.RECONNECT)
52 | {
53 | LogUtility.Log(this.injector, LogType.INFORMATION, "Attempt to connect to server");
54 |
55 | try
56 | {
57 | // Connect to the server
58 | this.ConnectAsync();
59 | this.lastAttempt = Time.realtimeSinceStartup;
60 | }
61 | catch (Exception)
62 | {
63 | LogUtility.Log(this.injector, LogType.ERROR, "Unable to connect to server");
64 | }
65 | }
66 | }
67 | else
68 | {
69 | // If there was a recent connecting attempt, it was successful
70 | if (this.connectingAttempt)
71 | {
72 | this.connectingAttempt = false;
73 | LogUtility.Log(this.injector, LogType.INFORMATION, "Successfully connected to server");
74 | }
75 | }
76 |
77 | // Return if websocket is alive
78 | return this.IsAlive;
79 | }
80 |
81 | ///
82 | /// Asynchronously send Request to the server
83 | ///
84 | ///
85 | internal void SendRequest(Request request)
86 | {
87 | // Send request to every channel
88 | foreach(string channel in this.injector.subscriptions.sendChannelList)
89 | {
90 | // Set channel of request
91 | request.channel = channel;
92 |
93 | // Refresh timestamp
94 | request.RefreshTimestamp();
95 |
96 | // Send request
97 | string json = JsonUtility.ToJson(request);
98 | if(this.injector.configuration.DEBUGSEND)
99 | LogUtility.Log("Sent message " + json);
100 | this.SendAsync(json, null);
101 | }
102 | }
103 |
104 | ///
105 | /// Handler for new Requests from the server. Simply enqueues them to be applied during the next ApplyChanges().
106 | ///
107 | ///
108 | internal void ReceiveRequest(string json)
109 | {
110 | if(this.injector.configuration.DEBUGRECEIVE)
111 | LogUtility.Log("Received message " + json);
112 |
113 | // Remove empty parameter
114 | json = json.Replace(",\"string1\":\"\"", "");
115 | json = json.Replace(",\"string2\":\"\"", "");
116 |
117 | this.injector.model.AddRequest(JsonUtility.FromJson(json));
118 | }
119 | }
120 | }
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Network/Connection.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: ac57aed60e6b8461b8419fa02538d42e
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Network/Request.cs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Request Script of Unity Network Model
4 | *
5 | * @file Request.cs
6 | * @author Uwe Gruenefeld, Tobias Lunte
7 | * @version 2020-05-05
8 | *
9 | **/
10 | using System;
11 | using System.Collections.Generic;
12 | using UnityEngine;
13 |
14 | namespace UnityNetworkModel
15 | {
16 | ///
17 | /// Request for changes to Objects, Components and Resources to be sent between Client and Server
18 | ///
19 | [Serializable]
20 | internal class Request : ISerializationCallbackReceiver
21 | {
22 | private Injector injector;
23 |
24 | // Types of request
25 | public const string RESOURCE = "r";
26 | public const string OBJECT = "o";
27 | public const string COMPONENT = "c";
28 |
29 | public const string UPDATE = "u";
30 | public const string DELETE = "d";
31 |
32 | // Parameters used by all requests
33 | [NonSerialized]
34 | public string messageType;
35 | [NonSerialized]
36 | public string updateType;
37 | public string type;
38 | public string name;
39 | public string channel;
40 | public long timestamp;
41 |
42 | [NonSerialized]
43 | public int iteration;
44 |
45 | // Human-readable parameters for specific types of request
46 | [NonSerialized]
47 | public string parent;
48 | [NonSerialized]
49 | public AbstractResource resource;
50 | [NonSerialized]
51 | public Type resourceType;
52 | [NonSerialized]
53 | public List components;
54 | [NonSerialized]
55 | public List componentTypes;
56 |
57 | // Serialized parameters that human-readable parameters are mapped to while sending over the network
58 | public List string1;
59 | public List string2;
60 |
61 | ///
62 | /// Common constructor used by static Request-generating methdos
63 | ///
64 | ///
65 | ///
66 | ///
67 | ///
68 | private Request(Injector injector, string messageType, string updateType, string name)
69 | {
70 | this.injector = injector;
71 | this.messageType = messageType;
72 | this.updateType = updateType;
73 | this.name = name;
74 |
75 | this.channel = "";
76 | this.iteration = 0;
77 |
78 | this.RefreshTimestamp();
79 | }
80 |
81 | ///
82 | /// Refreshes current timestamp
83 | ///
84 | internal void RefreshTimestamp()
85 | {
86 | if (injector.configuration.TIME)
87 | this.timestamp = DateTime.Now.ToUniversalTime().ToBinary();
88 | else
89 | this.timestamp = 0;
90 | }
91 |
92 | ///
93 | /// Create Request to update specific GameObject
94 | ///
95 | ///
96 | ///
97 | /// Request
98 | internal static Request UpdateObject(Injector injector, GameObject gameObject)
99 | {
100 | Request request = new Request(injector, Request.OBJECT, Request.UPDATE, gameObject.name);
101 | request.parent = gameObject.transform.parent.name;
102 |
103 | // If the Parent GameObject is the GameObject with the NetworkModel Configuration attached, then assign the Alias Name of the root GameObject
104 | if (request.parent == injector.configuration.gameObject.name)
105 | request.parent = Model.ROOT_NAME;
106 |
107 | return request;
108 | }
109 |
110 | ///
111 | /// Create Request to delete specific GameObject
112 | ///
113 | ///
114 | ///
115 | /// Request
116 | internal static Request DeleteObject(Injector injector, string name)
117 | {
118 | return new Request(injector, Request.OBJECT, Request.DELETE, name);
119 | }
120 |
121 |
122 | ///
123 | /// Create Request to update a specific Resource
124 | ///
125 | ///
126 | ///
127 | ///
128 | ///
129 | /// Request
130 | internal static Request UpdateResource(Injector injector, string name, Type resourceType, AbstractResource resource)
131 | {
132 | Request request = new Request(injector, Request.RESOURCE, Request.UPDATE, name);
133 | request.resource = resource;
134 | request.resourceType = resourceType;
135 | return request;
136 | }
137 |
138 | ///
139 | /// Create Request to delete a specific Resource
140 | ///
141 | ///
142 | ///
143 | /// Request
144 | internal static Request DeleteResource(Injector injector, string name)
145 | {
146 | return new Request(injector, Request.RESOURCE, Request.DELETE, name);
147 | }
148 |
149 | ///
150 | /// Create Request to update a List of Components belonging to a specific GameObject
151 | ///
152 | ///
153 | ///
154 | ///
155 | /// Request
156 | internal static Request UpdateComponents(Injector injector, string name, List components)
157 | {
158 | Request request = new Request(injector, Request.COMPONENT, Request.UPDATE, name);
159 | request.components = components;
160 | return request;
161 | }
162 |
163 | ///
164 | /// Create Request to delete a List of Components belonging to a specific GameObject
165 | ///
166 | ///
167 | ///
168 | ///
169 | /// Request
170 | internal static Request DeleteComponents(Injector injector, string name, List types)
171 | {
172 | Request request = new Request(injector, Request.COMPONENT, Request.DELETE, name);
173 | request.componentTypes = types;
174 | return request;
175 | }
176 |
177 | ///
178 | /// Before the request is sent to the server, packs human-readable parameters into serializable parameters
179 | ///
180 | public void OnBeforeSerialize()
181 | {
182 | this.type = this.messageType + this.updateType;
183 | switch (type)
184 | {
185 | case Request.RESOURCE + Request.UPDATE:
186 | this.string1 = new List() { this.EncodeClass(resourceType.ToString()) };
187 | this.string2 = new List() { JsonUtility.ToJson(resource) };
188 | break;
189 | case Request.OBJECT + Request.UPDATE:
190 | this.string1 = new List() { this.parent };
191 | break;
192 | case Request.COMPONENT + Request.UPDATE:
193 | this.string1 = new List();
194 | this.string2 = new List();
195 | foreach (AbstractComponent component in this.components)
196 | {
197 | this.string1.Add(this.EncodeClass(component.GetType().ToString()));
198 | this.string2.Add(JsonUtility.ToJson(component));
199 | }
200 | break;
201 | case Request.COMPONENT + Request.DELETE:
202 | this.string1 = new List();
203 | foreach (Type type in this.componentTypes)
204 | {
205 | this.string1.Add(this.EncodeClass(type.ToString()));
206 | }
207 | break;
208 | }
209 | }
210 |
211 | ///
212 | /// Encodes a String representing a NetworkModel class into a string representing a UnityEngine class
213 | ///
214 | ///
215 | private String EncodeClass(String name)
216 | {
217 | return name.Replace("UnityNetworkModel.", "").Replace("Serializable", "");
218 | }
219 |
220 | ///
221 | /// After the response is received from the server, unpacks serialized parameters into human-readable parameters
222 | ///
223 | public void OnAfterDeserialize()
224 | {
225 | this.messageType = this.type.Substring(0, 1);
226 | this.updateType = this.type.Substring(1, 1);
227 | switch (type)
228 | {
229 | case Request.RESOURCE + Request.UPDATE:
230 | this.resourceType = Type.GetType(this.DecodeClass(string1[0]));
231 | this.resource = (AbstractResource)JsonUtility.FromJson(this.string2[0], this.resourceType);
232 | break;
233 | case Request.OBJECT + Request.UPDATE:
234 | this.parent = this.string1[0];
235 | break;
236 | case Request.COMPONENT + Request.UPDATE:
237 | this.components = new List();
238 | for (int i = 0; i < this.string1.Count && i < this.string2.Count; i++)
239 | {
240 | Type type = Type.GetType(this.DecodeClass(this.string1[i]));
241 | this.components.Add((AbstractComponent)JsonUtility.FromJson(this.string2[i], type));
242 | }
243 | break;
244 | case Request.COMPONENT + Request.DELETE:
245 | this.componentTypes = new List();
246 | foreach (string typeName in string1)
247 | {
248 | this.componentTypes.Add(Type.GetType(this.DecodeClass(typeName)));
249 | }
250 | break;
251 | }
252 | }
253 |
254 | ///
255 | /// Encodes a String representing a UnityEngine class into a string representing a NetworkModel class
256 | ///
257 | ///
258 | private String DecodeClass(String name)
259 | {
260 | return "UnityNetworkModel." + name + "Serializable";
261 | }
262 | }
263 | }
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Network/Request.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: a82619ed78bdd48cbbdc6702a9cff8c2
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/NetworkModelConfiguration.cs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Main Script of Unity Network Model
4 | *
5 | * Attach this script to a GameObject in Unity
6 | * All children of that GameObject can be synchronized with the server
7 | *
8 | * Currently supported components are
9 | * - BoxCollider
10 | * - Camera
11 | * - Light
12 | * - LineRenderer
13 | * - MeshCollider
14 | * - MeshFilter
15 | * - MeshRenderer
16 | * - Script
17 | * - SphereCollider
18 | * - Transform
19 | *
20 | * Currently supported ressources are
21 | * - Material
22 | * - Mesh
23 | * - Texture2D
24 | *
25 | * @file NetworkModel.cs
26 | * @author Uwe Gruenefeld, Tobias Lunte
27 | * @version 2020-05-04
28 | *
29 | **/
30 | using System.Collections;
31 | using UnityEngine;
32 |
33 | namespace UnityNetworkModel
34 | {
35 | ///
36 | /// Configuration class of the UnityNetworkModel
37 | ///
38 | // Update the name of the component in the title and component menu
39 | [AddComponentMenu("NetworkModel/NetworkModel Configuration")]
40 | public class NetworkModelConfiguration : MonoBehaviour
41 | {
42 | // Connection
43 | public string IP = "127.0.0.1"; // Cannot be changed during runtime
44 | public int PORT = 8080; // Cannot be changed during runtime
45 | public float RECONNECT = 1;
46 | public float DELAY = 0.1f;
47 |
48 | // Settings
49 | public bool TIME = false;
50 | public bool SEND = true;
51 | public bool RECEIVE = true;
52 | public bool EXISTINGOBJECTS = false;
53 | public bool EXISTINGRESOURCES = false;
54 |
55 | // Channel
56 | public string SENDCHANNELS = "default"; // Cannot be changed during runtime
57 | public string RECEIVECHANNELS = "default"; // Cannot be changed during runtime
58 |
59 | // Rules Resources
60 |
61 | // Material
62 | public bool enableMaterial = true;
63 | public bool sendMaterial = true;
64 | public bool receiveMaterial = true;
65 |
66 | // Mesh
67 | public bool enableMesh = true;
68 | public bool sendMesh = true;
69 | public bool receiveMesh = true;
70 |
71 | // Texture2D
72 | public bool enableTexture2D = true;
73 | public bool sendTexture2D = true;
74 | public bool receiveTexture2D = true;
75 |
76 | // Debugging
77 | public LogType DEBUGLEVEL = LogType.DISABLED;
78 | public bool DEBUGSEND = false;
79 | public bool DEBUGRECEIVE = false;
80 |
81 | // Injector
82 | private Injector injector;
83 |
84 | // Variables for coroutines
85 | private int numberOfCoroutines;
86 | private bool isCoroutineRunning;
87 |
88 | ///
89 | /// Start method from MonoBehaviour
90 | ///
91 | void Start()
92 | {
93 | // Similar to dependency injection
94 | this.injector = new Injector(this);
95 |
96 | // Storage for (game)objects and resources
97 | this.injector.objectStore = new ObjectStore(this.injector);
98 | // Add the GameObject which contains this script as root GameObject to the ObjectStore
99 | this.injector.objectStore.Add(Model.ROOT_NAME, this.gameObject);
100 | this.injector.resourceStore = new ResourceStore(this.injector);
101 | this.injector.resourceStore.Add("null", null);
102 |
103 | // Handles serialization
104 | this.injector.serializer = new Serializer(this.injector);
105 |
106 | // Handles the complete data model
107 | this.injector.model = Model.CreateModel(this.injector);
108 |
109 | // Handles the connection to the server
110 | this.injector.connection = new Connection(this.injector);
111 | this.injector.connection.OnMessage += (sender, message) => this.injector.connection.ReceiveRequest(message.Data);
112 |
113 | // Handles subscriptions
114 | this.injector.subscriptions = new Subscriptions(this.injector);
115 |
116 |
117 | // Initialize variables for coroutines
118 | this.numberOfCoroutines = 0;
119 | this.isCoroutineRunning = false;
120 | }
121 |
122 | ///
123 | /// Update method from MonoBehaviour
124 | ///
125 | void Update()
126 | {
127 | // Start synchronization coroutine
128 | if (!this.isCoroutineRunning)
129 | StartCoroutine(Synchronize());
130 | }
131 |
132 | ///
133 | /// Coroutine to synchronize NetworkModel with server
134 | ///
135 | IEnumerator Synchronize()
136 | {
137 | // Coroutine running
138 | this.isCoroutineRunning = true;
139 | this.numberOfCoroutines++;
140 |
141 | // Try to establish connection, only proceed if successful
142 | if (this.injector.connection.EnsureIsAlive())
143 | {
144 | // If subscriptions are not initialized, then initialize them
145 | if (!this.injector.subscriptions.isInitialized)
146 | this.injector.subscriptions.Initialize();
147 |
148 | // Subscribe and unsubscribe from receiving updates on channel
149 | this.injector.subscriptions.UpdateReceivingChannel();
150 |
151 | // Apply change-requests that were received from the server since the last update
152 | if (this.RECEIVE)
153 | this.injector.model.ApplyChanges();
154 |
155 | yield return null;
156 |
157 | // Subscribe and unsubscribe from sending updates on channel
158 | this.injector.subscriptions.UpdateSendingChannel();
159 |
160 | // Send change-requests for modifications since last update to the server
161 | if (this.SEND)
162 | this.injector.model.TrackChanges();
163 | };
164 |
165 | // Insert time between updates
166 | yield return new WaitForSeconds(this.DELAY);
167 |
168 | // Check if this is the last coroutine
169 | this.numberOfCoroutines--;
170 | this.isCoroutineRunning = this.numberOfCoroutines != 0;
171 |
172 | // Finish coroutine
173 | yield return null;
174 | }
175 |
176 | ///
177 | /// OnDestory method from MonoBehaviour
178 | ///
179 | void OnDestroy()
180 | {
181 | // Close websocket connection
182 | if (this.injector != null)
183 | {
184 | Connection connection = this.injector.connection;
185 | if (connection != null)
186 | connection.CloseAsync();
187 | }
188 |
189 | LogUtility.Log(this.injector, LogType.INFORMATION, "Successfully disconnected from server");
190 | }
191 | }
192 | }
193 |
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/NetworkModelConfiguration.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 93b7197a2cb765943aa63b41f39958a3
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/NetworkModelRule.cs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Network Model Rule of Unity Network Model
4 | *
5 | * @file NetworkModelRule.cs
6 | * @author Uwe Gruenefeld
7 | * @version 2020-05-04
8 | *
9 | **/
10 | using UnityEngine;
11 |
12 | namespace UnityNetworkModel
13 | {
14 | ///
15 | /// Rule class of the UnityNetworkModel
16 | ///
17 | // Update the name of the component in the title and component menu
18 | [AddComponentMenu("NetworkModel/NetworkModel Rule")]
19 | public class NetworkModelRule : MonoBehaviour
20 | {
21 | // Scope
22 | public bool applyToObject = false;
23 | public bool applyToChildren = true;
24 |
25 | // Settings
26 | public int decimalPlaces = 5;
27 |
28 | // Rules Components
29 |
30 | // BoxCollider
31 | public bool enableBoxCollider;
32 | public bool sendBoxCollider;
33 | public bool receiveBoxCollider;
34 |
35 | // Camera
36 | public bool enableCamera;
37 | public bool sendCamera;
38 | public bool receiveCamera;
39 |
40 | // Light
41 | public bool enableLight;
42 | public bool sendLight;
43 | public bool receiveLight;
44 |
45 | // LineRenderer
46 | public bool enableLineRenderer;
47 | public bool sendLineRenderer;
48 | public bool receiveLineRenderer;
49 |
50 | // MeshCollider
51 | public bool enableMeshCollider;
52 | public bool sendMeshCollider;
53 | public bool receiveMeshCollider;
54 |
55 | // MeshFilter
56 | public bool enableMeshFilter;
57 | public bool sendMeshFilter;
58 | public bool receiveMeshFilter;
59 |
60 | // MeshRenderer
61 | public bool enableMeshRenderer;
62 | public bool sendMeshRenderer;
63 | public bool receiveMeshRenderer;
64 |
65 | // Script
66 | public bool enableScript;
67 | public bool sendScript;
68 | public bool receiveScript;
69 |
70 | // SphereCollider
71 | public bool enableSphereCollider;
72 | public bool sendSphereCollider;
73 | public bool receiveSphereCollider;
74 |
75 | // Transform
76 | public bool enableTransform;
77 | public bool sendTransform;
78 | public bool receiveTransform;
79 | }
80 | }
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/NetworkModelRule.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: d07266e346aa1d4408de093c015f09d6
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Utilities.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: b4f79d759badc3042828bb07abdd9891
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Utilities/CompressionUtility.cs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Compression Utility of Unity Network Model
4 | *
5 | * @file CompressionUtility.cs
6 | * @author Uwe Gruenefeld, Tobias Lunte
7 | * @version 2020-05-04
8 | *
9 | **/
10 | using System;
11 | using UnityEngine;
12 |
13 | namespace UnityNetworkModel
14 | {
15 | ///
16 | /// Utility class with functions related to Compression
17 | ///
18 | internal static class CompressionUtility
19 | {
20 | ///
21 | /// Compress an array of Color
22 | ///
23 | ///
24 | ///
25 | ///
26 | internal static Color[] Compress(GameObject gameObject, Color[] value)
27 | {
28 | int places = RuleUtility.FindDecimalPlaces(gameObject);
29 |
30 | Color[] result = new Color[value.Length];
31 |
32 | for(int i=0; i < value.Length && i < result.Length; i++)
33 | result[i] = Compress(places, value[i]);
34 |
35 | return result;
36 | }
37 |
38 | ///
39 | /// Compress a Color
40 | ///
41 | ///
42 | ///
43 | ///
44 | internal static Color Compress(GameObject gameObject, Color value)
45 | {
46 | int places = RuleUtility.FindDecimalPlaces(gameObject);
47 | return Compress(places, value);
48 | }
49 |
50 | ///
51 | /// Compress a Color based on given decimal places
52 | ///
53 | ///
54 | ///
55 | ///
56 | private static Color Compress(int places, Color value)
57 | {
58 | value.r = Compress(places, value.b);
59 | value.g = Compress(places, value.g);
60 | value.b = Compress(places, value.b);
61 | value.a = Compress(places, value.a);
62 |
63 | return value;
64 | }
65 |
66 | ///
67 | /// Compress an array of Vector3
68 | ///
69 | ///
70 | ///
71 | ///
72 | internal static Vector3[] Compress(GameObject gameObject, Vector3[] value)
73 | {
74 | int places = RuleUtility.FindDecimalPlaces(gameObject);
75 |
76 | Vector3[] result = new Vector3[value.Length];
77 |
78 | for(int i=0; i < value.Length && i < result.Length; i++)
79 | result[i] = Compress(places, value[i]);
80 |
81 | return result;
82 | }
83 |
84 | ///
85 | /// Compress a Vector3
86 | ///
87 | ///
88 | ///
89 | ///
90 | internal static Vector3 Compress(GameObject gameObject, Vector3 value)
91 | {
92 | int places = RuleUtility.FindDecimalPlaces(gameObject);
93 | return Compress(places, value);
94 | }
95 |
96 | ///
97 | /// Compress a Vector3 based on given decimal places
98 | ///
99 | ///
100 | ///
101 | ///
102 | private static Vector3 Compress(int places, Vector3 value)
103 | {
104 | value.x = Compress(places, value.x);
105 | value.y = Compress(places, value.y);
106 | value.z = Compress(places, value.z);
107 |
108 | return value;
109 | }
110 |
111 | ///
112 | /// Compress an array of Vector2
113 | ///
114 | ///
115 | ///
116 | ///
117 | internal static Vector2[] Compress(GameObject gameObject, Vector2[] value)
118 | {
119 | int places = RuleUtility.FindDecimalPlaces(gameObject);
120 |
121 | Vector2[] result = new Vector2[value.Length];
122 |
123 | for(int i=0; i < value.Length && i < result.Length; i++)
124 | result[i] = Compress(places, value[i]);
125 |
126 | return result;
127 | }
128 |
129 | ///
130 | /// Compress a Vector2
131 | ///
132 | ///
133 | ///
134 | ///
135 | internal static Vector2 Compress(GameObject gameObject, Vector2 value)
136 | {
137 | int places = RuleUtility.FindDecimalPlaces(gameObject);
138 | return Compress(places, value);
139 | }
140 |
141 | ///
142 | /// Compress a Vector2 based on given decimal places
143 | ///
144 | ///
145 | ///
146 | ///
147 | private static Vector2 Compress(int places, Vector2 value)
148 | {
149 | value.x = Compress(places, value.x);
150 | value.y = Compress(places, value.y);
151 |
152 | return value;
153 | }
154 |
155 | ///
156 | /// Compress a float value
157 | ///
158 | ///
159 | ///
160 | ///
161 | internal static float Compress(GameObject gameObject, float value)
162 | {
163 | int places = RuleUtility.FindDecimalPlaces(gameObject);
164 | return Compress(places, value);
165 | }
166 |
167 | ///
168 | /// Compress a float value based on given decimal places
169 | ///
170 | ///
171 | ///
172 | ///
173 | private static float Compress(int places, float value)
174 | {
175 | // Maximum compression allows one decimal place
176 | if(places <= 0)
177 | places = 1;
178 |
179 | // Compress value according to decimal places
180 | int factor = (int)Math.Pow(10, places);
181 | return (float)(Math.Truncate(value * factor) / (float)factor);
182 | }
183 | }
184 | }
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Utilities/CompressionUtility.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 7764ec350f828c648a945d01a5d46cb1
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Utilities/HashUtility.cs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Hashes Utility of Unity Network Model
4 | *
5 | * @file HashUtility.cs
6 | * @author Uwe Gruenefeld, Tobias Lunte
7 | * @version 2020-05-04
8 | *
9 | **/
10 | namespace UnityNetworkModel
11 | {
12 | ///
13 | /// Utility class with functions related to Hashes
14 | ///
15 | internal static class HashUtility
16 | {
17 | ///
18 | /// Utility function to create order-dependent hash from two hashes. Collisions unlikely if original hashes are already well-distibuted.
19 | ///
20 | ///
21 | ///
22 | ///
23 | internal static long Combine2Hashes(long h1, long h2)
24 | {
25 | return h1 * 31 + h2;
26 | }
27 |
28 | ///
29 | /// Utility function to create order-dependent hash from multiple hashes. Collisions unlikely if original hashes are already well-distibuted.
30 | ///
31 | ///
32 | ///
33 | internal static long CombineHashes(params long[] hashes)
34 | {
35 | long hash = 17;
36 |
37 | foreach (long h in hashes)
38 | {
39 | hash = HashUtility.Combine2Hashes(hash, h);
40 | }
41 |
42 | return hash;
43 | }
44 | }
45 | }
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Utilities/HashUtility.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e29f9e6b8b05f894da6974aec1f3f249
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Utilities/LogUtility.cs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Log Utility of Unity Network Model
4 | *
5 | * @file LogUtility.cs
6 | * @author Uwe Gruenefeld
7 | * @version 2020-05-05
8 | *
9 | **/
10 | using System;
11 | using UnityEngine;
12 |
13 | namespace UnityNetworkModel
14 | {
15 | ///
16 | /// Utility class with functions related to Logging
17 | ///
18 | internal static class LogUtility
19 | {
20 | ///
21 | /// Log message if logType is allowed in debug level
22 | ///
23 | internal static void Log(Injector injector, LogType logType, String message)
24 | {
25 | // Check if message should not get logged
26 | if((ushort)injector.configuration.DEBUGLEVEL < (ushort)logType)
27 | return;
28 |
29 | switch(logType)
30 | {
31 | case LogType.ERROR:
32 | Debug.LogError("NetworkModel: " + message);
33 | break;
34 | case LogType.WARNING:
35 | Debug.LogWarning("NetworkModel: " + message);
36 | break;
37 | case LogType.INFORMATION:
38 | Debug.Log("NetworkModel: " + message);
39 | break;
40 | }
41 | }
42 |
43 | ///
44 | /// Log message
45 | ///
46 | internal static void Log(String message)
47 | {
48 | Debug.Log("NetworkModel: " + message);
49 | }
50 | }
51 | }
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Utilities/LogUtility.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e9ee1de675b697b4b856dc906cf23981
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Utilities/RuleUtility.cs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Hierarchy Utility of Unity Network Model
4 | *
5 | * @file HierarchyUtility.cs
6 | * @author Uwe Gruenefeld
7 | * @version 2020-05-04
8 | *
9 | **/
10 | using System;
11 | using UnityEngine;
12 |
13 | namespace UnityNetworkModel
14 | {
15 | ///
16 | /// Utility class with functions related to Hierarchy
17 | ///
18 | internal static class RuleUtility
19 | {
20 | internal static int DEFAULT_DECIMAL_PLACES = 5;
21 | internal static bool DEFAULT_RULE = false;
22 |
23 | ///
24 | /// Function to find valid decimal places for GanmeObject
25 | ///
26 | ///
27 | ///
28 | internal static int FindDecimalPlaces(GameObject gameObject)
29 | {
30 | // Find relevant deviation
31 | Transform pointer = gameObject.transform;
32 |
33 | do
34 | {
35 | // See if current GameObject has a NetworkModel Rule component
36 | NetworkModelRule networkModelRule = pointer.GetComponent();
37 |
38 | // If true, then a rule was found
39 | if (networkModelRule != null)
40 | {
41 | // Check if the Rule was found in the passed GameObject
42 | if (gameObject.transform == pointer)
43 | {
44 | // Check if the Rule is active for the GameObject it is attached to
45 | if (networkModelRule.applyToObject)
46 | return networkModelRule.decimalPlaces;
47 | else
48 | {
49 | // Rule does not apply, continue with parent GameObject
50 | pointer = pointer.parent;
51 | continue;
52 | }
53 | }
54 | // ELse, the Rule was found in a parent GameObject
55 | else
56 | {
57 | // Check if the Rule is active for the GameObject it is attached to
58 | if (networkModelRule.applyToChildren)
59 | return networkModelRule.decimalPlaces;
60 | else
61 | {
62 | // Rule does not apply, continue with parent GameObject
63 | pointer = pointer.parent;
64 | continue;
65 | }
66 | }
67 | }
68 |
69 | // Go one GameObject up in Hierarchy
70 | pointer = pointer.parent;
71 |
72 | } while (pointer != null);
73 |
74 | // Default value
75 | return RuleUtility.DEFAULT_DECIMAL_PLACES;
76 | }
77 |
78 | ///
79 | /// Function to find valid rule for Component from GameObject
80 | ///
81 | ///
82 | ///
83 | ///
84 | ///
85 | ///
86 | internal static bool FindComponentRule(Injector injector, GameObject gameObject, Type type, UpdateType updateType)
87 | {
88 | // Find relevant rule
89 | Transform pointer = gameObject.transform;
90 |
91 | do
92 | {
93 | // See if current GameObject has a NetworkModel Rule component
94 | NetworkModelRule networkModelRule = pointer.GetComponent();
95 |
96 | // If true, then a rule was found
97 | if (networkModelRule != null)
98 | {
99 | // Check if the Rule was found in the passed GameObject
100 | if (gameObject.transform == pointer)
101 | {
102 | // Check if the Rule is active for the GameObject it is attached to
103 | if (networkModelRule.applyToObject)
104 | {
105 | // Get the correct Rule
106 | RuleType ruleType = CheckComponentRule(networkModelRule, type, updateType);
107 |
108 | // Check, if Rule is enabled
109 | if (ruleType != RuleType.DISABLED)
110 | return ruleType.ToBool();
111 | }
112 | else
113 | {
114 | // Rule does not apply, continue with parent GameObject
115 | pointer = pointer.parent;
116 | continue;
117 | }
118 | }
119 | // ELse, the Rule was found in a parent GameObject
120 | else
121 | {
122 | // Check if the Rule is active for the GameObject it is attached to
123 | if (networkModelRule.applyToChildren)
124 | {
125 | // Get the correct Rule
126 | RuleType ruleType = CheckComponentRule(networkModelRule, type, updateType);
127 |
128 | // Check, if Rule is enabled
129 | if (ruleType != RuleType.DISABLED)
130 | return ruleType.ToBool();
131 | }
132 | else
133 | {
134 | // Rule does not apply, continue with parent GameObject
135 | pointer = pointer.parent;
136 | continue;
137 | }
138 | }
139 | }
140 |
141 | // Go one GameObject up in Hierarchy
142 | pointer = pointer.parent;
143 |
144 | } while (pointer != null);
145 |
146 | LogUtility.Log(injector, LogType.INFORMATION, "No active rule found for Type " + type);
147 |
148 | // Default value
149 | return RuleUtility.DEFAULT_RULE;
150 | }
151 |
152 | ///
153 | /// Function to find valid rule for Component type
154 | ///
155 | ///
156 | ///
157 | ///
158 | ///
159 | private static RuleType CheckComponentRule(NetworkModelRule networkModelRule, Type type, UpdateType updateType)
160 | {
161 | // If Type is BoxCollider
162 | if (type == typeof(BoxCollider) || type.IsSubclassOf(typeof(BoxCollider)))
163 | {
164 | return CheckEntry(networkModelRule.enableBoxCollider, networkModelRule.sendBoxCollider, networkModelRule.receiveBoxCollider, updateType);
165 | }
166 | // Else, if Type is Camera
167 | else if (type == typeof(Camera) || type.IsSubclassOf(typeof(Camera)))
168 | {
169 | return CheckEntry(networkModelRule.enableCamera, networkModelRule.sendCamera, networkModelRule.receiveCamera, updateType);
170 | }
171 | // Else, if Type is Light
172 | else if (type == typeof(Light) || type.IsSubclassOf(typeof(Light)))
173 | {
174 | return CheckEntry(networkModelRule.enableLight, networkModelRule.sendLight, networkModelRule.receiveLight, updateType);
175 | }
176 | // Else, if Type is LineRenderer
177 | else if (type == typeof(LineRenderer) || type.IsSubclassOf(typeof(LineRenderer)))
178 | {
179 | return CheckEntry(networkModelRule.enableLineRenderer, networkModelRule.sendLineRenderer, networkModelRule.receiveLineRenderer, updateType);
180 | }
181 | // Else, if Type is MeshCollider
182 | else if (type == typeof(MeshCollider) || type.IsSubclassOf(typeof(MeshCollider)))
183 | {
184 | return CheckEntry(networkModelRule.enableMeshCollider, networkModelRule.sendMeshCollider, networkModelRule.receiveMeshCollider, updateType);
185 | }
186 | // Else, if Type is MeshFilter
187 | else if (type == typeof(MeshFilter) || type.IsSubclassOf(typeof(MeshFilter)))
188 | {
189 | return CheckEntry(networkModelRule.enableMeshFilter, networkModelRule.sendMeshFilter, networkModelRule.receiveMeshFilter, updateType);
190 | }
191 | // Else, if Type is MeshRenderer
192 | else if (type == typeof(MeshRenderer) || type.IsSubclassOf(typeof(MeshRenderer)))
193 | {
194 | return CheckEntry(networkModelRule.enableMeshRenderer, networkModelRule.sendMeshRenderer, networkModelRule.receiveMeshRenderer, updateType);
195 | }
196 | // Else, if Type is MonoBehaviour(Script)
197 | else if (type.IsSubclassOf(typeof(MonoBehaviour)))
198 | {
199 | return CheckEntry(networkModelRule.enableScript, networkModelRule.sendScript, networkModelRule.receiveScript, updateType);
200 | }
201 | // Else, if Type is SphereCollider
202 | else if (type == typeof(SphereCollider) || type.IsSubclassOf(typeof(SphereCollider)))
203 | {
204 | return CheckEntry(networkModelRule.enableSphereCollider, networkModelRule.sendSphereCollider, networkModelRule.receiveSphereCollider, updateType);
205 | }
206 | // Else, if Type is Transform
207 | else if (type == typeof(Transform) || type.IsSubclassOf(typeof(Transform)))
208 | {
209 | return CheckEntry(networkModelRule.enableTransform, networkModelRule.sendTransform, networkModelRule.receiveTransform, updateType);
210 | }
211 |
212 | return RuleType.DISABLED;
213 | }
214 |
215 | ///
216 | /// Function to find valid rule for Resource
217 | ///
218 | ///
219 | ///
220 | ///
221 | ///
222 | internal static bool FindResourceRule(Injector injector, Type type, UpdateType updateType)
223 | {
224 | RuleType result = RuleType.DISABLED;
225 |
226 | // If Type is Material
227 | if (type == typeof(Material) || type.IsSubclassOf(typeof(Material)))
228 | {
229 | result = CheckEntry(injector.configuration.enableMaterial, injector.configuration.sendMaterial, injector.configuration.receiveMaterial, updateType);
230 | }
231 |
232 | // Else, if Type is Mesh
233 | else if (type == typeof(Mesh) || type.IsSubclassOf(typeof(Mesh)))
234 | {
235 | result = CheckEntry(injector.configuration.enableMesh, injector.configuration.sendMesh, injector.configuration.receiveMesh, updateType);
236 | }
237 |
238 | // Else, if Type is Texture2D
239 | else if (type == typeof(Texture2D) || type.IsSubclassOf(typeof(Texture2D)))
240 | {
241 | result = CheckEntry(injector.configuration.enableTexture2D, injector.configuration.sendTexture2D, injector.configuration.receiveTexture2D, updateType);
242 | }
243 |
244 | // Check, if Rule is enabled
245 | if (result != RuleType.DISABLED)
246 | return result.ToBool();
247 |
248 | // Default case
249 | return false;
250 | }
251 |
252 | ///
253 | /// Function to check boolean values if the underlying rule is valid
254 | ///
255 | ///
256 | ///
257 | ///
258 | ///
259 | ///
260 | private static RuleType CheckEntry(bool enable, bool send, bool receive, UpdateType updateType)
261 | {
262 | // Check if rule for this Type is not enabled
263 | if (!enable)
264 | return RuleType.DISABLED;
265 |
266 | // Check the status of the enabled rule
267 | switch (updateType)
268 | {
269 | case UpdateType.SEND:
270 | return RuleTypeExtension.FromBool(send);
271 | case UpdateType.RECEIVE:
272 | return RuleTypeExtension.FromBool(receive);
273 | }
274 |
275 | // Default case
276 | return RuleType.DISABLED;
277 | }
278 | }
279 | }
--------------------------------------------------------------------------------
/client/unity/Assets/Scripts/NetworkModel/Utilities/RuleUtility.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 60984589b5c28ca44bdcb8bae2b99d74
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/client/unity/ProjectSettings/AudioManager.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!11 &1
4 | AudioManager:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 2
7 | m_Volume: 1
8 | Rolloff Scale: 1
9 | Doppler Factor: 1
10 | Default Speaker Mode: 2
11 | m_SampleRate: 0
12 | m_DSPBufferSize: 1024
13 | m_VirtualVoiceCount: 512
14 | m_RealVoiceCount: 32
15 | m_SpatializerPlugin:
16 | m_AmbisonicDecoderPlugin:
17 | m_DisableAudio: 0
18 | m_VirtualizeEffects: 1
19 | m_RequestedDSPBufferSize: 1024
20 |
--------------------------------------------------------------------------------
/client/unity/ProjectSettings/ClusterInputManager.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!236 &1
4 | ClusterInputManager:
5 | m_ObjectHideFlags: 0
6 | m_Inputs: []
7 |
--------------------------------------------------------------------------------
/client/unity/ProjectSettings/DynamicsManager.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!55 &1
4 | PhysicsManager:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 11
7 | m_Gravity: {x: 0, y: -9.81, z: 0}
8 | m_DefaultMaterial: {fileID: 0}
9 | m_BounceThreshold: 2
10 | m_SleepThreshold: 0.005
11 | m_DefaultContactOffset: 0.01
12 | m_DefaultSolverIterations: 6
13 | m_DefaultSolverVelocityIterations: 1
14 | m_QueriesHitBackfaces: 0
15 | m_QueriesHitTriggers: 1
16 | m_EnableAdaptiveForce: 0
17 | m_ClothInterCollisionDistance: 0
18 | m_ClothInterCollisionStiffness: 0
19 | m_ContactsGeneration: 1
20 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
21 | m_AutoSimulation: 1
22 | m_AutoSyncTransforms: 0
23 | m_ReuseCollisionCallbacks: 1
24 | m_ClothInterCollisionSettingsToggle: 0
25 | m_ContactPairsMode: 0
26 | m_BroadphaseType: 0
27 | m_WorldBounds:
28 | m_Center: {x: 0, y: 0, z: 0}
29 | m_Extent: {x: 250, y: 250, z: 250}
30 | m_WorldSubdivisions: 8
31 | m_FrictionType: 0
32 | m_EnableEnhancedDeterminism: 0
33 | m_EnableUnifiedHeightmaps: 1
34 | m_DefaultMaxAngluarSpeed: 7
35 |
--------------------------------------------------------------------------------
/client/unity/ProjectSettings/EditorBuildSettings.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!1045 &1
4 | EditorBuildSettings:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 2
7 | m_Scenes: []
8 | m_configObjects: {}
9 |
--------------------------------------------------------------------------------
/client/unity/ProjectSettings/EditorSettings.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!159 &1
4 | EditorSettings:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 9
7 | m_ExternalVersionControlSupport: Hidden Meta Files
8 | m_SerializationMode: 2
9 | m_LineEndingsForNewScripts: 2
10 | m_DefaultBehaviorMode: 0
11 | m_PrefabRegularEnvironment: {fileID: 0}
12 | m_PrefabUIEnvironment: {fileID: 0}
13 | m_SpritePackerMode: 0
14 | m_SpritePackerPaddingPower: 1
15 | m_EtcTextureCompressorBehavior: 1
16 | m_EtcTextureFastCompressor: 1
17 | m_EtcTextureNormalCompressor: 2
18 | m_EtcTextureBestCompressor: 4
19 | m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd;asmdef;rsp;asmref
20 | m_ProjectGenerationRootNamespace:
21 | m_CollabEditorSettings:
22 | inProgressEnabled: 1
23 | m_EnableTextureStreamingInEditMode: 1
24 | m_EnableTextureStreamingInPlayMode: 1
25 | m_AsyncShaderCompilation: 1
26 | m_EnterPlayModeOptionsEnabled: 0
27 | m_EnterPlayModeOptions: 3
28 | m_ShowLightmapResolutionOverlay: 1
29 | m_UseLegacyProbeSampleCount: 1
30 | m_AssetPipelineMode: 1
31 | m_CacheServerMode: 0
32 | m_CacheServerEndpoint:
33 | m_CacheServerNamespacePrefix: default
34 | m_CacheServerEnableDownload: 1
35 | m_CacheServerEnableUpload: 1
36 |
--------------------------------------------------------------------------------
/client/unity/ProjectSettings/GraphicsSettings.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!30 &1
4 | GraphicsSettings:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 12
7 | m_Deferred:
8 | m_Mode: 1
9 | m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0}
10 | m_DeferredReflections:
11 | m_Mode: 1
12 | m_Shader: {fileID: 74, guid: 0000000000000000f000000000000000, type: 0}
13 | m_ScreenSpaceShadows:
14 | m_Mode: 1
15 | m_Shader: {fileID: 64, guid: 0000000000000000f000000000000000, type: 0}
16 | m_LegacyDeferred:
17 | m_Mode: 1
18 | m_Shader: {fileID: 63, guid: 0000000000000000f000000000000000, type: 0}
19 | m_DepthNormals:
20 | m_Mode: 1
21 | m_Shader: {fileID: 62, guid: 0000000000000000f000000000000000, type: 0}
22 | m_MotionVectors:
23 | m_Mode: 1
24 | m_Shader: {fileID: 75, guid: 0000000000000000f000000000000000, type: 0}
25 | m_LightHalo:
26 | m_Mode: 1
27 | m_Shader: {fileID: 105, guid: 0000000000000000f000000000000000, type: 0}
28 | m_LensFlare:
29 | m_Mode: 1
30 | m_Shader: {fileID: 102, guid: 0000000000000000f000000000000000, type: 0}
31 | m_AlwaysIncludedShaders:
32 | - {fileID: 7, guid: 0000000000000000f000000000000000, type: 0}
33 | - {fileID: 15104, guid: 0000000000000000f000000000000000, type: 0}
34 | - {fileID: 15105, guid: 0000000000000000f000000000000000, type: 0}
35 | - {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0}
36 | - {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0}
37 | - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0}
38 | m_PreloadedShaders: []
39 | m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000,
40 | type: 0}
41 | m_CustomRenderPipeline: {fileID: 0}
42 | m_TransparencySortMode: 0
43 | m_TransparencySortAxis: {x: 0, y: 0, z: 1}
44 | m_DefaultRenderingPath: 1
45 | m_DefaultMobileRenderingPath: 1
46 | m_TierSettings: []
47 | m_LightmapStripping: 0
48 | m_FogStripping: 0
49 | m_InstancingStripping: 0
50 | m_LightmapKeepPlain: 1
51 | m_LightmapKeepDirCombined: 1
52 | m_LightmapKeepDynamicPlain: 1
53 | m_LightmapKeepDynamicDirCombined: 1
54 | m_LightmapKeepShadowMask: 1
55 | m_LightmapKeepSubtractive: 1
56 | m_FogKeepLinear: 1
57 | m_FogKeepExp: 1
58 | m_FogKeepExp2: 1
59 | m_AlbedoSwatchInfos: []
60 | m_LightsUseLinearIntensity: 0
61 | m_LightsUseColorTemperature: 0
62 |
--------------------------------------------------------------------------------
/client/unity/ProjectSettings/InputManager.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!13 &1
4 | InputManager:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 2
7 | m_Axes:
8 | - serializedVersion: 3
9 | m_Name: Horizontal
10 | descriptiveName:
11 | descriptiveNegativeName:
12 | negativeButton: left
13 | positiveButton: right
14 | altNegativeButton: a
15 | altPositiveButton: d
16 | gravity: 3
17 | dead: 0.001
18 | sensitivity: 3
19 | snap: 1
20 | invert: 0
21 | type: 0
22 | axis: 0
23 | joyNum: 0
24 | - serializedVersion: 3
25 | m_Name: Vertical
26 | descriptiveName:
27 | descriptiveNegativeName:
28 | negativeButton: down
29 | positiveButton: up
30 | altNegativeButton: s
31 | altPositiveButton: w
32 | gravity: 3
33 | dead: 0.001
34 | sensitivity: 3
35 | snap: 1
36 | invert: 0
37 | type: 0
38 | axis: 0
39 | joyNum: 0
40 | - serializedVersion: 3
41 | m_Name: Fire1
42 | descriptiveName:
43 | descriptiveNegativeName:
44 | negativeButton:
45 | positiveButton: left ctrl
46 | altNegativeButton:
47 | altPositiveButton: mouse 0
48 | gravity: 1000
49 | dead: 0.001
50 | sensitivity: 1000
51 | snap: 0
52 | invert: 0
53 | type: 0
54 | axis: 0
55 | joyNum: 0
56 | - serializedVersion: 3
57 | m_Name: Fire2
58 | descriptiveName:
59 | descriptiveNegativeName:
60 | negativeButton:
61 | positiveButton: left alt
62 | altNegativeButton:
63 | altPositiveButton: mouse 1
64 | gravity: 1000
65 | dead: 0.001
66 | sensitivity: 1000
67 | snap: 0
68 | invert: 0
69 | type: 0
70 | axis: 0
71 | joyNum: 0
72 | - serializedVersion: 3
73 | m_Name: Fire3
74 | descriptiveName:
75 | descriptiveNegativeName:
76 | negativeButton:
77 | positiveButton: left shift
78 | altNegativeButton:
79 | altPositiveButton: mouse 2
80 | gravity: 1000
81 | dead: 0.001
82 | sensitivity: 1000
83 | snap: 0
84 | invert: 0
85 | type: 0
86 | axis: 0
87 | joyNum: 0
88 | - serializedVersion: 3
89 | m_Name: Jump
90 | descriptiveName:
91 | descriptiveNegativeName:
92 | negativeButton:
93 | positiveButton: space
94 | altNegativeButton:
95 | altPositiveButton:
96 | gravity: 1000
97 | dead: 0.001
98 | sensitivity: 1000
99 | snap: 0
100 | invert: 0
101 | type: 0
102 | axis: 0
103 | joyNum: 0
104 | - serializedVersion: 3
105 | m_Name: Mouse X
106 | descriptiveName:
107 | descriptiveNegativeName:
108 | negativeButton:
109 | positiveButton:
110 | altNegativeButton:
111 | altPositiveButton:
112 | gravity: 0
113 | dead: 0
114 | sensitivity: 0.1
115 | snap: 0
116 | invert: 0
117 | type: 1
118 | axis: 0
119 | joyNum: 0
120 | - serializedVersion: 3
121 | m_Name: Mouse Y
122 | descriptiveName:
123 | descriptiveNegativeName:
124 | negativeButton:
125 | positiveButton:
126 | altNegativeButton:
127 | altPositiveButton:
128 | gravity: 0
129 | dead: 0
130 | sensitivity: 0.1
131 | snap: 0
132 | invert: 0
133 | type: 1
134 | axis: 1
135 | joyNum: 0
136 | - serializedVersion: 3
137 | m_Name: Mouse ScrollWheel
138 | descriptiveName:
139 | descriptiveNegativeName:
140 | negativeButton:
141 | positiveButton:
142 | altNegativeButton:
143 | altPositiveButton:
144 | gravity: 0
145 | dead: 0
146 | sensitivity: 0.1
147 | snap: 0
148 | invert: 0
149 | type: 1
150 | axis: 2
151 | joyNum: 0
152 | - serializedVersion: 3
153 | m_Name: Horizontal
154 | descriptiveName:
155 | descriptiveNegativeName:
156 | negativeButton:
157 | positiveButton:
158 | altNegativeButton:
159 | altPositiveButton:
160 | gravity: 0
161 | dead: 0.19
162 | sensitivity: 1
163 | snap: 0
164 | invert: 0
165 | type: 2
166 | axis: 0
167 | joyNum: 0
168 | - serializedVersion: 3
169 | m_Name: Vertical
170 | descriptiveName:
171 | descriptiveNegativeName:
172 | negativeButton:
173 | positiveButton:
174 | altNegativeButton:
175 | altPositiveButton:
176 | gravity: 0
177 | dead: 0.19
178 | sensitivity: 1
179 | snap: 0
180 | invert: 1
181 | type: 2
182 | axis: 1
183 | joyNum: 0
184 | - serializedVersion: 3
185 | m_Name: Fire1
186 | descriptiveName:
187 | descriptiveNegativeName:
188 | negativeButton:
189 | positiveButton: joystick button 0
190 | altNegativeButton:
191 | altPositiveButton:
192 | gravity: 1000
193 | dead: 0.001
194 | sensitivity: 1000
195 | snap: 0
196 | invert: 0
197 | type: 0
198 | axis: 0
199 | joyNum: 0
200 | - serializedVersion: 3
201 | m_Name: Fire2
202 | descriptiveName:
203 | descriptiveNegativeName:
204 | negativeButton:
205 | positiveButton: joystick button 1
206 | altNegativeButton:
207 | altPositiveButton:
208 | gravity: 1000
209 | dead: 0.001
210 | sensitivity: 1000
211 | snap: 0
212 | invert: 0
213 | type: 0
214 | axis: 0
215 | joyNum: 0
216 | - serializedVersion: 3
217 | m_Name: Fire3
218 | descriptiveName:
219 | descriptiveNegativeName:
220 | negativeButton:
221 | positiveButton: joystick button 2
222 | altNegativeButton:
223 | altPositiveButton:
224 | gravity: 1000
225 | dead: 0.001
226 | sensitivity: 1000
227 | snap: 0
228 | invert: 0
229 | type: 0
230 | axis: 0
231 | joyNum: 0
232 | - serializedVersion: 3
233 | m_Name: Jump
234 | descriptiveName:
235 | descriptiveNegativeName:
236 | negativeButton:
237 | positiveButton: joystick button 3
238 | altNegativeButton:
239 | altPositiveButton:
240 | gravity: 1000
241 | dead: 0.001
242 | sensitivity: 1000
243 | snap: 0
244 | invert: 0
245 | type: 0
246 | axis: 0
247 | joyNum: 0
248 | - serializedVersion: 3
249 | m_Name: Submit
250 | descriptiveName:
251 | descriptiveNegativeName:
252 | negativeButton:
253 | positiveButton: return
254 | altNegativeButton:
255 | altPositiveButton: joystick button 0
256 | gravity: 1000
257 | dead: 0.001
258 | sensitivity: 1000
259 | snap: 0
260 | invert: 0
261 | type: 0
262 | axis: 0
263 | joyNum: 0
264 | - serializedVersion: 3
265 | m_Name: Submit
266 | descriptiveName:
267 | descriptiveNegativeName:
268 | negativeButton:
269 | positiveButton: enter
270 | altNegativeButton:
271 | altPositiveButton: space
272 | gravity: 1000
273 | dead: 0.001
274 | sensitivity: 1000
275 | snap: 0
276 | invert: 0
277 | type: 0
278 | axis: 0
279 | joyNum: 0
280 | - serializedVersion: 3
281 | m_Name: Cancel
282 | descriptiveName:
283 | descriptiveNegativeName:
284 | negativeButton:
285 | positiveButton: escape
286 | altNegativeButton:
287 | altPositiveButton: joystick button 1
288 | gravity: 1000
289 | dead: 0.001
290 | sensitivity: 1000
291 | snap: 0
292 | invert: 0
293 | type: 0
294 | axis: 0
295 | joyNum: 0
296 |
--------------------------------------------------------------------------------
/client/unity/ProjectSettings/NavMeshAreas.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!126 &1
4 | NavMeshProjectSettings:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 2
7 | areas:
8 | - name: Walkable
9 | cost: 1
10 | - name: Not Walkable
11 | cost: 1
12 | - name: Jump
13 | cost: 2
14 | - name:
15 | cost: 1
16 | - name:
17 | cost: 1
18 | - name:
19 | cost: 1
20 | - name:
21 | cost: 1
22 | - name:
23 | cost: 1
24 | - name:
25 | cost: 1
26 | - name:
27 | cost: 1
28 | - name:
29 | cost: 1
30 | - name:
31 | cost: 1
32 | - name:
33 | cost: 1
34 | - name:
35 | cost: 1
36 | - name:
37 | cost: 1
38 | - name:
39 | cost: 1
40 | - name:
41 | cost: 1
42 | - name:
43 | cost: 1
44 | - name:
45 | cost: 1
46 | - name:
47 | cost: 1
48 | - name:
49 | cost: 1
50 | - name:
51 | cost: 1
52 | - name:
53 | cost: 1
54 | - name:
55 | cost: 1
56 | - name:
57 | cost: 1
58 | - name:
59 | cost: 1
60 | - name:
61 | cost: 1
62 | - name:
63 | cost: 1
64 | - name:
65 | cost: 1
66 | - name:
67 | cost: 1
68 | - name:
69 | cost: 1
70 | - name:
71 | cost: 1
72 | m_LastAgentTypeID: -887442657
73 | m_Settings:
74 | - serializedVersion: 2
75 | agentTypeID: 0
76 | agentRadius: 0.5
77 | agentHeight: 2
78 | agentSlope: 45
79 | agentClimb: 0.75
80 | ledgeDropHeight: 0
81 | maxJumpAcrossDistance: 0
82 | minRegionArea: 2
83 | manualCellSize: 0
84 | cellSize: 0.16666667
85 | manualTileSize: 0
86 | tileSize: 256
87 | accuratePlacement: 0
88 | debug:
89 | m_Flags: 0
90 | m_SettingNames:
91 | - Humanoid
92 |
--------------------------------------------------------------------------------
/client/unity/ProjectSettings/Physics2DSettings.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!19 &1
4 | Physics2DSettings:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 4
7 | m_Gravity: {x: 0, y: -9.81}
8 | m_DefaultMaterial: {fileID: 0}
9 | m_VelocityIterations: 8
10 | m_PositionIterations: 3
11 | m_VelocityThreshold: 1
12 | m_MaxLinearCorrection: 0.2
13 | m_MaxAngularCorrection: 8
14 | m_MaxTranslationSpeed: 100
15 | m_MaxRotationSpeed: 360
16 | m_BaumgarteScale: 0.2
17 | m_BaumgarteTimeOfImpactScale: 0.75
18 | m_TimeToSleep: 0.5
19 | m_LinearSleepTolerance: 0.01
20 | m_AngularSleepTolerance: 2
21 | m_DefaultContactOffset: 0.01
22 | m_JobOptions:
23 | serializedVersion: 2
24 | useMultithreading: 0
25 | useConsistencySorting: 0
26 | m_InterpolationPosesPerJob: 100
27 | m_NewContactsPerJob: 30
28 | m_CollideContactsPerJob: 100
29 | m_ClearFlagsPerJob: 200
30 | m_ClearBodyForcesPerJob: 200
31 | m_SyncDiscreteFixturesPerJob: 50
32 | m_SyncContinuousFixturesPerJob: 50
33 | m_FindNearestContactsPerJob: 100
34 | m_UpdateTriggerContactsPerJob: 100
35 | m_IslandSolverCostThreshold: 100
36 | m_IslandSolverBodyCostScale: 1
37 | m_IslandSolverContactCostScale: 10
38 | m_IslandSolverJointCostScale: 10
39 | m_IslandSolverBodiesPerJob: 50
40 | m_IslandSolverContactsPerJob: 50
41 | m_AutoSimulation: 1
42 | m_QueriesHitTriggers: 1
43 | m_QueriesStartInColliders: 1
44 | m_CallbacksOnDisable: 1
45 | m_ReuseCollisionCallbacks: 1
46 | m_AutoSyncTransforms: 0
47 | m_AlwaysShowColliders: 0
48 | m_ShowColliderSleep: 1
49 | m_ShowColliderContacts: 0
50 | m_ShowColliderAABB: 0
51 | m_ContactArrowScale: 0.2
52 | m_ColliderAwakeColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.7529412}
53 | m_ColliderAsleepColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.36078432}
54 | m_ColliderContactColor: {r: 1, g: 0, b: 1, a: 0.6862745}
55 | m_ColliderAABBColor: {r: 1, g: 1, b: 0, a: 0.2509804}
56 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
57 |
--------------------------------------------------------------------------------
/client/unity/ProjectSettings/PresetManager.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!1386491679 &1
4 | PresetManager:
5 | m_ObjectHideFlags: 0
6 | m_DefaultList: []
7 |
--------------------------------------------------------------------------------
/client/unity/ProjectSettings/ProjectVersion.txt:
--------------------------------------------------------------------------------
1 | m_EditorVersion: 2019.3.12f1
2 | m_EditorVersionWithRevision: 2019.3.12f1 (84b23722532d)
3 |
--------------------------------------------------------------------------------
/client/unity/ProjectSettings/QualitySettings.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!47 &1
4 | QualitySettings:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 5
7 | m_CurrentQuality: 5
8 | m_QualitySettings:
9 | - serializedVersion: 2
10 | name: Very Low
11 | pixelLightCount: 0
12 | shadows: 0
13 | shadowResolution: 0
14 | shadowProjection: 1
15 | shadowCascades: 1
16 | shadowDistance: 15
17 | shadowNearPlaneOffset: 3
18 | shadowCascade2Split: 0.33333334
19 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
20 | shadowmaskMode: 0
21 | blendWeights: 1
22 | textureQuality: 1
23 | anisotropicTextures: 0
24 | antiAliasing: 0
25 | softParticles: 0
26 | softVegetation: 0
27 | realtimeReflectionProbes: 0
28 | billboardsFaceCameraPosition: 0
29 | vSyncCount: 0
30 | lodBias: 0.3
31 | maximumLODLevel: 0
32 | streamingMipmapsActive: 0
33 | streamingMipmapsAddAllCameras: 1
34 | streamingMipmapsMemoryBudget: 512
35 | streamingMipmapsRenderersPerFrame: 512
36 | streamingMipmapsMaxLevelReduction: 2
37 | streamingMipmapsMaxFileIORequests: 1024
38 | particleRaycastBudget: 4
39 | asyncUploadTimeSlice: 2
40 | asyncUploadBufferSize: 16
41 | asyncUploadPersistentBuffer: 1
42 | resolutionScalingFixedDPIFactor: 1
43 | excludedTargetPlatforms: []
44 | - serializedVersion: 2
45 | name: Low
46 | pixelLightCount: 0
47 | shadows: 0
48 | shadowResolution: 0
49 | shadowProjection: 1
50 | shadowCascades: 1
51 | shadowDistance: 20
52 | shadowNearPlaneOffset: 3
53 | shadowCascade2Split: 0.33333334
54 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
55 | shadowmaskMode: 0
56 | blendWeights: 2
57 | textureQuality: 0
58 | anisotropicTextures: 0
59 | antiAliasing: 0
60 | softParticles: 0
61 | softVegetation: 0
62 | realtimeReflectionProbes: 0
63 | billboardsFaceCameraPosition: 0
64 | vSyncCount: 0
65 | lodBias: 0.4
66 | maximumLODLevel: 0
67 | streamingMipmapsActive: 0
68 | streamingMipmapsAddAllCameras: 1
69 | streamingMipmapsMemoryBudget: 512
70 | streamingMipmapsRenderersPerFrame: 512
71 | streamingMipmapsMaxLevelReduction: 2
72 | streamingMipmapsMaxFileIORequests: 1024
73 | particleRaycastBudget: 16
74 | asyncUploadTimeSlice: 2
75 | asyncUploadBufferSize: 16
76 | asyncUploadPersistentBuffer: 1
77 | resolutionScalingFixedDPIFactor: 1
78 | excludedTargetPlatforms: []
79 | - serializedVersion: 2
80 | name: Medium
81 | pixelLightCount: 1
82 | shadows: 1
83 | shadowResolution: 0
84 | shadowProjection: 1
85 | shadowCascades: 1
86 | shadowDistance: 20
87 | shadowNearPlaneOffset: 3
88 | shadowCascade2Split: 0.33333334
89 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
90 | shadowmaskMode: 0
91 | blendWeights: 2
92 | textureQuality: 0
93 | anisotropicTextures: 1
94 | antiAliasing: 0
95 | softParticles: 0
96 | softVegetation: 0
97 | realtimeReflectionProbes: 0
98 | billboardsFaceCameraPosition: 0
99 | vSyncCount: 1
100 | lodBias: 0.7
101 | maximumLODLevel: 0
102 | streamingMipmapsActive: 0
103 | streamingMipmapsAddAllCameras: 1
104 | streamingMipmapsMemoryBudget: 512
105 | streamingMipmapsRenderersPerFrame: 512
106 | streamingMipmapsMaxLevelReduction: 2
107 | streamingMipmapsMaxFileIORequests: 1024
108 | particleRaycastBudget: 64
109 | asyncUploadTimeSlice: 2
110 | asyncUploadBufferSize: 16
111 | asyncUploadPersistentBuffer: 1
112 | resolutionScalingFixedDPIFactor: 1
113 | excludedTargetPlatforms: []
114 | - serializedVersion: 2
115 | name: High
116 | pixelLightCount: 2
117 | shadows: 2
118 | shadowResolution: 1
119 | shadowProjection: 1
120 | shadowCascades: 2
121 | shadowDistance: 40
122 | shadowNearPlaneOffset: 3
123 | shadowCascade2Split: 0.33333334
124 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
125 | shadowmaskMode: 1
126 | blendWeights: 2
127 | textureQuality: 0
128 | anisotropicTextures: 1
129 | antiAliasing: 0
130 | softParticles: 0
131 | softVegetation: 1
132 | realtimeReflectionProbes: 1
133 | billboardsFaceCameraPosition: 1
134 | vSyncCount: 1
135 | lodBias: 1
136 | maximumLODLevel: 0
137 | streamingMipmapsActive: 0
138 | streamingMipmapsAddAllCameras: 1
139 | streamingMipmapsMemoryBudget: 512
140 | streamingMipmapsRenderersPerFrame: 512
141 | streamingMipmapsMaxLevelReduction: 2
142 | streamingMipmapsMaxFileIORequests: 1024
143 | particleRaycastBudget: 256
144 | asyncUploadTimeSlice: 2
145 | asyncUploadBufferSize: 16
146 | asyncUploadPersistentBuffer: 1
147 | resolutionScalingFixedDPIFactor: 1
148 | excludedTargetPlatforms: []
149 | - serializedVersion: 2
150 | name: Very High
151 | pixelLightCount: 3
152 | shadows: 2
153 | shadowResolution: 2
154 | shadowProjection: 1
155 | shadowCascades: 2
156 | shadowDistance: 70
157 | shadowNearPlaneOffset: 3
158 | shadowCascade2Split: 0.33333334
159 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
160 | shadowmaskMode: 1
161 | blendWeights: 4
162 | textureQuality: 0
163 | anisotropicTextures: 2
164 | antiAliasing: 2
165 | softParticles: 1
166 | softVegetation: 1
167 | realtimeReflectionProbes: 1
168 | billboardsFaceCameraPosition: 1
169 | vSyncCount: 1
170 | lodBias: 1.5
171 | maximumLODLevel: 0
172 | streamingMipmapsActive: 0
173 | streamingMipmapsAddAllCameras: 1
174 | streamingMipmapsMemoryBudget: 512
175 | streamingMipmapsRenderersPerFrame: 512
176 | streamingMipmapsMaxLevelReduction: 2
177 | streamingMipmapsMaxFileIORequests: 1024
178 | particleRaycastBudget: 1024
179 | asyncUploadTimeSlice: 2
180 | asyncUploadBufferSize: 16
181 | asyncUploadPersistentBuffer: 1
182 | resolutionScalingFixedDPIFactor: 1
183 | excludedTargetPlatforms: []
184 | - serializedVersion: 2
185 | name: Ultra
186 | pixelLightCount: 4
187 | shadows: 2
188 | shadowResolution: 2
189 | shadowProjection: 1
190 | shadowCascades: 4
191 | shadowDistance: 150
192 | shadowNearPlaneOffset: 3
193 | shadowCascade2Split: 0.33333334
194 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
195 | shadowmaskMode: 1
196 | blendWeights: 4
197 | textureQuality: 0
198 | anisotropicTextures: 2
199 | antiAliasing: 2
200 | softParticles: 1
201 | softVegetation: 1
202 | realtimeReflectionProbes: 1
203 | billboardsFaceCameraPosition: 1
204 | vSyncCount: 1
205 | lodBias: 2
206 | maximumLODLevel: 0
207 | streamingMipmapsActive: 0
208 | streamingMipmapsAddAllCameras: 1
209 | streamingMipmapsMemoryBudget: 512
210 | streamingMipmapsRenderersPerFrame: 512
211 | streamingMipmapsMaxLevelReduction: 2
212 | streamingMipmapsMaxFileIORequests: 1024
213 | particleRaycastBudget: 4096
214 | asyncUploadTimeSlice: 2
215 | asyncUploadBufferSize: 16
216 | asyncUploadPersistentBuffer: 1
217 | resolutionScalingFixedDPIFactor: 1
218 | excludedTargetPlatforms: []
219 | m_PerPlatformDefaultQuality:
220 | Android: 2
221 | Lumin: 5
222 | Nintendo 3DS: 5
223 | Nintendo Switch: 5
224 | PS4: 5
225 | PSP2: 2
226 | Standalone: 5
227 | WebGL: 3
228 | Windows Store Apps: 5
229 | XboxOne: 5
230 | iPhone: 2
231 | tvOS: 2
232 |
--------------------------------------------------------------------------------
/client/unity/ProjectSettings/TagManager.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!78 &1
4 | TagManager:
5 | serializedVersion: 2
6 | tags: []
7 | layers:
8 | - Default
9 | - TransparentFX
10 | - Ignore Raycast
11 | -
12 | - Water
13 | - UI
14 | -
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 | m_SortingLayers:
41 | - name: Default
42 | uniqueID: 0
43 | locked: 0
44 |
--------------------------------------------------------------------------------
/client/unity/ProjectSettings/TimeManager.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!5 &1
4 | TimeManager:
5 | m_ObjectHideFlags: 0
6 | Fixed Timestep: 0.02
7 | Maximum Allowed Timestep: 0.33333334
8 | m_TimeScale: 1
9 | Maximum Particle Timestep: 0.03
10 |
--------------------------------------------------------------------------------
/client/unity/ProjectSettings/UnityConnectSettings.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!310 &1
4 | UnityConnectSettings:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 1
7 | m_Enabled: 0
8 | m_TestMode: 0
9 | m_EventOldUrl: https://api.uca.cloud.unity3d.com/v1/events
10 | m_EventUrl: https://cdp.cloud.unity3d.com/v1/events
11 | m_ConfigUrl: https://config.uca.cloud.unity3d.com
12 | m_TestInitMode: 0
13 | CrashReportingSettings:
14 | m_EventUrl: https://perf-events.cloud.unity3d.com
15 | m_Enabled: 0
16 | m_LogBufferSize: 10
17 | m_CaptureEditorExceptions: 1
18 | UnityPurchasingSettings:
19 | m_Enabled: 0
20 | m_TestMode: 0
21 | UnityAnalyticsSettings:
22 | m_Enabled: 0
23 | m_TestMode: 0
24 | m_InitializeOnStartup: 1
25 | UnityAdsSettings:
26 | m_Enabled: 0
27 | m_InitializeOnStartup: 1
28 | m_TestMode: 0
29 | m_IosGameId:
30 | m_AndroidGameId:
31 | m_GameIds: {}
32 | m_GameId:
33 | PerformanceReportingSettings:
34 | m_Enabled: 0
35 |
--------------------------------------------------------------------------------
/client/unity/ProjectSettings/VFXManager.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!937362698 &1
4 | VFXManager:
5 | m_ObjectHideFlags: 0
6 | m_IndirectShader: {fileID: 0}
7 | m_CopyBufferShader: {fileID: 0}
8 | m_SortShader: {fileID: 0}
9 | m_RenderPipeSettingsPath:
10 | m_FixedTimeStep: 0.016666668
11 | m_MaxDeltaTime: 0.05
12 |
--------------------------------------------------------------------------------
/client/unity/ProjectSettings/XRSettings.asset:
--------------------------------------------------------------------------------
1 | {
2 | "m_SettingKeys": [
3 | "VR Device Disabled",
4 | "VR Device User Alert"
5 | ],
6 | "m_SettingValues": [
7 | "False",
8 | "False"
9 | ]
10 | }
--------------------------------------------------------------------------------
/server/nodejs/config.json:
--------------------------------------------------------------------------------
1 | {
2 | "port": 8080,
3 | "debug": true,
4 | "debugJSON": true
5 | }
6 |
--------------------------------------------------------------------------------
/server/nodejs/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "unity-network-model",
3 | "version": "0.2.0",
4 | "description": "Synchronized 3D model over network",
5 | "author": "Uwe Gruenefeld ",
6 | "repository": {
7 | "type": "git",
8 | "url": "https://github.com/UweGruenefeld/UnityNetworkModel"
9 | },
10 | "bugs": {
11 | "url": "https://github.com/UweGruenefeld/UnityNetworkModel/issues"
12 | },
13 | "dependencies": {
14 | "nodejs-websocket": "*"
15 | },
16 | "license": "MIT"
17 | }
18 |
--------------------------------------------------------------------------------
/showcase/nodejs-console.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/UweGruenefeld/UnityNetworkModel/94a54c7a660293f18a1e948befd0e3aa0726d518/showcase/nodejs-console.jpg
--------------------------------------------------------------------------------
/showcase/unity-config.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/UweGruenefeld/UnityNetworkModel/94a54c7a660293f18a1e948befd0e3aa0726d518/showcase/unity-config.jpg
--------------------------------------------------------------------------------
/showcase/unity-rules.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/UweGruenefeld/UnityNetworkModel/94a54c7a660293f18a1e948befd0e3aa0726d518/showcase/unity-rules.jpg
--------------------------------------------------------------------------------