168 Commits

Author SHA1 Message Date
Jedd Morgan 25b2916c66 bump package version (#108) 2023-11-20 14:10:56 +00:00
Jedd Morgan d158bbdf60 feat!(selection): selection now indexes based on ID (#107) 2023-11-20 13:57:18 +00:00
Jedd Morgan bb43ba5443 Merge pull request #106 from specklesystems/jrm/core/2.17rc
deps(2.17): Updated Core to 2.17.0-rc
2023-11-20 13:54:21 +00:00
Jedd Morgan cff4978179 Bump core to 2.17.0-rc 2023-11-17 12:58:42 +00:00
Jedd Morgan ce33e7c454 Merge pull request #105 from specklesystems/jrm/core/2.16.0
Updated core and objects to 2.16.0
2023-10-31 12:18:13 +00:00
Jedd Morgan fb1e458970 Bumped version connector package semver 2023-10-31 12:17:15 +00:00
Jedd Morgan 2755a9abd7 Fix compiler errors for 2.16 core/objects bump 2023-10-31 12:15:13 +00:00
Jedd Morgan ee9795e39f Bump Core + Objects 2023-10-31 11:52:47 +00:00
Jedd Morgan 999e6ae4ea Merge pull request #103 from specklesystems/jrm/update-docs
Updated SpeckleReceiver.cs
2023-09-26 22:46:37 +01:00
Jedd Morgan 8df96eeca4 Updated SpeckleReceiver.cs 2023-09-26 22:45:44 +01:00
Jedd Morgan 6aa92d4c57 Merge pull request #102 from specklesystems/doc-comments
Update SpeckleReceiver.cs
2023-09-26 22:18:41 +01:00
Jedd Morgan 030cb277b8 Update SpeckleReceiver.cs 2023-09-26 22:18:28 +01:00
Jedd Morgan 5ee498afce Update SpeckleReceiver.cs 2023-09-26 22:17:28 +01:00
Jedd Morgan 0bb1591624 Merge pull request #99 from specklesystems/jrm/unity/speckle-properties-example
Added manual speckle properties example
2023-09-12 14:01:18 +01:00
Jedd Morgan 5dd889c898 Update package.json 2023-09-12 13:59:30 +01:00
Jedd Morgan 9c7d1deb0a Added speckle properties example 2023-09-12 13:56:18 +01:00
Jedd Morgan 106d4c8e73 Merge pull request #98 from specklesystems/jrm/converter/convert-speckle-properties-on-instances
Attach Speckle Properties to instances
2023-08-31 15:41:22 +01:00
Jedd Morgan 7c8f70c0c0 Attach Speckle Properties to instances 2023-08-31 15:40:08 +01:00
Jedd Morgan f0be78888f Merge pull request #97 from specklesystems/2.15-deps
2.15 deps
2023-08-31 13:13:12 +01:00
Jedd Morgan 892e77e0ff Bumped version number 2023-08-31 12:50:20 +01:00
Jedd Morgan 8a9c21f979 Exposed toggle for attaching speckle properties 2023-08-31 12:30:50 +01:00
Jedd Morgan aa46d49620 reformat code 2023-08-31 12:08:35 +01:00
Jedd Morgan 5d92e12eff Bumped core to 2.15.1 stable 2023-08-31 12:08:14 +01:00
Jedd Morgan e1a3ae6b9c urp test 2023-07-11 23:32:01 +01:00
Jedd Morgan d44ead55db Added support for translucency with the standard shader 2023-07-11 22:55:18 +01:00
Jedd Morgan a3fb10570e deps: 2.15.0-alpha2 2023-06-29 00:26:21 +01:00
Jedd Morgan 57154a6fb8 deps: bumped core to 2.15.0-alpha 2023-06-26 22:20:33 +01:00
Jedd Morgan 5db1f450af Merge pull request #93 from specklesystems/jrm/traversal-refactor
implementation of traversal refactor
2023-06-26 22:14:52 +01:00
Jedd Morgan 62875c0a27 Editor progress bar now works 2023-06-22 17:23:57 +01:00
Jedd Morgan b3c6b59721 Cancellation fixes and editor progress 2023-06-14 17:08:51 +01:00
Jedd Morgan d9f7895b3f Improved Editor Cancellation 2023-06-11 14:39:14 +01:00
Jedd Morgan dc58f6b0b0 wip collections 2023-06-08 23:17:50 +01:00
Jedd Morgan 556a7eaddf Merge remote-tracking branch 'origin/main' into jrm/traversal-refactor 2023-06-07 17:09:27 +01:00
Jedd Morgan 39a79be700 Merge branch 'main' into jrm/traversal-refactor 2023-06-07 17:08:58 +01:00
Jedd Morgan 73ef71f4fd Merge pull request #95 from specklesystems/core/2.14.2
Bumped core to 2.14.2
2023-06-07 15:21:13 +01:00
Jedd Morgan 6a07ecfd5b bumped version number 2023-06-07 15:20:57 +01:00
Jedd Morgan e512df9c82 Bumped core to 2.14.2 2023-06-07 13:54:10 +01:00
Jedd Morgan 59221e89ba Merge pull request #94 from specklesystems/jrm/update-core-2.13.0
Added IsMultiplayer
2023-04-22 01:21:09 +01:00
Jedd Morgan 32533ddb21 Added IsMultiplayer 2023-04-22 01:20:08 +01:00
Jedd Morgan fc537e137f Merge pull request #92 from specklesystems/jrm/update-core-2.13.0
2.13 update
2023-04-22 00:15:01 +01:00
Jedd Morgan 2aaaf6572c Final polish 2023-04-22 00:14:40 +01:00
Jedd Morgan a89e4cdfe7 wip implementation of traversal refactor 2023-04-21 22:34:59 +01:00
Jedd Morgan 9a89255ae8 Fixed build warnings 2023-04-11 21:14:35 +01:00
Jedd Morgan 9f3145eb19 2.13 testing 2023-04-11 17:55:59 +01:00
Jedd Morgan 5dde0dae60 Configure await false fixes deadlocks 2023-04-06 22:50:47 +01:00
Jedd Morgan 0794c53b24 Converter now builds 2023-04-04 20:20:07 +01:00
Jedd Morgan 2973087beb Update objects & core dlls to 2.13 2023-04-04 19:59:48 +01:00
Matteo Cominetti db2b831278 Delete .github/workflows directory 2023-02-15 12:47:19 +00:00
Alan Rynne 23145f45e1 ci: Updated github actions to use new actions repo 2023-01-09 20:48:47 +01:00
Jedd Morgan d1a0a66639 Merge pull request #88 from specklesystems/jrm/stream-manager-improvements
2.10 Features: Stream manager improvements
2022-11-30 17:35:33 +00:00
Jedd Morgan 00f57f1bdd feat(editor): Added entry in gameobject menu + minor bug fixes 2022-11-30 17:34:00 +00:00
JR-Morgan 55c26f4bdd small improvements 2022-11-17 21:02:04 +00:00
JR-Morgan 69c5c62a45 Restructured editor assemblies 2022-11-10 17:59:02 +00:00
JR-Morgan cf7362b023 feat(Sender): Added editor sender 2022-11-09 03:12:23 +00:00
JR-Morgan 6a802df7ee Stream Previews 2022-11-09 00:08:41 +00:00
JR-Morgan c6de60f18c Asset restructure to seperate components and wrappers 2022-11-08 19:13:48 +00:00
JR-Morgan 9f2744df2c seperating out editor UI from editor receiving 2022-11-04 02:50:37 +00:00
Jedd Morgan 8d2fc0072d Merge pull request #84 from specklesystems/jrm/playground-fixes
Minor fixes for SpecklePlayground
2022-10-27 17:26:46 +01:00
JR-Morgan 698513da48 fix(playground): fixed minor UI/UX issues with specklePlayground 2022-10-27 17:22:58 +01:00
Jedd Morgan f92722d3ed Merge pull request #83 from specklesystems/jrm/get-members-fix
Removed some empty gameobjects that were accidently added to SpecklePlayground scene
2022-10-27 16:39:29 +01:00
JR-Morgan 065d4c0fd5 Merge branch 'main' of https://github.com/specklesystems/speckle-unity into jrm/get-members-fix 2022-10-27 16:37:58 +01:00
JR-Morgan 70eae64ea4 Removed some empty gameobjects that were accidently added to SpecklePlayground scene 2022-10-27 16:37:04 +01:00
Jedd Morgan a0a7d4f956 Merge pull request #82 from specklesystems/jrm/get-members-fix
Temporary fix for GetMemberNames throwing exception with box.bbox
2022-10-27 16:34:51 +01:00
JR-Morgan 48506f89cc fix(core): bumped core with fix for GetMembers failing on box.bbox 2022-10-27 16:32:43 +01:00
Jedd Morgan f4aba6c1e5 Merge pull request #80 from specklesystems/jrm/blocks
Added support for Blocks and Asset saving
2022-10-27 14:27:19 +01:00
JR-Morgan 9810084094 Merge branch 'jrm/crossplatform-fix' into jrm/blocks 2022-10-27 14:26:10 +01:00
JR-Morgan 8bc9279621 fix(converter): Meshes without materials will now share the same "defaultMaterial" 2022-10-27 14:19:55 +01:00
Jedd Morgan 09411919ab Update package.json 2022-10-24 14:38:49 +01:00
JR-Morgan 3a632c1117 fixed issue with writing nested prefab assets 2022-10-21 21:06:05 +01:00
JR-Morgan c1a1e576b6 fix(converter): Fixed issue with meshes not being saved 2022-10-17 22:05:27 +01:00
Jonathon Broughton df7adc859c meta files rebuilt 2022-10-14 13:52:38 +01:00
JR-Morgan 7cf05003dd attempted fix for macos editor not picking up core DLL 2022-10-14 13:31:31 +01:00
JR-Morgan 2822a6b8c3 fix(core): added native dlls for MacOS, Linux 2022-10-14 12:45:09 +01:00
JR-Morgan 38b73d48f8 feat(core): Bumped core to 2.9 2022-10-14 12:21:16 +01:00
JR-Morgan abe721a323 feat(converter): Added native asset cache to converter to allow for loading/saving assets in an abstract way 2022-10-11 14:55:26 +01:00
JR-Morgan 837794f6e9 feat(converter): Refactor to enable Block conversion 2022-10-05 21:31:44 +01:00
Jedd Morgan d8d46be6b3 Merge pull request #78 from specklesystems/2.8.0-package-bump
2.8.0 Update
2022-09-20 18:15:18 +01:00
Jedd Morgan 57c5307c8c 2.8.0 Update 2022-09-20 18:14:42 +01:00
Jedd Morgan e0e0c42a14 Merge pull request #75 from specklesystems/unity-to-bim
Unity To Bim Features
2022-09-20 18:10:10 +01:00
JR-Morgan 6e6e53a3b1 feature(core): Bumped core 2022-09-20 18:08:15 +01:00
JR-Morgan de1e154065 feat(EditorUI): Added "Edit mode" toggle (and experimental warning) to SpeckleProperties editor
fix(Converter): Fixed issue with ToNative conversion of `Objects.Geometry` objects leading to unparented `GameObject`speckle
2022-08-29 21:11:36 +01:00
JR-Morgan 74a75538f9 Merge branch 'main' into unity-to-bim 2022-08-29 18:54:48 +01:00
Jedd Morgan 8aaec04705 Merge pull request #72 from haitheredavid/recenter-mesh
Fix for setting mesh center
2022-08-29 18:40:47 +01:00
JR-Morgan 2c910136c6 Bumped core + BIM properties editor UI 2022-08-18 22:52:33 +01:00
David Morgan 8f64e7fcb3 set mesh center 2022-08-16 17:49:34 -04:00
Jedd Morgan e674b4970a Update README.md 2022-08-11 02:44:56 +01:00
Jedd Morgan fc5e4828b8 Update README.md 2022-08-11 02:41:27 +01:00
JR-Morgan f3bb67fda1 Conversion Bug fixes and category parenting 2022-08-08 20:05:13 +01:00
JR-Morgan 7a915262fc ToSpeckle refactor 2022-07-19 03:40:33 +01:00
JR-Morgan 40541bfec6 Merge branch 'main' of https://github.com/specklesystems/speckle-unity into unity-to-bim 2022-07-18 20:15:40 +01:00
JR-Morgan 32db50d03b Updated speckle properties to support selection of Base type 2022-07-18 20:13:59 +01:00
JR-Morgan dca1908a1e Fixed issue with generating material asset for materials with invalid chars 2022-05-23 20:48:16 +01:00
Jedd Morgan dab592bb0a Merge pull request #61 from specklesystems/2.5.0-beta
2.5.0 Update
2022-05-23 01:59:05 +01:00
JR-Morgan 672865ed87 Refactored ToNative converter to aligh with UE 2022-05-23 01:51:35 +01:00
JR-Morgan 10f0c244ff Re-added commit creation when sending.
Also replaced ParallelExtensionsExtras.dll with source file for cross platform building
2022-05-18 01:00:02 +01:00
Jedd Morgan 26f611380c Merge pull request #63 from haitheredavid/fix-send-dispose
Fix send dispose
2022-05-04 14:52:34 +01:00
David Morgan cd42a3b5dd format 2022-04-28 01:25:07 -04:00
David Morgan a9c39f7bb3 looks like I used notepad 2022-04-28 01:24:53 -04:00
David Morgan 815bebf7a0 removed cancellation token 2022-04-28 01:24:06 -04:00
David Morgan fe4b6fc163 switched to operations 2022-04-28 01:13:30 -04:00
David Morgan 9a22673e47 Merge remote-tracking branch 'upstream/2.5.0-beta' into fix-send-dispose 2022-04-28 01:08:18 -04:00
David Morgan ef0ba750d9 dispose toggle set to true 2022-04-28 01:07:20 -04:00
JR-Morgan 561ad1029e Bumped core to 2.5.0-beta 2022-04-07 01:42:59 +01:00
JR-Morgan 8412d2e425 Clean-up 2022-04-07 01:12:28 +01:00
Jedd Morgan 899fe0edc1 Merge pull request #55 from specklesystems/origin/texture-coordinates-fix
Updates to Mesh conversion - Texcoords, N-gons, displayValue, Normals
2022-02-24 18:56:26 +01:00
JR-Morgan a60763e02d Updated objects to 2.4.0 2022-02-24 17:50:28 +00:00
JR-Morgan 764fd1e45a Merge branch 'pr/58' into 2.4.0-update 2022-02-23 13:06:43 +00:00
JR-Morgan 17d81ef20f Bumped core 2.4.0 2022-02-23 13:00:02 +00:00
Philip Belesky 6024556001 Add macOS-compatible SQLite dependency 2022-02-03 14:52:06 +11:00
JR-Morgan 6437c3b20b Updated ToNative conversion to accept multiple displayValue meshes 2022-02-03 00:39:36 +00:00
Jedd Morgan 5401886b04 Merge pull request #50 from specklesystems/speckle-properties3
SpeckleProperties observable dictionary implementation
2021-12-13 18:12:46 +00:00
JR-Morgan 8b44834934 Speckle shader magic! 2021-12-11 17:44:34 +00:00
JR-Morgan 11a154a98e Speckle shader 2021-12-11 00:35:49 +00:00
JR-Morgan 59ec7af536 Merge branch 'main' into origin/texture-coordinates-fix 2021-12-10 17:08:44 +00:00
JR-Morgan 451471a6bc Changed default number of streams, branches, and commits that will be fetched by the StreamManager 2021-12-10 17:07:03 +00:00
JR-Morgan 3de01bdf4e To Native mesh conversion now correctly converts vertex colors and PBR properties 2021-12-10 17:06:16 +00:00
JR-Morgan 37c128cf1c Merge remote-tracking branch 'origin/main' into speckle-properties3 2021-12-02 20:09:46 +00:00
Jedd Morgan 781e35c76f Merge pull request #52 from specklesystems/package
Created embedded package for Speckle Connector
2021-12-02 17:31:15 +00:00
JR-Morgan 7ad76b5c6c Deleted unnecessary meta file 2021-12-02 13:46:35 +00:00
JR-Morgan ecb7af44b3 Moved connector into Package 2021-12-02 13:26:32 +00:00
JR-Morgan b8cb1ca97a Experimenting with texture-coordinate conversion 2021-12-02 13:23:29 +00:00
Jedd Morgan 2e73558cde Merge pull request #51 from specklesystems/bump-core-2.2.4
Bumped core to 2.2.4 and added read receipts
2021-11-30 17:40:14 +00:00
JR-Morgan 3f9bc06dfb Bumped core and added read receipts 2021-11-26 00:11:35 +00:00
JR-Morgan 19da51c40b SpeckleProperties observable dictionary 2021-11-24 20:33:49 +00:00
Jedd Morgan c3de6a49a8 Merge pull request #48 from specklesystems/playground-send-fix
Fix playground sending.
2021-10-30 00:24:09 +01:00
JR-Morgan 97c017998a Fixed bug with object selection in speckle playground that caused an exception to be thrown on send 2021-10-29 17:23:50 +01:00
Jedd Morgan d949a0f650 Merge pull request #42 from specklesystems/shader-build-fix
Fix for #38
2021-10-07 20:17:33 +01:00
JR-Morgan 46d33dc3f7 Fixed issue with Editor Progress bar being updated from non-unity thread. 2021-10-07 20:10:35 +01:00
JR-Morgan c0bc7d0805 Updated core to a9ee8e5a1689d865e8d6e69c42221385c9ad3e56 2021-10-07 17:28:24 +01:00
Matteo Cominetti 8d4e390db9 Create close-issue.yml 2021-10-02 17:10:51 +01:00
Matteo Cominetti 123e87f554 Create open-issue.yml 2021-10-02 17:10:39 +01:00
JR-Morgan 8f3dc3543e Manually added required shaders to build, potential fix for #38 2021-09-28 11:15:01 +01:00
Jedd Morgan f8b3511656 Merge pull request #41 from specklesystems/assemblies
Assemblies and Broken Scene References fixed
2021-09-15 11:54:50 +01:00
JR-Morgan d8d2d3f574 Fixed broken scene references (hopefully for good now)
- Removed `.meta` from `.gitignore`
- Fixed broken scene references
- Upgraded project to 2020.3.17
2021-09-15 11:43:25 +01:00
JR-Morgan 0e357a9198 Fixed broken scene references (hopefully for good now)
- Removed `.meta` from `.gitignore`
- Fixed broken scene references
- Upgraded project to 2020.3.17
2021-09-15 11:23:06 +01:00
Jedd Morgan 67e0efeb18 Merge pull request #39 from psarras/assemblies
added assemblies in preparation for creating a Package #7
2021-09-14 16:31:59 +01:00
Jedd Morgan 5a702d00eb Merge pull request #40 from haitheredavid/fix/37
fix: editor namespace break
2021-09-14 16:11:21 +01:00
David Morgan f13ff5519e forgot endif 2021-08-12 10:12:31 -05:00
David Morgan 73f9ebec65 wrapped unity editor name space 2021-08-12 07:24:41 -05:00
spsarras d1a7623cc9 added assemblies in preparation for creating a Package #7 2021-08-12 10:57:14 +01:00
Matteo Cominetti 19a7cbff76 fix: missing scripts in playground scene 2021-08-11 14:11:33 +01:00
Matteo Cominetti 37554b9e63 Merge pull request #35 from pkratten/main
fix: actually apply found material.
2021-08-09 17:18:27 +01:00
Peter Krattenmacher aa3ce05498 fix: actually apply found material. 2021-08-08 20:33:45 +02:00
Matteo Cominetti c0ce0d3a97 Merge pull request #34 from specklesystems/material-assets
Material assets
2021-08-01 13:35:16 +01:00
Matteo Cominetti 62e98a3f93 refractor: unity is updating some stuff 2021-08-01 14:33:11 +02:00
Matteo Cominetti 4ae838bdc6 fix: checks for empty material names 2021-08-01 14:32:19 +02:00
Matteo Cominetti f0b2c7f151 feat: updates objects library 2021-08-01 14:08:30 +02:00
Peter Krattenmacher 52133c15fc feat: generate material assets if not present 2021-07-22 11:08:32 +02:00
Matteo Cominetti 4dfd26f730 feat: updates playground 2021-07-08 16:00:09 +01:00
Matteo Cominetti b071f87d48 refractor: restores 2 space indent 2021-07-08 15:54:32 +01:00
Matteo Cominetti 0ba69b311b Merge remote-tracking branch 'david/editorDM' into main
# Conflicts:
#	Assets/Speckle Connector/Editor/StreamManagerEditor.cs
2021-07-08 15:53:01 +01:00
Matteo Cominetti bb3c7df806 Merge pull request #26 from specklesystems/dim/quick-fix
feat(core): dispose transport flag for receiving
2021-07-08 15:35:44 +01:00
Matteo Cominetti 1e0d533fab feat: updates playground 2021-07-08 15:31:53 +01:00
Matteo Cominetti 4ad1387de8 feat: updates playground scene 2021-07-08 15:21:25 +01:00
Matteo Cominetti b090a881a5 feat: updates core 2021-07-08 14:56:58 +01:00
Dimitrie Stefanescu 1fd0ea9873 fix: one more call fixed 2021-07-05 07:53:25 +01:00
Dimitrie Stefanescu ccde4ed9a2 feat(core): dispose transport flag for receiving
re https://github.com/specklesystems/speckle-sharp/pull/557 (not essential; default behaviour still
ok, but this is to keep things aligned)
2021-07-05 07:42:25 +01:00
David Morgan 5ae2893733 fix: checking for bbox
Issue with bbox not being set on all mesh objects of Base
2021-07-01 10:17:50 -05:00
David Morgan 5922e373eb feat: Basic UV support
Added simple logic for creating UV's during mesh creation.
2021-06-30 19:11:08 -05:00
David Morgan 97125e251f fix: Removed Newtonsoft.Json.dll
Seems like this .dll is already referenced in the packages-lock.json
2021-06-30 17:45:57 -05:00
David Morgan bc2c8269ed fix: Stream Manager Editor account info display
Changed StreamManagerEditor.cs to use account email rather than username since the popup utility will squash similar string values
2021-06-30 17:44:32 -05:00
David Morgan 054fe68fc3 feat: non leaking meshes generated in editor mode
Addressed issue with unity bugging out over meshes being created in editor mode by modifying the conversion process ConverterUnity.Geometry.cs. Also modified stream manager to manage the RecursiveConverter.cs component access
2021-06-30 17:40:38 -05:00
Matteo Cominetti d975978800 feat: updates sample scene 2021-06-29 22:13:22 +01:00
Matteo Cominetti 8a1e781e9e Merge pull request #23 from specklesystems/editor2
feat: receive in editor mode
2021-06-29 20:27:09 +01:00
Matteo Cominetti fd2f4cf175 feat: receive in editor mode 2021-06-29 20:26:36 +01:00
Matteo Cominetti 0a3304f958 feat: updates core and sets sourceApp on send 2021-06-15 13:51:34 +01:00
Matteo Cominetti 29e74841ef Merge pull request #15 from specklesystems/tutorial/revit-unity
Receiver and material improvements
2021-04-21 19:13:03 +01:00
Matteo Cominetti 13481e5932 feat: minor cleanup 2021-04-21 19:12:18 +01:00
429 changed files with 22943 additions and 3685 deletions
+210
View File
@@ -0,0 +1,210 @@
root = true
# Don't use tabs for indentation.
[*]
indent_style = space
# Microsoft .NET properties
csharp_using_directive_placement = outside_namespace:silent
dotnet_style_parentheses_in_arithmetic_binary_operators = never_if_unnecessary:none
dotnet_style_parentheses_in_other_binary_operators = never_if_unnecessary:none
dotnet_style_parentheses_in_relational_binary_operators = never_if_unnecessary:none
# ReSharper properties
resharper_align_linq_query = false
resharper_align_multiline_calls_chain = true
resharper_align_multiline_extends_list = true
resharper_align_multiline_for_stmt = true
resharper_align_multiline_parameter = true
resharper_align_multiple_declaration = true
resharper_align_multline_type_parameter_constrains = true
resharper_align_multline_type_parameter_list = true
resharper_braces_for_dowhile = not_required
resharper_braces_for_fixed = not_required
resharper_braces_for_lock = not_required
resharper_braces_for_using = not_required
resharper_csharp_align_multiline_calls_chain = false
resharper_csharp_align_multiline_extends_list = false
resharper_csharp_align_multiline_parameter = false
resharper_csharp_int_align_comments = false
resharper_csharp_outdent_commas = true
resharper_csharp_outdent_dots = false
resharper_csharp_wrap_after_declaration_lpar = true
resharper_csharp_wrap_after_invocation_lpar = true
resharper_csharp_wrap_arguments_style = chop_if_long
resharper_csharp_wrap_before_declaration_rpar = true
resharper_csharp_wrap_before_invocation_rpar = false
resharper_csharp_wrap_extends_list_style = chop_if_long
resharper_csharp_wrap_parameters_style = chop_if_long
resharper_force_attribute_style = join
resharper_indent_nested_fixed_stmt = false
resharper_indent_nested_foreach_stmt = true
resharper_indent_nested_for_stmt = true
resharper_indent_nested_lock_stmt = false
resharper_indent_nested_usings_stmt = false
resharper_indent_nested_while_stmt = true
resharper_int_align = false
resharper_int_align_nested_ternary = false
resharper_int_align_switch_expressions = false
resharper_keep_existing_declaration_block_arrangement = true
resharper_keep_existing_declaration_parens_arrangement = false
resharper_keep_existing_embedded_block_arrangement = true
resharper_keep_existing_enum_arrangement = true
resharper_keep_existing_expr_member_arrangement = true
resharper_keep_existing_initializer_arrangement = false
resharper_local_function_body = expression_body
resharper_max_attribute_length_for_same_line = 20
resharper_max_formal_parameters_on_line = 5
resharper_max_initializer_elements_on_line = 0
resharper_max_invocation_arguments_on_line = 5
resharper_outdent_binary_ops = true
resharper_outdent_dots = false
resharper_place_constructor_initializer_on_same_line = false
resharper_place_simple_initializer_on_single_line = true
resharper_prefer_explicit_discard_declaration = false
resharper_wrap_after_declaration_lpar = false
resharper_wrap_before_invocation_rpar = false
resharper_wrap_chained_binary_expressions = chop_if_long
resharper_wrap_chained_binary_patterns = chop_if_long
resharper_wrap_chained_method_calls = chop_if_long
resharper_xmldoc_indent_text = ZeroIndent
# Standard properties
insert_final_newline = true
# (Please don't specify an indent_size here; that has too many unintended consequences.)
# Code files
[*.{cs,csx,vb,vbx}]
indent_size = 4
charset = utf-8
# Xml project files
[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}]
indent_size = 2
space_after_last_pi_attribute = false
# Xml config files
[*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}]
indent_size = 2
space_after_last_pi_attribute = false
# JSON files
[*.json]
indent_size = 2
# Dotnet code style settings:
[*.{cs,vb}]
# Sort using and Import directives with System.* appearing first
dotnet_sort_system_directives_first = true
dotnet_separate_import_directive_groups = false
# Avoid "this." and "Me." if not necessary
dotnet_style_qualification_for_field = false:suggestion
dotnet_style_qualification_for_property = false:suggestion
dotnet_style_qualification_for_method = false:suggestion
dotnet_style_qualification_for_event = false:suggestion
# Use language keywords instead of framework type names for type references
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
dotnet_style_predefined_type_for_member_access = true:suggestion
# Parentheses preferences
dotnet_style_parentheses_in_arithmetic_binary_operators = never_if_unnecessary:silent
dotnet_style_parentheses_in_relational_binary_operators = never_if_unnecessary:silent
dotnet_style_parentheses_in_other_binary_operators = never_if_unnecessary:silent
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent
# Modifier preferences
dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent
dotnet_style_readonly_field = true:suggestion
# Expression-level preferences
dotnet_style_object_initializer = true:suggestion
dotnet_style_collection_initializer = true:suggestion
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_null_propagation = true:suggestion
dotnet_style_explicit_tuple_names = true:suggestion
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:silent
dotnet_style_prefer_inferred_tuple_names = true:suggestion
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
dotnet_style_prefer_auto_properties = true:warning
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
dotnet_style_prefer_conditional_expression_over_return = true:silent
# CSharp code style settings:
[*.cs]
# Prefer "var" everywhere
csharp_style_var_elsewhere = false:none
csharp_style_var_for_built_in_types = false:none
csharp_style_var_when_type_is_apparent = false:none
# Prefer method-like constructs to have a block body
csharp_style_expression_bodied_methods = false:suggestion
csharp_style_expression_bodied_constructors = false:suggestion
csharp_style_expression_bodied_operators = true:suggestion
# Prefer property-like constructs to have an expression-body
csharp_style_expression_bodied_properties = true:suggestion
csharp_style_expression_bodied_indexers = true:suggestion
csharp_style_expression_bodied_accessors = true:suggestion
# Suggest more modern language features when available
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
csharp_style_inlined_variable_declaration = true:suggestion
csharp_style_throw_expression = true:suggestion
csharp_style_conditional_delegate_call = true:suggestion
# Newline settings
csharp_new_line_before_open_brace = all
csharp_new_line_before_else = true
csharp_new_line_before_catch = true
csharp_new_line_before_finally = true
csharp_new_line_before_members_in_object_initializers = true
csharp_new_line_before_members_in_anonymous_types = true
# Space preferences
csharp_space_after_cast = false
csharp_space_after_keywords_in_control_flow_statements = true
csharp_space_between_method_call_parameter_list_parentheses = false
csharp_space_between_method_declaration_parameter_list_parentheses = false
csharp_space_between_parentheses = false
csharp_space_before_colon_in_inheritance_clause = true
csharp_space_after_colon_in_inheritance_clause = true
csharp_space_around_binary_operators = before_and_after
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
csharp_space_between_method_call_name_and_opening_parenthesis = false
csharp_space_between_method_call_empty_parameter_list_parentheses = false
# Wrapping preferences
csharp_preserve_single_line_statements = true
csharp_preserve_single_line_blocks = true
# Analyzer settings
dotnet_diagnostic.ide0055.severity = none
# Maintainability rules
dotnet_diagnostic.ca1501.severity = warning
dotnet_diagnostic.ca1502.severity = warning
dotnet_diagnostic.ca1505.severity = warning
dotnet_diagnostic.ca1506.severity = warning
dotnet_diagnostic.ca1507.severity = warning
dotnet_diagnostic.ca1508.severity = warning
dotnet_diagnostic.ca1509.severity = warning
# Misc
dotnet_diagnostic.ca1051.severity = none # Do not declare visible instance fields
dotnet_diagnostic.ca1062.severity = none # Public method must check all parameters for null
dotnet_diagnostic.ca1707.severity = none # Remove underscores in names
dotnet_analyzer_diagnostic.category-globalization.severity = none
dotnet_analyzer_diagnostic.category-security.severity = none
dotnet_analyzer_diagnostic.category-interoperability.severity = none
dotnet_analyzer_diagnostic.category-singlefile.severity = none
[*.{appxmanifest,asax,ascx,aspx,axaml,build,c,c++,cc,cginc,compute,cp,cpp,cs,cshtml,cu,cuh,cxx,dtd,fs,fsi,fsscript,fsx,fx,fxh,h,hh,hlsl,hlsli,hlslinc,hpp,hxx,inc,inl,ino,ipp,ixx,master,ml,mli,mpp,mq4,mq5,mqh,nuspec,paml,razor,resw,resx,shader,skin,tpp,usf,ush,vb,xaml,xamlx,xoml,xsd}]
indent_style = space
indent_size = 4
tab_width = 2
+10 -3
View File
@@ -10,6 +10,9 @@
/[Ll]ogs/
/[Uu]ser[Ss]ettings/
#Test space content
/[Tt]estSpace/
# MemoryCaptures can get excessive in size.
# They also could contain extremely sensitive data
/[Mm]emoryCaptures/
@@ -42,14 +45,14 @@ ExportedObj/
*.pidb
*.booproj
*.svd
*.pdb
#*.pdb
*.mdb
*.opendb
*.VC.db
# Unity3D generated meta files
*.pidb.meta
*.pdb.meta
#*.pdb.meta
*.mdb.meta
# Unity3D generated file on crash reports
@@ -70,4 +73,8 @@ crashlytics-build.properties
/[Aa]ssets/[Ss]treamingAssets/aa.meta
/[Aa]ssets/[Ss]treamingAssets/aa/*
.idea/
*.meta
# Speckle cached recieved objects
/[Aa]ssets/[Rr]esources/[Mm]aterials/
/[Aa]ssets/[Rr]esources/[Gg]eometry/
/[Aa]ssets/[Rr]esources/[Pp]refabs/
-52
View File
@@ -1,52 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ContentModelStore">
<e p="C:\Code\Speckle-Next\speckle-unity\Speckle Unity" t="IncludeRecursive">
<e p="Assembly-CSharp.csproj" t="IncludeRecursive" />
<e p="Assets" t="Include">
<e p="Extra" t="Include">
<e p="CameraOperate.cs" t="Include" />
<e p="RosolynDirectoryCreator.cs" t="Include" />
<e p="Selectable.cs" t="Include" />
<e p="SelectionManager.cs" t="Include" />
</e>
<e p="First person controller" t="Include">
<e p="Scripts" t="Include">
<e p="Components" t="Include">
<e p="Crouch.cs" t="Include" />
<e p="FirstPersonAudio.cs" t="Include" />
<e p="GroundCheck.cs" t="Include" />
<e p="Jump.cs" t="Include" />
<e p="Zoom.cs" t="Include" />
</e>
<e p="FirstPersonLook.cs" t="Include" />
<e p="FirstPersonMovement.cs" t="Include" />
</e>
</e>
<e p="InteractionLogic.cs" t="Include" />
<e p="Speckle Connector" t="Include">
<e p="ConverterUnity.BuiltElements.cs" t="Include" />
<e p="ConverterUnity.cs" t="Include" />
<e p="ConverterUnity.Geometry.cs" t="Include" />
<e p="ConverterUnity.Units.cs" t="Include" />
<e p="Dispatcher.cs" t="Include" />
<e p="Receiver.cs" t="Include" />
<e p="Sender.cs" t="Include" />
<e p="SpeckleProperties.cs" t="Include" />
<e p="Streams.cs" t="Include" />
<e p="Utils.cs" t="Include" />
</e>
<e p="SpeckleExamples.cs" t="Include" />
<e p="Tutorial" t="Include">
<e p="Tutorial.cs" t="Include" />
</e>
</e>
<e p="obj" t="ExcludeRecursive" />
<e p="Packages" t="ExcludeRecursive" />
<e p="Speckle Unity.sln" t="IncludeFlat" />
<e p="Temp\Bin" t="ExcludeRecursive" />
</e>
<e p="C:\Users\Admin\AppData\Local\JetBrains\Rider2020.2\extResources" t="IncludeRecursive" />
<e p="C:\Users\Admin\AppData\Local\JetBrains\Rider2020.2\resharper-host\Local\Transient\Rider\v202\SolutionCaches\_Speckle Unity.-1593363948.00" t="ExcludeRecursive" />
</component>
</project>
-8
View File
@@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/.idea.Speckle Unity/riderModule.iml" filepath="$PROJECT_DIR$/.idea/.idea.Speckle Unity/riderModule.iml" />
</modules>
</component>
</project>
-7
View File
@@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="RIDER_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$/../.." />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
+6
View File
@@ -0,0 +1,6 @@
{
"version": "1.0",
"components": [
"Microsoft.VisualStudio.Workload.ManagedGame"
]
}
@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: addaa5ebcd10c5245bf8d074437d5b37
guid: f7f8762fcd0c1174782d2ba683cb6b74
folderAsset: yes
DefaultImporter:
externalObjects: {}
@@ -0,0 +1,62 @@
using System.Collections;
using System.Collections.Generic;
using Objects.Converter.Unity;
using Speckle.ConnectorUnity.Utils;
using Speckle.ConnectorUnity.Wrappers;
using Speckle.Core.Api;
using Speckle.Core.Credentials;
using Speckle.Core.Models;
using Speckle.Core.Transports;
using UnityEngine;
/// <summary>
/// Example script for grabbing speckle properties for a specific object "on-the-fly"
/// </summary>
/// <remarks>
/// see discussion https://speckle.community/t/reloading-assemblies-takes-too-long/6708
/// </remarks>
[AddComponentMenu("Speckle/Extras/" + nameof(AttachSpecklePropertiesExample))]
public class AttachSpecklePropertiesExample : MonoBehaviour
{
public string streamId;
public string objectId;
public virtual void Start()
{
Client speckleClient = new(AccountManager.GetDefaultAccount());
StartCoroutine(AttachSpeckleProperties(speckleClient, streamId, objectId));
}
public IEnumerator AttachSpeckleProperties(
Client speckleClient,
string streamId,
string objectId
)
{
//Fetch the object from Speckle
ServerTransport remoteTransport = new(speckleClient.Account, streamId);
Utils.WaitForTask<Base> operation =
new(async () => await Operations.Receive(objectId, remoteTransport));
//yield until task completes
yield return operation;
Base speckleObject = operation.Result;
//Do something with the properties. e.g. attach SpeckleProperties component
DoSomething(speckleObject);
}
protected virtual void DoSomething(Base speckleObject)
{
//GetProperties will filter "useful" properties
Dictionary<string, object> properties = ConverterUnity.GetProperties(
speckleObject,
typeof(SpeckleObject)
);
var sd = this.gameObject.AddComponent<SpeckleProperties>();
sd.Data = properties;
sd.SpeckleType = speckleObject.GetType();
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b5627857f30c8994c87469d287b2d115
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+172 -172
View File
@@ -22,193 +22,193 @@ using UnityEngine;
public class CameraOperate : MonoBehaviour
{
[Tooltip("Mouse wheel rolling control lens please enter, the speed of the back")]
[Range(0.5f, 10f)] public float scrollSpeed = 10f;
[Tooltip("Right mouse button control lens X axis rotation speed")]
[Range(0.5f, 2f)] public float rotateXSpeed = 1f;
[Tooltip("Right mouse button control lens Y axis rotation speed")]
[Range(0.5f, 2f)] public float rotateYSpeed = 1f;
[Tooltip("Mouse wheel press, lens translation speed")]
[Range(0.5f, 2f)] public float moveSpeed = 1f;
[Tooltip("The keyboard controls how fast the camera moves")]
[Range(0.5f, 2f)] public float keyMoveSpeed = 1f;
[Tooltip("Mouse wheel rolling control lens please enter, the speed of the back")]
[Range(0f, 10f)] public float scrollSpeed = 10f;
[Tooltip("Right mouse button control lens X axis rotation speed")]
[Range(0.5f, 2f)] public float rotateXSpeed = 1f;
[Tooltip("Right mouse button control lens Y axis rotation speed")]
[Range(0.5f, 2f)] public float rotateYSpeed = 1f;
[Tooltip("Mouse wheel press, lens translation speed")]
[Range(0.5f, 2f)] public float moveSpeed = 1f;
[Tooltip("The keyboard controls how fast the camera moves")]
[Range(0.5f, 2f)] public float keyMoveSpeed = 1f;
//Whether the lens control operation is performed
//是否进行镜头控制操作
public bool operate = true;
//Whether the lens control operation is performed
//是否进行镜头控制操作
public bool operate = true;
//Whether keyboard control lens operation is performed
//是否进行键盘控制镜头操作
public bool isKeyOperate = true;
//Whether keyboard control lens operation is performed
//是否进行键盘控制镜头操作
public bool isKeyOperate = true;
//Whether currently in rotation
//目前是否在轮换
private bool isRotate = false;
//Whether currently in rotation
//目前是否在轮换
private bool isRotate = false;
//Is currently in panning
//目前在平移吗
private bool isMove = false;
//Is currently in panning
//目前在平移吗
private bool isMove = false;
//Camera transform component cache
//摄像机转换组件缓存
private Transform m_transform;
//Camera transform component cache
//摄像机转换组件缓存
private Transform m_transform;
//The initial position of the camera at the beginning of the operation
//摄像机在开始进行操作时摄像机初始的位置
private Vector3 traStart;
//The initial position of the camera at the beginning of the operation
//摄像机在开始进行操作时摄像机初始的位置
private Vector3 traStart;
//The initial position of the mouse as the camera begins to operate
//摄像机在开始进行操作时鼠标初始的位置
private Vector3 mouseStart;
//The initial position of the mouse as the camera begins to operate
//摄像机在开始进行操作时鼠标初始的位置
private Vector3 mouseStart;
//Is the camera facing down
//摄像机是否镜头朝下
private bool isDown = false;
//Is the camera facing down
//摄像机是否镜头朝下
private bool isDown = false;
// Start is called before the first frame update
void Start()
// Start is called before the first frame update
void Start()
{
m_transform = transform;
}
// Update is called once per frame
void Update()
{
if (operate)
{
m_transform = transform;
}
//When in the rotation state, and the right mouse button is released, then exit the rotation state
//当处于旋转状态,且鼠标右键放开,则退出旋转状态
if (isRotate && Input.GetMouseButtonUp(1))
{
isRotate = false;
}
//When it is in the translation state, and the mouse wheel is released, it will exit the translation state
//当处于平移状态,且鼠标滚轮放开,则退出平移状态
if (isMove && Input.GetMouseButtonUp(2))
{
isMove = false;
}
// Update is called once per frame
void Update()
{
if (operate)
//Whether it's in a rotational state
//是否处于旋转状态
if (isRotate)
{
//Gets the offset of the mouse on the screen
//获取鼠标在屏幕上的偏移量
Vector3 offset = Input.mousePosition - mouseStart;
// whether the lens is facing down
//是否镜头朝下
if (isDown)
{
//When in the rotation state, and the right mouse button is released, then exit the rotation state
//当处于旋转状态,且鼠标右键放开,则退出旋转状态
if (isRotate && Input.GetMouseButtonUp(1))
{
isRotate = false;
}
//When it is in the translation state, and the mouse wheel is released, it will exit the translation state
//当处于平移状态,且鼠标滚轮放开,则退出平移状态
if (isMove && Input.GetMouseButtonUp(2))
{
isMove = false;
}
//Whether it's in a rotational state
//是否处于旋转状态
if (isRotate)
{
//Gets the offset of the mouse on the screen
//获取鼠标在屏幕上的偏移量
Vector3 offset = Input.mousePosition - mouseStart;
// whether the lens is facing down
//是否镜头朝下
if (isDown)
{
// the final rotation Angle = initial Angle + offset, 0.3f coefficient makes the rotation speed normal when rotateYSpeed, rotateXSpeed is 1
//最后的旋转角度 = 初始角度 + 偏移量,0.3f系数使得当rotateYSpeedrotateXSpeed为1的时候,旋转速度正常
m_transform.rotation = Quaternion.Euler(traStart + new Vector3(offset.y * 0.3f * rotateYSpeed, -offset.x * 0.3f * rotateXSpeed, 0));
}
else
{
// final rotation Angle = initial Angle + offset
//最后的旋转角度 = 初始角度 + 偏移量
m_transform.rotation = Quaternion.Euler(traStart + new Vector3(-offset.y * 0.3f * rotateYSpeed, offset.x * 0.3f * rotateXSpeed, 0));
}
// simulate the unity editor operation: right click, the keyboard can control the lens movement
//模仿unity编辑器操作:右键按下,键盘可以控制镜头移动
if (isKeyOperate)
{
float speed = keyMoveSpeed;
// press LeftShift to make speed *2
//按下LeftShift使得速度*2
if (Input.GetKey(KeyCode.LeftShift))
{
speed = 2f * speed;
}
// press W on the keyboard to move the camera forward
//键盘W键按下,镜头前进
if (Input.GetKey(KeyCode.W))
{
m_transform.position += m_transform.forward * Time.deltaTime * 10f * speed;
}
// press the S key on the keyboard to back up the camera
//键盘S键按下,镜头后退
if (Input.GetKey(KeyCode.S))
{
m_transform.position -= m_transform.forward * Time.deltaTime * 10f * speed;
}
// press A on the keyboard and the camera will turn left
//键盘A键按下,镜头向左
if (Input.GetKey(KeyCode.A))
{
m_transform.position -= m_transform.right * Time.deltaTime * 10f * speed;
}
// press D on the keyboard to turn the camera to the right
//键盘D键按下,镜头向右
if (Input.GetKey(KeyCode.D))
{
m_transform.position += m_transform.right * Time.deltaTime * 10f * speed;
}
}
}
// press the right mouse button to enter the rotation state
//鼠标右键按下,表示进入旋转状态
else if (Input.GetMouseButtonDown(1))
{
// enter the rotation state
//进入旋转状态
isRotate = true;
// record the initial position of the mouse in order to calculate the offset
//记录鼠标初始位置,为了计算偏移量
mouseStart = Input.mousePosition;
// record the initial mouse Angle
//记录鼠标初始角度
traStart = m_transform.rotation.eulerAngles;
// to determine whether the lens is facing down (the Y-axis is <0 according to the position of the object facing up),-0.0001f is a special case when x rotates 90
//判断镜头是否朝下(根据物体朝上的位置的y轴是<0),-0.0001f是x旋转90的时候的特例
isDown = m_transform.up.y < -0.0001f ? true : false;
}
// whether it is in the translation state
//是否处于平移状态
if (isMove)
{
// mouse offset on the screen
//鼠标在屏幕上的偏移量
Vector3 offset = Input.mousePosition - mouseStart;
// final position = initial position + offset
//最终位置 = 初始位置 + 偏移量
m_transform.position = traStart + m_transform.up * -offset.y * 0.1f * moveSpeed + m_transform.right * -offset.x * 0.1f * moveSpeed;
}
// click the mouse wheel to enter translation mode
//鼠标滚轮按下,进入平移模式
else if (Input.GetMouseButtonDown(2))
{
// translation begins
//平移开始
isMove = true;
// record the initial position of the mouse
//记录鼠标初始位置
mouseStart = Input.mousePosition;
// record the initial position of the camera
//记录摄像机初始位置
traStart = m_transform.position;
}
// how much did the roller roll
//滚轮滚动了多少
float scroll = Input.GetAxis("Mouse ScrollWheel");
// scroll to scroll or not
//滚动是否滚动
if (scroll != 0)
{
// position = current position + scroll amount
//位置 = 当前位置 + 滚动量
m_transform.position += m_transform.forward * scroll * 1000f * Time.deltaTime * scrollSpeed;
}
// the final rotation Angle = initial Angle + offset, 0.3f coefficient makes the rotation speed normal when rotateYSpeed, rotateXSpeed is 1
//最后的旋转角度 = 初始角度 + 偏移量,0.3f系数使得当rotateYSpeedrotateXSpeed为1的时候,旋转速度正常
m_transform.rotation = Quaternion.Euler(traStart + new Vector3(offset.y * 0.3f * rotateYSpeed, -offset.x * 0.3f * rotateXSpeed, 0));
}
else
{
// final rotation Angle = initial Angle + offset
//最后的旋转角度 = 初始角度 + 偏移量
m_transform.rotation = Quaternion.Euler(traStart + new Vector3(-offset.y * 0.3f * rotateYSpeed, offset.x * 0.3f * rotateXSpeed, 0));
}
// simulate the unity editor operation: right click, the keyboard can control the lens movement
//模仿unity编辑器操作:右键按下,键盘可以控制镜头移动
if (isKeyOperate)
{
float speed = keyMoveSpeed;
// press LeftShift to make speed *2
//按下LeftShift使得速度*2
if (Input.GetKey(KeyCode.LeftShift))
{
speed = 2f * speed;
}
// press W on the keyboard to move the camera forward
//键盘W键按下,镜头前进
if (Input.GetKey(KeyCode.W))
{
m_transform.position += m_transform.forward * Time.deltaTime * 10f * speed;
}
// press the S key on the keyboard to back up the camera
//键盘S键按下,镜头后退
if (Input.GetKey(KeyCode.S))
{
m_transform.position -= m_transform.forward * Time.deltaTime * 10f * speed;
}
// press A on the keyboard and the camera will turn left
//键盘A键按下,镜头向左
if (Input.GetKey(KeyCode.A))
{
m_transform.position -= m_transform.right * Time.deltaTime * 10f * speed;
}
// press D on the keyboard to turn the camera to the right
//键盘D键按下,镜头向右
if (Input.GetKey(KeyCode.D))
{
m_transform.position += m_transform.right * Time.deltaTime * 10f * speed;
}
}
}
// press the right mouse button to enter the rotation state
//鼠标右键按下,表示进入旋转状态
else if (Input.GetMouseButtonDown(1))
{
// enter the rotation state
//进入旋转状态
isRotate = true;
// record the initial position of the mouse in order to calculate the offset
//记录鼠标初始位置,为了计算偏移量
mouseStart = Input.mousePosition;
// record the initial mouse Angle
//记录鼠标初始角度
traStart = m_transform.rotation.eulerAngles;
// to determine whether the lens is facing down (the Y-axis is <0 according to the position of the object facing up),-0.0001f is a special case when x rotates 90
//判断镜头是否朝下(根据物体朝上的位置的y轴是<0),-0.0001f是x旋转90的时候的特例
isDown = m_transform.up.y < -0.0001f ? true : false;
}
// whether it is in the translation state
//是否处于平移状态
if (isMove)
{
// mouse offset on the screen
//鼠标在屏幕上的偏移量
Vector3 offset = Input.mousePosition - mouseStart;
// final position = initial position + offset
//最终位置 = 初始位置 + 偏移量
m_transform.position = traStart + m_transform.up * -offset.y * 0.1f * moveSpeed + m_transform.right * -offset.x * 0.1f * moveSpeed;
}
// click the mouse wheel to enter translation mode
//鼠标滚轮按下,进入平移模式
else if (Input.GetMouseButtonDown(2))
{
// translation begins
//平移开始
isMove = true;
// record the initial position of the mouse
//记录鼠标初始位置
mouseStart = Input.mousePosition;
// record the initial position of the camera
//记录摄像机初始位置
traStart = m_transform.position;
}
// how much did the roller roll
//滚轮滚动了多少
float scroll = Input.GetAxis("Mouse ScrollWheel");
// scroll to scroll or not
//滚动是否滚动
if (scroll != 0)
{
// position = current position + scroll amount
//位置 = 当前位置 + 滚动量
m_transform.position += m_transform.forward * scroll * 1000f * Time.deltaTime * scrollSpeed;
}
}
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6c972b8c7391a8243869747abd85964f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+71
View File
@@ -0,0 +1,71 @@
using System;
using System.Collections;
using System.Threading.Tasks;
using Speckle.ConnectorUnity;
using Speckle.ConnectorUnity.Components;
using Speckle.Core.Api;
using Speckle.Core.Credentials;
using Speckle.Core.Transports;
using UnityEngine;
[AddComponentMenu("Speckle/Extras/Manual Receiver")]
[RequireComponent(typeof(RecursiveConverter))]
public class ManualReceive : MonoBehaviour
{
public string authToken;
public string serverUrl;
public string streamId, objectId;
private RecursiveConverter receiver;
void Awake()
{
receiver = GetComponent<RecursiveConverter>();
}
IEnumerator Start()
{
Debug.developerConsoleVisible = true;
if(Time.timeSinceLevelLoad > 20) yield return null;
Receive();
}
[ContextMenu(nameof(Receive))]
public void Receive()
{
var account = new Account()
{
token = authToken,
serverInfo = new ServerInfo() {url = serverUrl},
};
Task.Run(async () =>
{
var transport = new ServerTransport(account, streamId);
var localTransport = new MemoryTransport();
var @base = await Operations.Receive(
objectId,
remoteTransport: transport,
localTransport: localTransport,
onErrorAction: (m, e) => Debug.LogError(m + e),
disposeTransports: true
);
if (@base == null) throw new Exception("received data was null!");
Dispatcher.Instance().Enqueue(() =>
{
var parentObject = new GameObject(name);
receiver.RecursivelyConvertToNative_Sync(@base, parentObject.transform);
Debug.Log($"Receive {objectId} completed");
});
});
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 66c38558aa523bf4290b4fd84411df46
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+79
View File
@@ -0,0 +1,79 @@
using System.Threading;
using System.Threading.Tasks;
using Speckle.ConnectorUnity.Components;
using Speckle.Core.Api;
using Speckle.Core.Models;
using Speckle.Core.Transports;
using UnityEngine;
namespace Extra
{
/// <summary>
/// Script used to generate streams for performance benchmarking in other hostApps.
/// Will send several several commits with a varying number of copies on a GameObject (with children)
/// </summary>
[ExecuteAlways]
[RequireComponent(typeof(SpeckleSender))]
public sealed class PerformanceTestSender : MonoBehaviour
{
[Range(0, 100)]
public int numberOfIterations = 10;
public Vector3 translation = Vector3.forward * 100;
public GameObject objectToSend;
private SpeckleSender sender;
private void Awake()
{
sender = GetComponent<SpeckleSender>();
}
public async Task SendIterations()
{
GameObject go = new GameObject();
for (int i = 0; i < numberOfIterations; i++)
{
Instantiate(objectToSend, translation * i, Quaternion.identity, go.transform);
Base b = sender.Converter.RecursivelyConvertToSpeckle(go, _ => true);
await Send(b, $"{i}");
}
Debug.Log("Done!");
}
private async Task<string> Send(Base data, string branchName)
{
var client = sender.Account.Client;
var stream = sender.Stream.Selected;
ServerTransport transport = new ServerTransport(sender.Account.Selected, stream!.id);
await client.BranchCreate(new BranchCreateInput(){streamId = stream.id, name = branchName});
return await SpeckleSender.SendDataAsync(CancellationToken.None,
remoteTransport: transport,
data: data,
client: client!,
branchName: branchName,
createCommit: true,
onProgressAction: null,
onErrorAction: (m, e) => throw e);
}
}
#if UNITY_EDITOR
[UnityEditor.CustomEditor(typeof(PerformanceTestSender))]
public sealed class PerformanceTestSenderEditor : UnityEditor.Editor
{
public override async void OnInspectorGUI()
{
DrawDefaultInspector();
if (GUILayout.Button("Create and send"))
{
await ((PerformanceTestSender)target).SendIterations();
}
}
}
#endif
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c98b93e32c844fb488992e2e376447a1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+5 -3
View File
@@ -1,7 +1,8 @@
using System.IO;
using System.Text.RegularExpressions;
using UnityEditor;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
namespace Speckle.ConnectorUnity
{
@@ -21,7 +22,7 @@ namespace Speckle.ConnectorUnity
return;
const string pattern =
@"^DirectoryNotFoundException: Could not find a part of the path '.*?\\Temp\\RoslynAnalysisRunner'\.$";
@"^DirectoryNotFoundException: Could not find a part of the path '.*?\\Temp\\RoslynAnalysisRunner'\.$";
if (Regex.IsMatch(message, pattern))
{
@@ -29,4 +30,5 @@ namespace Speckle.ConnectorUnity
}
}
}
}
}
#endif
+30 -32
View File
@@ -4,45 +4,43 @@ using UnityEngine;
//Thanks to : https://sharpcoderblog.com/blog/unity-3d-rts-style-unit-selection
[AddComponentMenu("Speckle/Playground/Selectable"), DisallowMultipleComponent]
public class Selectable : MonoBehaviour
{
public Bounds GetObjectBounds()
public Bounds GetObjectBounds()
{
Bounds totalBounds = new Bounds();
var renderers = this.gameObject.GetComponents<MeshRenderer>();
foreach (var r in renderers)
{
Bounds totalBounds = new Bounds();
var renderers = this.gameObject.GetComponents<MeshRenderer>();
foreach (var r in renderers)
{
if(totalBounds.center == Vector3.zero)
{
totalBounds = r.bounds;
}
else
{
totalBounds.Encapsulate(r.bounds);
}
}
return totalBounds;
if (totalBounds.center == Vector3.zero)
{
totalBounds = r.bounds;
}
else
{
totalBounds.Encapsulate(r.bounds);
}
}
void OnEnable()
{
//Add this Object to global list
if (!SelectionManager.selectables.Contains(this))
{
SelectionManager.selectables.Add(this);
}
}
return totalBounds;
}
void OnDisable()
void OnEnable()
{
//Add this Object to global list
if (!SelectionManager.selectables.Contains(this))
{
//Remove this Object from global list
if (SelectionManager.selectables.Contains(this))
{
SelectionManager.selectables.Remove(this);
}
SelectionManager.selectables.Add(this);
}
}
void OnDisable()
{
SelectionManager.selectables.Remove(this);
SelectionManager.selectedObjects.Remove(this);
}
}
+8 -7
View File
@@ -4,6 +4,7 @@ using UnityEngine;
using UnityEngine.EventSystems;
//Thanks to : https://sharpcoderblog.com/blog/unity-3d-rts-style-unit-selection
[AddComponentMenu("Speckle/Playground/Selection Manager"), DisallowMultipleComponent]
public class SelectionManager : MonoBehaviour
{
public Texture topLeftBorder;
@@ -32,7 +33,7 @@ public class SelectionManager : MonoBehaviour
Vector3 mousePosition1;
public static List<Selectable> selectables = new List<Selectable>();
public static List<int> selectedObjects = new List<int>();
public static List<Selectable> selectedObjects = new List<Selectable>();
// Update is called once per frame
void Update()
@@ -59,14 +60,14 @@ public class SelectionManager : MonoBehaviour
Camera camera = Camera.main;
if (camera == null)
return;
selectedObjects.Clear();
for (int i = 0; i < selectables.Count; i++)
Bounds viewportBounds = GetViewportBounds(camera, mousePosition1, Input.mousePosition);
foreach (var t in selectables)
{
Bounds viewportBounds = GetViewportBounds(camera, mousePosition1, Input.mousePosition);
if (viewportBounds.Contains(camera.WorldToViewportPoint(selectables[i].transform.position)))
if (viewportBounds.Contains(camera.WorldToViewportPoint(t.transform.position)))
{
selectedObjects.Add(i);
selectedObjects.Add(t);
}
}
}
@@ -86,7 +87,7 @@ public class SelectionManager : MonoBehaviour
Camera camera = Camera.main;
for (int i = 0; i < selectedObjects.Count; i++)
{
DrawSelectionIndicator(camera, selectables[selectedObjects[i]].GetObjectBounds());
DrawSelectionIndicator(camera, selectedObjects[i].GetObjectBounds());
}
}
}
+59
View File
@@ -0,0 +1,59 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Immutable;
using System.Linq;
using Speckle.ConnectorUnity;
using UnityEngine;
[RequireComponent(typeof(Sender)), ExecuteAlways]
[Obsolete]
public class SendChildrenToSpeckle : MonoBehaviour
{
public LayerMask layerMask;
public string streamId;
public string branchName = "main";
public bool createCommit = true;
private Sender sender;
void Awake()
{
sender = GetComponent<Sender>();
}
[ContextMenu(nameof(Send))]
public void Send()
{
var selected = GetComponentsInChildren<Transform>()
.Where(t => t != this.transform)
.Select(o => o.gameObject)
.ToImmutableHashSet();
Debug.Log("starting send...");
sender.Send(
streamId,
selected,
null,
branchName,
createCommit,
onErrorAction: OnError,
onProgressAction: OnProgress,
onDataSentAction: OnSent
);
}
private void OnSent(string objectId)
{
Debug.Log($"Data sent {objectId}", this);
}
private void OnError(string message, Exception e)
{
Debug.LogError($"Error while sending {message} \n {e}", this);
}
private void OnProgress(ConcurrentDictionary<string, int> dict)
{
Debug.Log($"progress was made", this);
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 06440602a29587942a9b041f6e277a93
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+20
View File
@@ -0,0 +1,20 @@
{
"name": "Speckle.Extra",
"rootNamespace": "",
"references": [
"GUID:eed1b8b83e2c0074d9e5de2348e3ff72",
"GUID:e6adfdc4e436206479f48eafc82f32b5",
"GUID:d274441ecc3eb3f43b093eec1503d681",
"GUID:50d889142fdf9de4b8501c6eaa4b3225",
"GUID:7383cd71541a2aa48a7baf23f74b4d5f"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}
+7
View File
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 5e69a9305ecfb37438ec1f98750d0b13
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 2822f83843986b844820ecb3fe7c2c98
guid: 56f15216bd310954bb57d0900839c613
folderAsset: yes
DefaultImporter:
externalObjects: {}
+28
View File
@@ -0,0 +1,28 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Normals
m_Shader: {fileID: 4800000, guid: 75756b5b04ca7b5438e346a8f9f754ba, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats: []
m_Colors: []
m_BuildTextureStacks: []
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 763d54739fbe63e4bbd1598690d1af38
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,49 @@
Shader "Unlit/Normals"
{
Properties
{
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 100
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
half3 normal : NORMAL;
};
struct v2f
{
float4 vertex : SV_POSITION;
half3 normal : NORMAL;
};
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.normal = v.normal;
return o;
}
half4 frag (v2f i) : SV_Target
{
half4 color = 0;
color.rgb = i.normal * 0.5 + 0.5;
return color;
}
ENDCG
}
}
}
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 75756b5b04ca7b5438e346a8f9f754ba
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
preprocessorOverride: 0
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,87 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: SpeckleSurface
m_Shader: {fileID: 4800000, guid: 837fc98dbf6a92c479b902184ca947bf, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _GridSize: 128
- _Margin: 0.15
- _Metallic: 0
- _Mode: 0
- _Mul: 8192
- _NormalSaturation: 0.03
- _OcclusionStrength: 1
- _Parallax: 0.02
- _Saturation: 0.323
- _SmoothnessSaturation: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _Thickness: 0.32
- _UVSec: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _Color0: {r: 0.6, g: 0.6, b: 0.6, a: 1}
- _Color1: {r: 0.57, g: 0.57, b: 0.57, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
m_BuildTextureStacks: []
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 2830afbce900e634985de6a3930d9608
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,128 @@
Shader "Custom/SpeckleSurface"
{
Properties
{
[Header(Cube)]
_Thickness("Thickness", Range(0, 1)) = 0.32
_Margin("Margin", Range(0, 1)) = 0.15
_NormalSaturation("Normal Saturation", range(0,1)) = 0.03
_SmoothnessSaturation("Smoothness Saturation", range(0,1)) = 0.02
[Header(Tiling)]
_Mul("Multiple", int) = 8192
_GridSize("Grid Size", int) = 128
_Color0("Color 0", Color) = (0.6, 0.6, 0.6, 1)
_Color1("Color 1", Color) = (0.57, 0.57, 0.57, 1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
// Physically based Standard lighting model, and enable shadows on all light types
#pragma surface surf Standard fullforwardshadows
// Use shader model 3.0 target, to get nicer looking lighting
//#pragma target 3.0
struct Input
{
float2 uv_MainTex;
};
sampler2D _MainTex;
float _Thickness;
float _Margin;
int _Mul;
int _GridSize;
fixed4 _Color0;
fixed4 _Color1;
float _NormalSaturation;
float _SmoothnessSaturation;
// Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.
// See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing.
// #pragma instancing_options assumeuniformscaling
//UNITY_INSTANCING_BUFFER_START(Props)
// put more per-instance properties here
//UNITY_INSTANCING_BUFFER_END(Props)
fixed speckleSample(float2 pos)
{
// sample the texture
const fixed top = +0.5;
const fixed left = -1;
const fixed base = -0.5;
bool invert;
{ //Fine Grid
float2 grid_pos = (pos + 0.5) * _Mul / 2.0;
grid_pos = grid_pos - floor(grid_pos);
invert = grid_pos.x > 0.5 ^ grid_pos.y > 0.5;
}
float2 cell_pos = (pos + 0.5) * _Mul;
cell_pos = cell_pos - floor(cell_pos);
//cell_pos between 0-1 for each Speckle cube
fixed grey;
//Cube
{
if(cell_pos.x + cell_pos.y < 1.0)
grey = left;
else
grey = top;
if(cell_pos.x > _Thickness && cell_pos.y < 1.0 -_Thickness)
grey = base;
}
if(invert) grey = grey - 1;
//Ears
if( cell_pos.x + cell_pos.y < _Thickness
|| 1.0 - cell_pos.x + 1.0 - cell_pos.y < _Thickness)
{
grey = 0;
}
//Margins
const bool inCube = cell_pos.x > _Margin && cell_pos.y < 1.0 -_Margin;
if(!inCube) grey = 0;
return grey;
}
void surf (Input IN, inout SurfaceOutputStandard o)
{
fixed4 background = _Color0;
//Coarse grid
float2 grid_pos = (IN.uv_MainTex + 0.5) * _Mul / _GridSize;
grid_pos = grid_pos - floor(grid_pos);
if(grid_pos.x > 0.5 ^ grid_pos.y > 0.5)
{
background = _Color1;
}
const half grey = speckleSample(IN.uv_MainTex);
o.Albedo = background;
o.Metallic = 0.0;
o.Normal = o.Normal + (grey + 1) * _NormalSaturation;
o.Smoothness = grey * _SmoothnessSaturation;
o.Alpha = background.a;
}
ENDCG
}
FallBack "Diffuse"
}
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 837fc98dbf6a92c479b902184ca947bf
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
preprocessorOverride: 0
userData:
assetBundleName:
assetBundleVariant:
+47
View File
@@ -0,0 +1,47 @@
Shader "Unlit/UVs"
{
Properties
{
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 100
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float4 vertex : SV_POSITION;
float2 colors : TEXCOORD0;
};
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.colors = v.uv;
return o;
}
half4 frag (v2f i) : SV_Target
{
return half4(i.colors.x, i.colors.y, 0, 0);
}
ENDCG
}
}
}
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: f6778d5072232804689f36bb771a2122
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
preprocessorOverride: 0
userData:
assetBundleName:
assetBundleVariant:
+78
View File
@@ -0,0 +1,78 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Uvs
m_Shader: {fileID: 4800000, guid: f6778d5072232804689f36bb771a2122, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
m_BuildTextureStacks: []
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 6fe0ba5d1c59c7548be17ef9fb8e2e40
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,35 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: VertexColors
m_Shader: {fileID: 4800000, guid: 3b849de517d871d46874414758a096f2, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _Shininess: 0.078125
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _SpecColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
m_BuildTextureStacks: []
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c84690dfb148c6e4f8343f76b3cad987
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,47 @@
Shader "Unlit/VertexColors"
{
Properties
{
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 100
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
half4 color : COLOR0;
};
struct v2f
{
float4 vertex : SV_POSITION;
half4 color : COLOR0;
};
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.color = v.color;
return o;
}
half4 frag (v2f i) : SV_Target
{
return i.color;
}
ENDCG
}
}
}
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 3b849de517d871d46874414758a096f2
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
preprocessorOverride: 0
userData:
assetBundleName:
assetBundleVariant:
+219 -170
View File
@@ -1,195 +1,244 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using Speckle.Core.Api;
using UnityEngine;
using UnityEngine.UI;
using Text = UnityEngine.UI.Text;
namespace Speckle.ConnectorUnity
{
public class InteractionLogic : MonoBehaviour
{
private Receiver receiver;
public void InitReceiver(Stream stream, bool autoReceive)
[Obsolete]
public class InteractionLogic : MonoBehaviour
{
gameObject.name = $"receiver-{stream.id}-{Guid.NewGuid().ToString()}";
InitRemove();
private Receiver _receiver;
receiver = gameObject.AddComponent<Receiver>();
receiver.Stream = stream;
var btn = gameObject.transform.Find("Btn").GetComponentInChildren<Button>();
var streamText = gameObject.transform.Find("StreamText").GetComponentInChildren<Text>();
var statusText = gameObject.transform.Find("StatusText").GetComponentInChildren<Text>();
var branchesDropdown = gameObject.transform.Find("Dropdown").GetComponentInChildren<Dropdown>();
var receiveProgress = btn.GetComponentInChildren<Slider>();
receiveProgress.gameObject.SetActive(false); //hide
//populate branches
branchesDropdown.options.Clear();
foreach (var branch in receiver.Stream.branches.items)
{
branchesDropdown.options.Add(new Dropdown.OptionData(branch.name));
}
//trigger ui refresh, maybe there's a better method
branchesDropdown.value = -1;
branchesDropdown.value = 0;
branchesDropdown.onValueChanged.AddListener(index =>
{
if (index == -1)
return;
receiver.BranchName = receiver.Stream.branches.items[index].name;
});
receiver.Init(stream.id, autoReceive, true,
onDataReceivedAction: (go) =>
public void InitReceiver(Stream stream, bool autoReceive)
{
statusText.text = $"Received {go.name}";
MakeButtonsInteractable(true);
receiveProgress.value = 0;
receiveProgress.gameObject.SetActive(false);
gameObject.name = $"receiver-{stream.id}-{Guid.NewGuid().ToString()}";
InitRemove();
AddComponents(go);
},
onTotalChildrenCountKnown: (count) => { receiver.TotalChildrenCount = count; },
onProgressAction: (dict) =>
{
//Run on a dispatcher as GOs can only be retrieved on the main thread
Dispatcher.Instance().Enqueue(() =>
{
var val = dict.Values.Average() / receiver.TotalChildrenCount;
receiveProgress.gameObject.SetActive(true);
receiveProgress.value = (float) val;
});
});
_receiver = gameObject.AddComponent<Receiver>();
_receiver.Stream = stream;
var btn = gameObject.transform.Find("Btn").GetComponentInChildren<Button>();
var streamText = gameObject.transform.Find("StreamText").GetComponentInChildren<Text>();
var statusText = gameObject.transform.Find("StatusText").GetComponentInChildren<Text>();
var branchesDropdown = gameObject.transform
.Find("Dropdown")
.GetComponentInChildren<Dropdown>();
var receiveProgress = btn.GetComponentInChildren<Slider>();
receiveProgress.gameObject.SetActive(false); //hide
streamText.text = $"Stream: {stream.name}\nId: {stream.id} - Auto: {autoReceive}";
btn.onClick.AddListener(() =>
{
statusText.text = "Receiving...";
MakeButtonsInteractable(false);
receiver.Receive();
});
}
/// <summary>
/// Recursively adds custom components to all children of a GameObject
/// </summary>
/// <param name="go"></param>
private void AddComponents(GameObject go)
{
for (var i = 0; i < go.transform.childCount; i++)
{
var child = go.transform.GetChild(i);
if (child.childCount > 0)
{
AddComponents(child.gameObject);
}
child.gameObject.AddComponent<Selectable>();
//Add extra Components
//var rigidbody = child.gameObject.AddComponent<Rigidbody>();
//rigidbody.mass = 10;
}
}
public void InitSender(Stream stream)
{
gameObject.name = $"sender-{stream.id}-{Guid.NewGuid().ToString()}";
InitRemove();
var sender = gameObject.AddComponent<Sender>();
//sender.Stream = stream;
var btn = gameObject.transform.Find("Btn").GetComponentInChildren<Button>();
var streamText = gameObject.transform.Find("StreamText").GetComponentInChildren<Text>();
var statusText = gameObject.transform.Find("StatusText").GetComponentInChildren<Text>();
btn.GetComponentInChildren<Text>().text = "Send";
statusText.text = "Ready to send";
var sendProgress = btn.GetComponentInChildren<Slider>();
sendProgress.gameObject.SetActive(false); //hide
streamText.text = $"Stream: {stream.name}\nId: {stream.id}";
btn.onClick.AddListener(() =>
{
var objs = new List<GameObject>();
foreach (var index in SelectionManager.selectedObjects)
{
objs.Add(SelectionManager.selectables[index].gameObject);
}
if (!objs.Any())
{
statusText.text = $"No objects selected";
return;
}
MakeButtonsInteractable(false);
statusText.text = "Sending...";
sender.Send(stream.id, objs,
onProgressAction: (dict) =>
//populate branches
branchesDropdown.options.Clear();
List<Branch> branches = _receiver.Stream.branches.items;
branches.Reverse();
foreach (Branch branch in branches)
{
//Run on a dispatcher as GOs can only be retrieved on the main thread
Dispatcher.Instance().Enqueue(() =>
{
var val = dict.Values.Average() / objs.Count;
sendProgress.gameObject.SetActive(true);
sendProgress.value = (float) val;
});
},
onDataSentAction: (commitId) =>
branchesDropdown.options.Add(
new Dropdown.OptionData(branch.name.Replace(' ', '\u00A0'))
);
}
//trigger ui refresh, maybe there's a better method
branchesDropdown.value = -1;
branchesDropdown.value = 0;
branchesDropdown.onValueChanged.AddListener(index =>
{
Dispatcher.Instance().Enqueue(() =>
{
MakeButtonsInteractable(true);
statusText.text = $"Sent {commitId}";
sendProgress.gameObject.SetActive(false); //hide
});
if (index == -1)
return;
_receiver.BranchName = branches[index].name;
});
_receiver.Init(
stream.id,
autoReceive,
onDataReceivedAction: (go) =>
{
statusText.text = $"Received {go.name}";
MakeButtonsInteractable(true);
receiveProgress.value = 0;
receiveProgress.gameObject.SetActive(false);
AddComponents(go);
},
onTotalChildrenCountKnown: (count) =>
{
_receiver.TotalChildrenCount = count;
},
onProgressAction: (dict) =>
{
//Run on a dispatcher as GOs can only be retrieved on the main thread
Dispatcher
.Instance()
.Enqueue(() =>
{
var val = dict.Values.Average() / _receiver.TotalChildrenCount;
receiveProgress.gameObject.SetActive(true);
receiveProgress.value = (float)val;
});
}
);
streamText.text = $"Stream: {stream.name}\nId: {stream.id} - Auto: {autoReceive}";
btn.onClick.AddListener(() =>
{
statusText.text = "Receiving...";
MakeButtonsInteractable(false);
_receiver.Receive();
});
}
);
}
private void MakeButtonsInteractable(bool interactable)
{
var selectables = gameObject.transform.GetComponentsInChildren<UnityEngine.UI.Selectable>();
foreach (var selectable in selectables)
{
selectable.interactable = interactable;
}
}
private void InitRemove()
{
var close = gameObject.transform.Find("Close").GetComponentInChildren<Button>();
close.onClick.AddListener(() =>
{
//remove received geometry
if (receiver != null)
/// <summary>
/// Recursively adds custom components to all children of a GameObject
/// </summary>
/// <param name="go"></param>
private void AddComponents(GameObject go)
{
Destroy(receiver.ReceivedData);
for (var i = 0; i < go.transform.childCount; i++)
{
var child = go.transform.GetChild(i);
if (child.childCount > 0)
{
AddComponents(child.gameObject);
}
child.gameObject.AddComponent<Selectable>();
//Add extra Components
//var rigidbody = child.gameObject.AddComponent<Rigidbody>();
//rigidbody.mass = 10;
}
}
//update ui
GameObject.Find("_SpeckleExamples").GetComponent<SpeckleExamples>().RemoveStreamPrefab(gameObject);
public void InitSender(Stream stream)
{
gameObject.name = $"sender-{stream.id}-{Guid.NewGuid().ToString()}";
InitRemove();
//kill it
Destroy(gameObject);
});
var sender = gameObject.AddComponent<Sender>();
var btn = gameObject.transform.Find("Btn").GetComponentInChildren<Button>();
var streamText = gameObject.transform.Find("StreamText").GetComponentInChildren<Text>();
var statusText = gameObject.transform.Find("StatusText").GetComponentInChildren<Text>();
btn.GetComponentInChildren<Text>().text = "Send";
statusText.text = "Ready to send";
var sendProgress = btn.GetComponentInChildren<Slider>();
sendProgress.gameObject.SetActive(false); //hide
streamText.text = $"Stream: {stream.name}\nId: {stream.id}";
btn.onClick.AddListener(() =>
{
var objs = SelectionManager.selectedObjects
.Select(s => s.gameObject)
.ToImmutableHashSet();
if (!objs.Any())
{
statusText.text = $"No objects selected";
return;
}
MakeButtonsInteractable(false);
statusText.text = "Sending...";
try
{
sender.Send(
stream.id,
objs,
onProgressAction: (dict) =>
{
//Run on a dispatcher as GOs can only be retrieved on the main thread
Dispatcher
.Instance()
.Enqueue(() =>
{
var val = dict.Values.Average() / objs.Count;
sendProgress.gameObject.SetActive(true);
sendProgress.value = (float)val;
});
},
onDataSentAction: (objectId) =>
{
Debug.Log($"Send operation completed, object id: {objectId}", this);
Dispatcher
.Instance()
.Enqueue(() =>
{
MakeButtonsInteractable(true);
statusText.text = $"Sent {objectId}";
sendProgress.gameObject.SetActive(false); //hide
});
},
onErrorAction: (message, e) =>
{
Debug.LogError("Send operation Failed!", this);
Dispatcher
.Instance()
.Enqueue(() =>
{
MakeButtonsInteractable(true);
statusText.text = $"Error {message}";
sendProgress.gameObject.SetActive(false); //hide
Debug.LogError(e, this);
});
}
);
}
catch (Exception e)
{
Dispatcher
.Instance()
.Enqueue(() =>
{
MakeButtonsInteractable(true);
statusText.text = $"Error {e.Message}";
sendProgress.gameObject.SetActive(false); //hide
Debug.LogError(e, this);
});
}
});
}
private void MakeButtonsInteractable(bool interactable)
{
var selectables =
gameObject.transform.GetComponentsInChildren<UnityEngine.UI.Selectable>();
foreach (var selectable in selectables)
{
selectable.interactable = interactable;
}
}
private void InitRemove()
{
var close = gameObject.transform.Find("Close").GetComponentInChildren<Button>();
close.onClick.AddListener(() =>
{
//remove received geometry
if (_receiver != null)
{
Destroy(_receiver.ReceivedData);
}
//update ui
GameObject
.Find("_SpeckleExamples")
.GetComponent<SpeckleExamples>()
.RemoveStreamPrefab(gameObject);
//kill it
Destroy(gameObject);
});
}
}
}
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9e8bc8cda58ea6c41a8d9c89bf68f726
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 978be06c8e5f29d42910ca9985d0e9ab
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 98d0614354f7fc04cb4b030f4c54810f
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 5b42d273c4ee09a43b5dff30f6e05988
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e50a8f3b511f13748b134a3a5e000b0f
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f823114029cf4814c962a9b71f81705d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -1,29 +0,0 @@
using Objects.BuiltElements;
using Objects.Geometry;
using UnityEngine;
namespace Objects.Converter.Unity
{
public partial class ConverterUnity
{
/// <summary>
/// Converts a Speckle View3D to a GameObject
/// </summary>
/// <param name="point"></param>
/// <returns></returns>
public GameObject View3DToNative(View3D speckleView)
{
var go = new GameObject(speckleView.name);
var camera = go.AddComponent<Camera>();
camera.transform.position = VectorByCoordinates(speckleView.origin.x, speckleView.origin.y, speckleView.origin.z,
speckleView.origin.units);
camera.transform.forward = VectorByCoordinates(speckleView.forwardDirection.x, speckleView.forwardDirection.y,
speckleView.forwardDirection.z, speckleView.forwardDirection.units);
camera.transform.up = VectorByCoordinates(speckleView.upDirection.x, speckleView.upDirection.y,
speckleView.upDirection.z, speckleView.upDirection.units);
AttachSpeckleProperties(go, speckleView.GetMembers());
return go;
}
}
}
@@ -1,390 +0,0 @@
using Objects.Geometry;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Objects.Other;
using Speckle.ConnectorUnity;
using Speckle.Core.Models;
using UnityEngine;
using Mesh = Objects.Geometry.Mesh;
namespace Objects.Converter.Unity
{
public partial class ConverterUnity
{
#region helper methods
/// <summary>
///
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="z"></param>
/// <returns></returns>
public Vector3 VectorByCoordinates(double x, double y, double z, string units)
{
// switch y and z
return new Vector3((float) ScaleToNative(x, units), (float) ScaleToNative(z, units),
(float) ScaleToNative(y, units));
}
public Vector3 VectorFromPoint(Point p)
{
// switch y and z
return new Vector3((float) ScaleToNative(p.x, p.units), (float) ScaleToNative(p.z, p.units),
(float) ScaleToNative(p.y, p.units));
}
/// <summary>
///
/// </summary>
/// <param name="ptValues"></param>
/// <returns></returns>
// public Vector3 ArrayToPoint(double[] ptValues, string units)
// {
// double x = ptValues[0];
// double y = ptValues[1];
// double z = ptValues[2];
//
// return PointByCoordinates(x, y, z, units);
// }
/// <summary>
///
/// </summary>
/// <param name="arr"></param>
/// <returns></returns>
public Vector3[] ArrayToPoints(IEnumerable<double> arr, string units)
{
if (arr.Count() % 3 != 0) throw new Exception("Array malformed: length%3 != 0.");
Vector3[] points = new Vector3[arr.Count() / 3];
var asArray = arr.ToArray();
for (int i = 2, k = 0; i < arr.Count(); i += 3)
points[k++] = VectorByCoordinates(asArray[i - 2], asArray[i - 1], asArray[i], units);
return points;
}
#endregion
#region ToSpeckle
//TODO: more of these
/// <summary>
///
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
public Point PointToSpeckle(Vector3 p)
{
//switch y and z
return new Point(p.x, p.z, p.y);
}
/// <summary>
/// Converts a Speckle mesh to a GameObject with a mesh renderer
/// </summary>
/// <param name="speckleMesh"></param>
/// <returns></returns>
public Mesh MeshToSpeckle(GameObject go)
{
//TODO: support multiple filters?
var filter = go.GetComponent<MeshFilter>();
if (filter == null)
{
return null;
}
//convert triangle array into speckleMesh faces
List<int> faces = new List<int>();
int i = 0;
//store them here, makes it like 1000000x faster?
var triangles = filter.mesh.triangles;
while (i < triangles.Length)
{
faces.Add(0);
faces.Add(triangles[i + 0]);
faces.Add(triangles[i + 2]);
faces.Add(triangles[i + 1]);
i += 3;
}
var mesh = new Mesh();
// get the speckle data from the go here
// so that if the go comes from speckle, typed props will get overridden below
AttachUnityProperties(mesh, go);
mesh.units = ModelUnits;
var vertices = filter.mesh.vertices;
foreach (var vertex in vertices)
{
var p = go.transform.TransformPoint(vertex);
var sp = PointToSpeckle(p);
mesh.vertices.Add(sp.x);
mesh.vertices.Add(sp.y);
mesh.vertices.Add(sp.z);
}
mesh.faces = faces;
return mesh;
}
#endregion
#region ToNative
private GameObject NewPointBasedGameObject(Vector3[] points, string name)
{
if (points.Length == 0) return null;
float pointDiameter = 1; //TODO: figure out how best to change this?
var go = new GameObject();
go.name = name;
var lineRenderer = go.AddComponent<LineRenderer>();
lineRenderer.positionCount = points.Length;
lineRenderer.SetPositions(points);
lineRenderer.numCornerVertices = lineRenderer.numCapVertices = 8;
lineRenderer.startWidth = lineRenderer.endWidth = pointDiameter;
return go;
}
/// <summary>
/// Converts a Speckle point to a GameObject with a line renderer
/// </summary>
/// <param name="point"></param>
/// <returns></returns>
public GameObject PointToNative(Point point)
{
Vector3 newPt = VectorByCoordinates(point.x, point.y, point.z, point.units);
var go = NewPointBasedGameObject(new Vector3[2] {newPt, newPt}, point.speckle_type);
return go;
}
/// <summary>
/// Converts a Speckle line to a GameObject with a line renderer
/// </summary>
/// <param name="line"></param>
/// <returns></returns>
public GameObject LineToNative(Line line)
{
var points = new List<Vector3> {VectorFromPoint(line.start), VectorFromPoint(line.end)};
var go = NewPointBasedGameObject(points.ToArray(), line.speckle_type);
return go;
}
/// <summary>
/// Converts a Speckle polyline to a GameObject with a line renderer
/// </summary>
/// <param name="polyline"></param>
/// <returns></returns>
public GameObject PolylineToNative(Polyline polyline)
{
var points = polyline.points.Select(x => VectorFromPoint(x));
var go = NewPointBasedGameObject(points.ToArray(), polyline.speckle_type);
return go;
}
/// <summary>
/// Converts a Speckle curve to a GameObject with a line renderer
/// </summary>
/// <param name="curve"></param>
/// <returns></returns>
public GameObject CurveToNative(Curve curve)
{
var points = ArrayToPoints(curve.points, curve.units);
var go = NewPointBasedGameObject(points.ToArray(), curve.speckle_type);
return go;
}
public GameObject MeshToNative(Base speckleMeshObject)
{
if (!(speckleMeshObject["displayMesh"] is Mesh))
return null;
return MeshToNative(speckleMeshObject["displayMesh"] as Mesh,
speckleMeshObject["renderMaterial"] as RenderMaterial, speckleMeshObject.GetMembers());
}
/// <summary>
/// Converts a Speckle mesh to a GameObject with a mesh renderer
/// </summary>
/// <param name="speckleMesh">Mesh to convert</param>
/// <param name="renderMaterial">If provided will override the renderMaterial on the mesh itself</param>
/// <param name="properties">If provided will override the properties on the mesh itself</param>
/// <returns></returns>
public GameObject MeshToNative(Mesh speckleMesh, RenderMaterial renderMaterial = null,
Dictionary<string, object> properties = null)
{
if (speckleMesh.vertices.Count == 0 || speckleMesh.faces.Count == 0)
{
return null;
}
var recentreMeshTransforms = true; //TODO: figure out how best to change this?
var verts = ArrayToPoints(speckleMesh.vertices, speckleMesh.units).ToList();
//convert speckleMesh.faces into triangle array
List<int> tris = new List<int>();
int i = 0;
while (i < speckleMesh.faces.Count)
{
if (speckleMesh.faces[i] == 0)
{
//Triangles
tris.Add(speckleMesh.faces[i + 1]);
tris.Add(speckleMesh.faces[i + 3]);
tris.Add(speckleMesh.faces[i + 2]);
i += 4;
}
else
{
//Quads to triangles
tris.Add(speckleMesh.faces[i + 1]);
tris.Add(speckleMesh.faces[i + 3]);
tris.Add(speckleMesh.faces[i + 2]);
tris.Add(speckleMesh.faces[i + 1]);
tris.Add(speckleMesh.faces[i + 4]);
tris.Add(speckleMesh.faces[i + 3]);
i += 5;
}
}
var go = new GameObject();
go.name = speckleMesh.speckle_type;
var mesh = go.AddComponent<MeshFilter>().mesh;
var meshRenderer = go.AddComponent<MeshRenderer>();
var speckleMaterial = renderMaterial ?? (RenderMaterial)speckleMesh["renderMaterial"];
meshRenderer.material = GetMaterial(speckleMaterial);
if (verts.Count >= 65535)
mesh.indexFormat = UnityEngine.Rendering.IndexFormat.UInt32;
// center transform pivot according to the bounds of the model
if (recentreMeshTransforms)
{
Bounds meshBounds = new Bounds();
meshBounds.center = verts[0];
verts.ForEach(x => meshBounds.Encapsulate(x));
go.transform.position = meshBounds.center;
// offset mesh vertices
for (int l = 0; l < verts.Count; l++)
{
verts[l] -= meshBounds.center;
}
}
// assign mesh properties
mesh.vertices = verts.ToArray();
mesh.triangles = tris.ToArray();
mesh.Optimize();
mesh.RecalculateNormals();
mesh.RecalculateTangents();
//generate uvs doesn't work as intended. Leaving out for now
//GenerateUVs (ref mesh);
//Add mesh collider
MeshCollider mc = go.AddComponent<MeshCollider>();
mc.sharedMesh = mesh;
//mc.convex = true;
//attach properties on this very mesh
//means the mesh originated in Rhino or similar
if (properties == null)
{
var meshprops = typeof(Mesh).GetProperties(BindingFlags.Instance | BindingFlags.Public).Select(x => x.Name)
.ToList();
properties = speckleMesh.GetMembers()
.Where(x => !meshprops.Contains(x.Key))
.ToDictionary(x => x.Key, x => x.Value);
}
AttachSpeckleProperties(go, properties);
return go;
}
#endregion
private Material GetMaterial(RenderMaterial renderMaterial)
{
//todo support more complex materials
var shader = Shader.Find("Standard");
Material mat = new Material(shader);
//if a renderMaterial is passed use that, otherwise try get it from the mesh itself
if (renderMaterial != null)
{
// 1. match material by name, if any
var matByName = ContextObjects.FirstOrDefault(x => ((Material)x.NativeObject).name == renderMaterial.name);
if (matByName!=null)
{
return matByName.NativeObject as Material;
}
// 2. re-create material by setting diffuse color and transparency on standard shaders
if (renderMaterial.opacity < 1)
{
shader = Shader.Find("Transparent/Diffuse");
mat = new Material(shader);
}
var c = renderMaterial.diffuse.ToUnityColor();
mat.color = new Color(c.r, c.g, c.b, Convert.ToSingle(renderMaterial.opacity));
return mat;
}
// 3. if not renderMaterial was passed, the default shader will be used
return mat;
}
private void AttachSpeckleProperties(GameObject go, Dictionary<string, object> properties)
{
var sd = go.AddComponent<SpeckleProperties>();
sd.Data = properties;
}
private void AttachUnityProperties(Base @base, GameObject go)
{
var sd = go.GetComponent<SpeckleProperties>();
if (sd == null || sd.Data == null)
return;
foreach (var key in sd.Data.Keys)
{
@base[key] = sd.Data[key];
}
}
}
}
@@ -1,23 +0,0 @@
using Objects.Geometry;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using Mesh = Objects.Geometry.Mesh;
namespace Objects.Converter.Unity
{
public partial class ConverterUnity
{
public string ModelUnits = Speckle.Core.Kits.Units.Meters; //the default Unity units are meters
private double ScaleToNative(double value, string units)
{
var f = Speckle.Core.Kits.Units.GetConversionFactor(units, ModelUnits);
return value * f;
}
}
}
-126
View File
@@ -1,126 +0,0 @@
using Objects.Geometry;
using Speckle.Core.Kits;
using Speckle.Core.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Objects.BuiltElements;
using UnityEngine;
using Mesh = Objects.Geometry.Mesh;
namespace Objects.Converter.Unity
{
public partial class ConverterUnity : ISpeckleConverter
{
#region implemented methods
public string Description => "Default Speckle Kit for Unity";
public string Name => nameof(ConverterUnity);
public string Author => "Speckle";
public string WebsiteOrEmail => "https://speckle.systems";
public IEnumerable<string> GetServicedApplications() => new string[] {Applications.Other}; //TODO: add unity
public HashSet<Exception> ConversionErrors { get; private set; } = new HashSet<Exception>();
public List<ApplicationPlaceholderObject> ContextObjects { get; set; } = new List<ApplicationPlaceholderObject>();
public void SetContextDocument(object doc) => throw new NotImplementedException();
public void SetContextObjects(List<ApplicationPlaceholderObject> objects) => ContextObjects = objects;
public void SetPreviousContextObjects(List<ApplicationPlaceholderObject> objects) =>
throw new NotImplementedException();
public Base ConvertToSpeckle(object @object)
{
switch (@object)
{
case GameObject o:
if (o.GetComponent<MeshFilter>() != null)
return MeshToSpeckle(o);
throw new NotSupportedException();
default:
throw new NotSupportedException();
}
}
public object ConvertToNative(Base @object)
{
switch (@object)
{
// case Point o:
// return PointToNative(o);
// case Line o:
// return LineToNative(o);
// case Polyline o:
// return PolylineToNative(o);
// case Curve o:
// return CurveToNative(o);
// case View3D o:
// return View3DToNative(o);
case Mesh o:
return MeshToNative(o);
//Built elements with a mesh representation implement this interface
case IDisplayMesh o:
return MeshToNative((Base) o);
default:
//capture any other object that might have a mesh representation
if (@object["displayMesh"] is Mesh)
return MeshToNative(@object["displayMesh"] as Mesh);
throw new NotSupportedException();
}
}
public List<Base> ConvertToSpeckle(List<object> objects)
{
return objects.Select(x => ConvertToSpeckle(x)).ToList();
}
public List<object> ConvertToNative(List<Base> objects)
{
return objects.Select(x => ConvertToNative(x)).ToList();
;
}
public bool CanConvertToSpeckle(object @object)
{
switch (@object)
{
case GameObject o:
return o.GetComponent<MeshFilter>() != null;
default:
return false;
}
}
public bool CanConvertToNative(Base @object)
{
switch (@object)
{
// case Point _:
// return true;
// case Line _:
// return true;
// case Polyline _:
// return true;
// case Curve _:
// return true;
// case View3D _:
// return true;
// case View2D _:
// return false;
case IDisplayMesh _:
return true;
case Mesh _:
return true;
default:
return @object["displayMesh"] is Mesh;
}
}
#endregion implemented methods
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,33 +0,0 @@
fileFormatVersion: 2
guid: 17512a3c0f40afa4c8dfcc7e01f5d966
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
Binary file not shown.
@@ -1,33 +0,0 @@
fileFormatVersion: 2
guid: 1cf9bfa3fa391d44fbad15257fcf8188
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
Binary file not shown.
@@ -1,33 +0,0 @@
fileFormatVersion: 2
guid: e04acff695d6dfc4c8172d263c148366
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
@@ -1,33 +0,0 @@
fileFormatVersion: 2
guid: 95c269842f6915a4cb61a32d2e4fa9e8
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
@@ -1,455 +0,0 @@
{
"runtimeTarget": {
"name": ".NETStandard,Version=v2.0/",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETStandard,Version=v2.0": {},
".NETStandard,Version=v2.0/": {
"SpeckleCore2/2.1.0": {
"dependencies": {
"GraphQL.Client": "3.2.2",
"Microsoft.CSharp": "4.7.0",
"NETStandard.Library": "2.0.3",
"Piwik.Tracker": "3.0.0",
"Sentry": "3.2.0",
"Speckle.Newtonsoft.Json": "12.0.3.1",
"System.Data.SQLite.Core": "1.0.113.7"
},
"runtime": {
"SpeckleCore2.dll": {}
}
},
"GraphQL.Client/3.2.2": {
"dependencies": {
"GraphQL.Client.Abstractions": "3.2.2",
"GraphQL.Client.Abstractions.Websocket": "3.2.2"
},
"runtime": {
"lib/netstandard2.0/GraphQL.Client.dll": {
"assemblyVersion": "3.2.2.0",
"fileVersion": "3.2.2.0"
}
}
},
"GraphQL.Client.Abstractions/3.2.2": {
"dependencies": {
"GraphQL.Primitives": "3.2.2",
"System.Reactive": "4.3.2"
},
"runtime": {
"lib/netstandard2.0/GraphQL.Client.Abstractions.dll": {
"assemblyVersion": "3.2.2.0",
"fileVersion": "3.2.2.0"
}
}
},
"GraphQL.Client.Abstractions.Websocket/3.2.2": {
"dependencies": {
"GraphQL.Client.Abstractions": "3.2.2"
},
"runtime": {
"lib/netstandard2.0/GraphQL.Client.Abstractions.Websocket.dll": {
"assemblyVersion": "3.2.2.0",
"fileVersion": "3.2.2.0"
}
}
},
"GraphQL.Primitives/3.2.2": {
"runtime": {
"lib/netstandard2.0/GraphQL.Primitives.dll": {
"assemblyVersion": "3.2.2.0",
"fileVersion": "3.2.2.0"
}
}
},
"Microsoft.Bcl.AsyncInterfaces/5.0.0": {
"dependencies": {
"System.Threading.Tasks.Extensions": "4.5.4"
},
"runtime": {
"lib/netstandard2.0/Microsoft.Bcl.AsyncInterfaces.dll": {
"assemblyVersion": "5.0.0.0",
"fileVersion": "5.0.20.51904"
}
}
},
"Microsoft.CSharp/4.7.0": {
"runtime": {
"lib/netstandard2.0/Microsoft.CSharp.dll": {
"assemblyVersion": "4.0.5.0",
"fileVersion": "4.700.19.56404"
}
}
},
"Microsoft.NETCore.Platforms/1.1.0": {},
"Microsoft.NETCore.Targets/1.1.0": {},
"NETStandard.Library/2.0.3": {
"dependencies": {
"Microsoft.NETCore.Platforms": "1.1.0"
}
},
"Piwik.Tracker/3.0.0": {
"runtime": {
"lib/net40/Piwik.Tracker.dll": {
"assemblyVersion": "3.0.0.0",
"fileVersion": "3.0.0.0"
}
}
},
"Sentry/3.2.0": {
"dependencies": {
"Microsoft.Bcl.AsyncInterfaces": "5.0.0",
"System.Buffers": "4.5.1",
"System.Reflection.Metadata": "5.0.0",
"System.Text.Json": "5.0.0",
"System.Threading.Tasks.Extensions": "4.5.4"
},
"runtime": {
"lib/netstandard2.0/Sentry.dll": {
"assemblyVersion": "3.2.0.0",
"fileVersion": "3.2.0.0"
}
}
},
"Speckle.Newtonsoft.Json/12.0.3.1": {
"runtime": {
"lib/netstandard2.0/Speckle.Newtonsoft.Json.dll": {
"assemblyVersion": "12.0.3.0",
"fileVersion": "11.0.1.0"
}
}
},
"Stub.System.Data.SQLite.Core.NetStandard/1.0.113.2": {
"runtime": {
"lib/netstandard2.0/System.Data.SQLite.dll": {
"assemblyVersion": "1.0.113.0",
"fileVersion": "1.0.113.0"
}
}
},
"System.Buffers/4.5.1": {
"runtime": {
"lib/netstandard2.0/System.Buffers.dll": {
"assemblyVersion": "4.0.3.0",
"fileVersion": "4.6.28619.1"
}
}
},
"System.Collections.Immutable/5.0.0": {
"dependencies": {
"System.Memory": "4.5.4"
},
"runtime": {
"lib/netstandard2.0/System.Collections.Immutable.dll": {
"assemblyVersion": "5.0.0.0",
"fileVersion": "5.0.20.51904"
}
}
},
"System.Data.SQLite.Core/1.0.113.7": {
"dependencies": {
"Stub.System.Data.SQLite.Core.NetStandard": "1.0.113.2"
}
},
"System.Memory/4.5.4": {
"dependencies": {
"System.Buffers": "4.5.1",
"System.Numerics.Vectors": "4.5.0",
"System.Runtime.CompilerServices.Unsafe": "5.0.0"
},
"runtime": {
"lib/netstandard2.0/System.Memory.dll": {
"assemblyVersion": "4.0.1.1",
"fileVersion": "4.6.28619.1"
}
}
},
"System.Numerics.Vectors/4.5.0": {
"runtime": {
"lib/netstandard2.0/System.Numerics.Vectors.dll": {
"assemblyVersion": "4.1.4.0",
"fileVersion": "4.6.26515.6"
}
}
},
"System.Reactive/4.3.2": {
"dependencies": {
"System.Runtime.InteropServices.WindowsRuntime": "4.3.0",
"System.Threading.Tasks.Extensions": "4.5.4"
},
"runtime": {
"lib/netstandard2.0/System.Reactive.dll": {
"assemblyVersion": "4.3.0.0",
"fileVersion": "4.3.2.55399"
}
}
},
"System.Reflection.Metadata/5.0.0": {
"dependencies": {
"System.Collections.Immutable": "5.0.0"
},
"runtime": {
"lib/netstandard2.0/System.Reflection.Metadata.dll": {
"assemblyVersion": "5.0.0.0",
"fileVersion": "5.0.20.51904"
}
}
},
"System.Runtime/4.3.0": {
"dependencies": {
"Microsoft.NETCore.Platforms": "1.1.0",
"Microsoft.NETCore.Targets": "1.1.0"
}
},
"System.Runtime.CompilerServices.Unsafe/5.0.0": {
"runtime": {
"lib/netstandard2.0/System.Runtime.CompilerServices.Unsafe.dll": {
"assemblyVersion": "5.0.0.0",
"fileVersion": "5.0.20.51904"
}
}
},
"System.Runtime.InteropServices.WindowsRuntime/4.3.0": {
"dependencies": {
"System.Runtime": "4.3.0"
},
"runtime": {
"lib/netstandard1.3/System.Runtime.InteropServices.WindowsRuntime.dll": {
"assemblyVersion": "4.0.2.0",
"fileVersion": "4.6.24705.1"
}
}
},
"System.Text.Encodings.Web/5.0.0": {
"dependencies": {
"System.Memory": "4.5.4"
},
"runtime": {
"lib/netstandard2.0/System.Text.Encodings.Web.dll": {
"assemblyVersion": "5.0.0.0",
"fileVersion": "5.0.20.51904"
}
}
},
"System.Text.Json/5.0.0": {
"dependencies": {
"Microsoft.Bcl.AsyncInterfaces": "5.0.0",
"System.Buffers": "4.5.1",
"System.Memory": "4.5.4",
"System.Numerics.Vectors": "4.5.0",
"System.Runtime.CompilerServices.Unsafe": "5.0.0",
"System.Text.Encodings.Web": "5.0.0",
"System.Threading.Tasks.Extensions": "4.5.4"
},
"runtime": {
"lib/netstandard2.0/System.Text.Json.dll": {
"assemblyVersion": "5.0.0.0",
"fileVersion": "5.0.20.51904"
}
}
},
"System.Threading.Tasks.Extensions/4.5.4": {
"dependencies": {
"System.Runtime.CompilerServices.Unsafe": "5.0.0"
},
"runtime": {
"lib/netstandard2.0/System.Threading.Tasks.Extensions.dll": {
"assemblyVersion": "4.2.0.1",
"fileVersion": "4.6.28619.1"
}
}
}
}
},
"libraries": {
"SpeckleCore2/2.1.0": {
"type": "project",
"serviceable": false,
"sha512": ""
},
"GraphQL.Client/3.2.2": {
"type": "package",
"serviceable": true,
"sha512": "sha512-CgopiGmBLs95hQrxL3FG8EOJlKiF4CU9fLdELRIgk1GagaN9mxluyErLzZfT7a6Z/26vxHYCDfnL/UZgmjxOKw==",
"path": "graphql.client/3.2.2",
"hashPath": "graphql.client.3.2.2.nupkg.sha512"
},
"GraphQL.Client.Abstractions/3.2.2": {
"type": "package",
"serviceable": true,
"sha512": "sha512-fWwx/5K15BGFi6p7+kZ32fYlOPv50Sb6ta7XpAUeh9vfYjZWU+BxL9ydKRgBrj2owpx6MSV0mfrSPalMO/LeAg==",
"path": "graphql.client.abstractions/3.2.2",
"hashPath": "graphql.client.abstractions.3.2.2.nupkg.sha512"
},
"GraphQL.Client.Abstractions.Websocket/3.2.2": {
"type": "package",
"serviceable": true,
"sha512": "sha512-YdTEpy0WohAmvsu6tdHkSkh9CaWHz5NIcrZtU0O4eCD58eG0A8O6o72FoK75uxArDg8YyqxlJ8AA6LoNJIxMNg==",
"path": "graphql.client.abstractions.websocket/3.2.2",
"hashPath": "graphql.client.abstractions.websocket.3.2.2.nupkg.sha512"
},
"GraphQL.Primitives/3.2.2": {
"type": "package",
"serviceable": true,
"sha512": "sha512-JWurQzJ39/agJqrLIcRgnTtzCgn3zlGmrrYH4qznHUEq49QIMM+btTGbsE9pXmVKIk4Kl0SrDag+Y9ev8zBoXw==",
"path": "graphql.primitives/3.2.2",
"hashPath": "graphql.primitives.3.2.2.nupkg.sha512"
},
"Microsoft.Bcl.AsyncInterfaces/5.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-W8DPQjkMScOMTtJbPwmPyj9c3zYSFGawDW3jwlBOOsnY+EzZFLgNQ/UMkK35JmkNOVPdCyPr2Tw7Vv9N+KA3ZQ==",
"path": "microsoft.bcl.asyncinterfaces/5.0.0",
"hashPath": "microsoft.bcl.asyncinterfaces.5.0.0.nupkg.sha512"
},
"Microsoft.CSharp/4.7.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-pTj+D3uJWyN3My70i2Hqo+OXixq3Os2D1nJ2x92FFo6sk8fYS1m1WLNTs0Dc1uPaViH0YvEEwvzddQ7y4rhXmA==",
"path": "microsoft.csharp/4.7.0",
"hashPath": "microsoft.csharp.4.7.0.nupkg.sha512"
},
"Microsoft.NETCore.Platforms/1.1.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-kz0PEW2lhqygehI/d6XsPCQzD7ff7gUJaVGPVETX611eadGsA3A877GdSlU0LRVMCTH/+P3o2iDTak+S08V2+A==",
"path": "microsoft.netcore.platforms/1.1.0",
"hashPath": "microsoft.netcore.platforms.1.1.0.nupkg.sha512"
},
"Microsoft.NETCore.Targets/1.1.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-aOZA3BWfz9RXjpzt0sRJJMjAscAUm3Hoa4UWAfceV9UTYxgwZ1lZt5nO2myFf+/jetYQo4uTP7zS8sJY67BBxg==",
"path": "microsoft.netcore.targets/1.1.0",
"hashPath": "microsoft.netcore.targets.1.1.0.nupkg.sha512"
},
"NETStandard.Library/2.0.3": {
"type": "package",
"serviceable": true,
"sha512": "sha512-st47PosZSHrjECdjeIzZQbzivYBJFv6P2nv4cj2ypdI204DO+vZ7l5raGMiX4eXMJ53RfOIg+/s4DHVZ54Nu2A==",
"path": "netstandard.library/2.0.3",
"hashPath": "netstandard.library.2.0.3.nupkg.sha512"
},
"Piwik.Tracker/3.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-91mJZeyxFUhA9t2oFTVw+W7p9t7+oZ1KAPfvGUvAkX2m/74xDlPsp8qfs4UIW9XE+TrU7PCBn43QPh0rP9jeOA==",
"path": "piwik.tracker/3.0.0",
"hashPath": "piwik.tracker.3.0.0.nupkg.sha512"
},
"Sentry/3.2.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-nCKeGuy8JCofqM44+ThKXnjKU7A00mQCHrPbChEh50l+WcSJW1bV+pQDblWhQis37+cP3sV6q0QApDEK4Qy4Zw==",
"path": "sentry/3.2.0",
"hashPath": "sentry.3.2.0.nupkg.sha512"
},
"Speckle.Newtonsoft.Json/12.0.3.1": {
"type": "package",
"serviceable": true,
"sha512": "sha512-yM+DdKzI++HY4FYbloGcPGQ0yrfSv5/a5Rd+iYuzj47ATRtb2M5oCEVcxM4Xum5EDq0BMwkIY/cw/DMlRrZFDA==",
"path": "speckle.newtonsoft.json/12.0.3.1",
"hashPath": "speckle.newtonsoft.json.12.0.3.1.nupkg.sha512"
},
"Stub.System.Data.SQLite.Core.NetStandard/1.0.113.2": {
"type": "package",
"serviceable": true,
"sha512": "sha512-yGIM9xFyPHl79HluNTSQarvAOIJ68pmzmlMayVN6Nivu/7TiaHt7WqptolvwmuKdAXei8OzENh9RNdh7d6evjQ==",
"path": "stub.system.data.sqlite.core.netstandard/1.0.113.2",
"hashPath": "stub.system.data.sqlite.core.netstandard.1.0.113.2.nupkg.sha512"
},
"System.Buffers/4.5.1": {
"type": "package",
"serviceable": true,
"sha512": "sha512-Rw7ijyl1qqRS0YQD/WycNst8hUUMgrMH4FCn1nNm27M4VxchZ1js3fVjQaANHO5f3sN4isvP4a+Met9Y4YomAg==",
"path": "system.buffers/4.5.1",
"hashPath": "system.buffers.4.5.1.nupkg.sha512"
},
"System.Collections.Immutable/5.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-FXkLXiK0sVVewcso0imKQoOxjoPAj42R8HtjjbSjVPAzwDfzoyoznWxgA3c38LDbN9SJux1xXoXYAhz98j7r2g==",
"path": "system.collections.immutable/5.0.0",
"hashPath": "system.collections.immutable.5.0.0.nupkg.sha512"
},
"System.Data.SQLite.Core/1.0.113.7": {
"type": "package",
"serviceable": true,
"sha512": "sha512-2DKMIxfZpIVzdMfx1dj9qvTm+0m0Mx6sN6CZXMQDNytU7Sk/JKo0Ox6mvHAicfHrQgqZbUZMzMMtLXD0kwmFfg==",
"path": "system.data.sqlite.core/1.0.113.7",
"hashPath": "system.data.sqlite.core.1.0.113.7.nupkg.sha512"
},
"System.Memory/4.5.4": {
"type": "package",
"serviceable": true,
"sha512": "sha512-1MbJTHS1lZ4bS4FmsJjnuGJOu88ZzTT2rLvrhW7Ygic+pC0NWA+3hgAen0HRdsocuQXCkUTdFn9yHJJhsijDXw==",
"path": "system.memory/4.5.4",
"hashPath": "system.memory.4.5.4.nupkg.sha512"
},
"System.Numerics.Vectors/4.5.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-QQTlPTl06J/iiDbJCiepZ4H//BVraReU4O4EoRw1U02H5TLUIT7xn3GnDp9AXPSlJUDyFs4uWjWafNX6WrAojQ==",
"path": "system.numerics.vectors/4.5.0",
"hashPath": "system.numerics.vectors.4.5.0.nupkg.sha512"
},
"System.Reactive/4.3.2": {
"type": "package",
"serviceable": true,
"sha512": "sha512-WhGkScPWxw2pp7UwRW8M1OvYZ3WUDPC2wJ0aiuaB4KRD3bt4wLkgHgYnOUu87WRhsurvv5LN0E63iWOEza2o8g==",
"path": "system.reactive/4.3.2",
"hashPath": "system.reactive.4.3.2.nupkg.sha512"
},
"System.Reflection.Metadata/5.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-5NecZgXktdGg34rh1OenY1rFNDCI8xSjFr+Z4OU4cU06AQHUdRnIIEeWENu3Wl4YowbzkymAIMvi3WyK9U53pQ==",
"path": "system.reflection.metadata/5.0.0",
"hashPath": "system.reflection.metadata.5.0.0.nupkg.sha512"
},
"System.Runtime/4.3.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-JufQi0vPQ0xGnAczR13AUFglDyVYt4Kqnz1AZaiKZ5+GICq0/1MH/mO/eAJHt/mHW1zjKBJd7kV26SrxddAhiw==",
"path": "system.runtime/4.3.0",
"hashPath": "system.runtime.4.3.0.nupkg.sha512"
},
"System.Runtime.CompilerServices.Unsafe/5.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-ZD9TMpsmYJLrxbbmdvhwt9YEgG5WntEnZ/d1eH8JBX9LBp+Ju8BSBhUGbZMNVHHomWo2KVImJhTDl2hIgw/6MA==",
"path": "system.runtime.compilerservices.unsafe/5.0.0",
"hashPath": "system.runtime.compilerservices.unsafe.5.0.0.nupkg.sha512"
},
"System.Runtime.InteropServices.WindowsRuntime/4.3.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-J4GUi3xZQLUBasNwZnjrffN8i5wpHrBtZoLG+OhRyGo/+YunMRWWtwoMDlUAIdmX0uRfpHIBDSV6zyr3yf00TA==",
"path": "system.runtime.interopservices.windowsruntime/4.3.0",
"hashPath": "system.runtime.interopservices.windowsruntime.4.3.0.nupkg.sha512"
},
"System.Text.Encodings.Web/5.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-EEslUvHKll1ftizbn20mX3Ix/l4Ygk/bdJ2LY6/X6FlGaP0RIhKMo9nS6JIGnKKT6KBP2PGj6JC3B9/ZF6ErqQ==",
"path": "system.text.encodings.web/5.0.0",
"hashPath": "system.text.encodings.web.5.0.0.nupkg.sha512"
},
"System.Text.Json/5.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-+luxMQNZ2WqeffBU7Ml6njIvxc8169NW2oU+ygNudXQGZiarjE7DOtN7bILiQjTZjkmwwRZGTtLzmdrSI/Ustw==",
"path": "system.text.json/5.0.0",
"hashPath": "system.text.json.5.0.0.nupkg.sha512"
},
"System.Threading.Tasks.Extensions/4.5.4": {
"type": "package",
"serviceable": true,
"sha512": "sha512-zteT+G8xuGu6mS+mzDzYXbzS7rd3K6Fjb9RiZlYlJPam2/hU7JCBZBVEcywNuR+oZ1ncTvc/cq0faRr3P01OVg==",
"path": "system.threading.tasks.extensions/4.5.4",
"hashPath": "system.threading.tasks.extensions.4.5.4.nupkg.sha512"
}
}
}
Binary file not shown.
@@ -1,33 +0,0 @@
fileFormatVersion: 2
guid: fde0b3ed1afd33749a8675e312c704fc
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
Binary file not shown.
@@ -1,33 +0,0 @@
fileFormatVersion: 2
guid: a403e5b8a63ba334983c3f7811d22de6
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
Binary file not shown.
@@ -1,33 +0,0 @@
fileFormatVersion: 2
guid: a89f3d8ae2ec3394784109af592b902d
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
@@ -1,33 +0,0 @@
fileFormatVersion: 2
guid: e401bf217545e9d4c9d29f56d85c201b
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
Binary file not shown.
@@ -1,33 +0,0 @@
fileFormatVersion: 2
guid: 4dd0f68e5983fb04a9b06609712cc4e4
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
Binary file not shown.
@@ -1,27 +0,0 @@
fileFormatVersion: 2
guid: 56f71e71972277846b26b62341a29c20
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
userData:
assetBundleName:
assetBundleVariant:
-123
View File
@@ -1,123 +0,0 @@
/*
Copyright 2015 Pim de Witte All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using Speckle.Core.Kits;
using Speckle.Core.Logging;
using UnityEngine;
namespace Speckle.ConnectorUnity
{
/// Author: Pim de Witte (pimdewitte.com) and contributors, https://github.com/PimDeWitte/UnityMainThreadDispatcher
/// <summary>
/// A thread-safe class which holds a queue with actions to execute on the next Update() method. It can be used to make calls to the main thread for
/// things such as UI Manipulation in Unity. It was developed for use in combination with the Firebase Unity plugin, which uses separate threads for event handling
/// </summary>
public class Dispatcher : MonoBehaviour {
private static readonly Queue<Action> _executionQueue = new Queue<Action>();
public void Update() {
lock(_executionQueue) {
while (_executionQueue.Count > 0) {
_executionQueue.Dequeue().Invoke();
}
}
}
/// <summary>
/// Locks the queue and adds the IEnumerator to the queue
/// </summary>
/// <param name="action">IEnumerator function that will be executed from the main thread.</param>
public void Enqueue(IEnumerator action) {
lock (_executionQueue) {
_executionQueue.Enqueue (() => {
StartCoroutine (action);
});
}
}
/// <summary>
/// Locks the queue and adds the Action to the queue
/// </summary>
/// <param name="action">function that will be executed from the main thread.</param>
public void Enqueue(Action action)
{
Enqueue(ActionWrapper(action));
}
/// <summary>
/// Locks the queue and adds the Action to the queue, returning a Task which is completed when the action completes
/// </summary>
/// <param name="action">function that will be executed from the main thread.</param>
/// <returns>A Task that can be awaited until the action completes</returns>
public Task EnqueueAsync(Action action)
{
var tcs = new TaskCompletionSource<bool>();
void WrappedAction() {
try
{
action();
tcs.TrySetResult(true);
} catch (Exception ex)
{
tcs.TrySetException(ex);
}
}
Enqueue(ActionWrapper(WrappedAction));
return tcs.Task;
}
IEnumerator ActionWrapper(Action a)
{
a();
yield return null;
}
private static Dispatcher _instance = null;
public static bool Exists() {
return _instance != null;
}
public static Dispatcher Instance() {
if (!Exists ()) {
throw new Exception ("Could not find the Dispatcher object. Please ensure you have added a Dispatcher object with this script to your scene.");
}
return _instance;
}
void Awake() {
Setup.Init(Applications.Unity);
if (_instance == null) {
_instance = this;
DontDestroyOnLoad(this.gameObject);
}
}
void OnDestroy() {
_instance = null;
}
}
}
Binary file not shown.
-331
View File
@@ -1,331 +0,0 @@
using Objects.Converter.Unity;
using Speckle.Core.Api;
using Speckle.Core.Api.SubscriptionModels;
using Speckle.Core.Credentials;
using Speckle.Core.Logging;
using Speckle.Core.Models;
using Speckle.Core.Transports;
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Sentry;
using Sentry.Protocol;
using UnityEngine;
namespace Speckle.ConnectorUnity
{
/// <summary>
/// A Speckle Receiver, it's a wrapper around a basic Speckle Client
/// that handles conversions and subscriptions for you
/// </summary>
public class Receiver : MonoBehaviour
{
public string StreamId;
public string BranchName = "main";
public Stream Stream;
public int TotalChildrenCount = 0;
public GameObject ReceivedData;
private bool AutoReceive;
private bool DeleteOld;
private Action<ConcurrentDictionary<string, int>> OnProgressAction;
private Action<string, Exception> OnErrorAction;
private Action<int> OnTotalChildrenCountKnown;
private Action<GameObject> OnDataReceivedAction;
private ConverterUnity _converter = new ConverterUnity();
private Client Client { get; set; }
public Receiver()
{
}
/// <summary>
/// Initializes the Receiver manually
/// </summary>
/// <param name="streamId">Id of the stream to receive</param>
/// <param name="autoReceive">If true, it will automatically receive updates sent to this stream</param>
/// <param name="deleteOld">If true, it will delete previously received objects when new one are received</param>
/// <param name="account">Account to use, if null the default account will be used</param>
/// <param name="onDataReceivedAction">Action to run after new data has been received and converted</param>
/// <param name="onProgressAction">Action to run when there is download/conversion progress</param>
/// <param name="onErrorAction">Action to run on error</param>
/// <param name="onTotalChildrenCountKnown">Action to run when the TotalChildrenCount is known</param>
public void Init(string streamId, bool autoReceive = false, bool deleteOld = true, Account account = null,
Action<GameObject> onDataReceivedAction = null, Action<ConcurrentDictionary<string, int>> onProgressAction = null,
Action<string, Exception> onErrorAction = null, Action<int> onTotalChildrenCountKnown = null)
{
StreamId = streamId;
AutoReceive = autoReceive;
DeleteOld = deleteOld;
OnDataReceivedAction = onDataReceivedAction;
OnErrorAction = onErrorAction;
OnProgressAction = onProgressAction;
OnTotalChildrenCountKnown = onTotalChildrenCountKnown;
Client = new Client(account ?? AccountManager.GetDefaultAccount());
//using the ApplicationPlaceholderObject to pass materials
//available in Assets/Materials to the converters
var materials = Resources.LoadAll("Materials", typeof(Material)).Cast<Material>()
.Select(x => new ApplicationPlaceholderObject {NativeObject = x}).ToList();
_converter.SetContextObjects(materials);
if (AutoReceive)
{
Client.SubscribeCommitCreated(StreamId);
Client.OnCommitCreated += Client_OnCommitCreated;
}
}
/// <summary>
/// Gets and converts the data of the last commit on the Stream
/// </summary>
/// <returns></returns>
public void Receive()
{
if (Client == null || string.IsNullOrEmpty(StreamId))
throw new Exception("Receiver has not been initialized. Please call Init().");
Task.Run(async () =>
{
try
{
var mainBranch = await Client.BranchGet(StreamId, BranchName, 1);
if (!mainBranch.commits.items.Any())
throw new Exception("This branch has no commits");
var commit = mainBranch.commits.items[0];
GetAndConvertObject(commit.referencedObject, commit.id);
}
catch (Exception e)
{
throw new SpeckleException(e.Message, e, true, SentryLevel.Error);
}
});
}
#region private methods
/// <summary>
/// Fired when a new commit is created on this stream
/// It receives and converts the objects and then executes the user defined _onCommitCreated action.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected virtual void Client_OnCommitCreated(object sender, CommitInfo e)
{
if (e.branchName == BranchName)
{
Debug.Log("New commit created");
GetAndConvertObject(e.objectId, e.id);
}
}
private async void GetAndConvertObject(string objectId, string commitId)
{
try
{
Tracker.TrackPageview(Tracker.RECEIVE);
var transport = new ServerTransport(Client.Account, StreamId);
var @base = await Operations.Receive(
objectId,
remoteTransport: transport,
onErrorAction: OnErrorAction,
onProgressAction: OnProgressAction,
onTotalChildrenCountKnown: OnTotalChildrenCountKnown
);
Dispatcher.Instance().Enqueue(() =>
{
var go = ConvertRecursivelyToNative(@base, commitId);
//remove previously received object
if (DeleteOld && ReceivedData != null)
Destroy(ReceivedData);
ReceivedData = go;
OnDataReceivedAction?.Invoke(go);
});
}
catch (Exception e)
{
throw new SpeckleException(e.Message, e, true, SentryLevel.Error);
}
}
/// <summary>
/// Converts a Base object to a GameObject Recursively
/// </summary>
/// <param name="base"></param>
/// <returns></returns>
private GameObject ConvertRecursivelyToNative(Base @base, string name)
{
// case 1: it's an item that has a direct conversion method, eg a point
if (_converter.CanConvertToNative(@base))
{
var go = TryConvertItemToNative(@base);
return go;
}
// case 2: it's a wrapper Base
// 2a: if there's only one member unpack it
// 2b: otherwise return dictionary of unpacked members
var members = @base.GetMemberNames().ToList();
if (members.Count() == 1)
{
var go = RecurseTreeToNative(@base[members.First()]);
go.name = members.First();
return go;
}
else
{
//empty game object with the commit id as name, used to contain all the rest
var go = new GameObject();
go.name = name;
foreach (var member in members)
{
var goo = RecurseTreeToNative(@base[member]);
if (goo != null)
{
goo.name = member;
goo.transform.parent = go.transform;
}
}
return go;
}
}
/// <summary>
/// Converts an object recursively to a list of GameObjects
/// </summary>
/// <param name="object"></param>
/// <returns></returns>
private GameObject RecurseTreeToNative(object @object)
{
if (IsList(@object))
{
var list = ((IEnumerable) @object).Cast<object>();
var objects = list.Select(x => RecurseTreeToNative(x)).Where(x => x != null).ToList();
if (objects.Any())
{
var go = new GameObject();
go.name = "List";
objects.ForEach(x => x.transform.parent = go.transform);
return go;
}
}
else
{
return TryConvertItemToNative(@object);
}
return null;
}
private GameObject TryConvertItemToNative(object value)
{
if (value == null)
return null;
//it's a simple type or not a Base
if (value.GetType().IsSimpleType() || !(value is Base))
{
return null;
}
var @base = (Base) value;
//it's an unsupported Base, go through each of its property and try convert that
if (!_converter.CanConvertToNative(@base))
{
var members = @base.GetMemberNames().ToList();
//empty game object with the commit id as name, used to contain all the rest
var go = new GameObject();
go.name = @base.speckle_type;
var goos = new List<GameObject>();
foreach (var member in members)
{
var goo = RecurseTreeToNative(@base[member]);
if (goo != null)
{
goo.name = member;
goo.transform.parent = go.transform;
goos.Add(goo);
}
}
//if no children is valid, return null
if (!goos.Any())
{
Destroy(go);
return null;
}
return go;
}
else
{
try
{
var go = _converter.ConvertToNative(@base) as GameObject;
// Some revit elements have nested elements in a "elements" property
// for instance hosted families on a wall
if (go != null && @base["elements"] is List<Base> l && l.Any())
{
var goo = RecurseTreeToNative(l);
if (goo != null)
{
goo.name = "elements";
goo.transform.parent = go.transform;
}
}
return go;
}
catch (Exception e)
{
throw new SpeckleException(e.Message, e, true, SentryLevel.Error);
}
}
return null;
}
private static bool IsList(object @object)
{
if (@object == null)
return false;
var type = @object.GetType();
return (typeof(IEnumerable).IsAssignableFrom(type) && !typeof(IDictionary).IsAssignableFrom(type) &&
type != typeof(string));
}
private static bool IsDictionary(object @object)
{
if (@object == null)
return false;
Type type = @object.GetType();
return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Dictionary<,>);
}
private void OnDestroy()
{
Client.CommitCreatedSubscription.Dispose();
}
#endregion
}
}
-113
View File
@@ -1,113 +0,0 @@
using Objects.Converter.Unity;
using Speckle.Core.Api;
using Speckle.Core.Api.SubscriptionModels;
using Speckle.Core.Credentials;
using Speckle.Core.Logging;
using Speckle.Core.Models;
using Speckle.Core.Transports;
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Sentry;
using Sentry.Protocol;
using UnityEngine;
namespace Speckle.ConnectorUnity
{
/// <summary>
/// A Speckle Sender, it's a wrapper around a basic Speckle Client
/// that handles conversions for you
/// </summary>
public class Sender : MonoBehaviour
{
/// <summary>
/// Converts and sends the data of the last commit on the Stream
/// </summary>
/// <param name="streamId">ID of the stream to send to</param>
/// <param name="gameObjects">List of gameObjects to convert and send</param>
/// <param name="account">Account to use. If not provided the default account will be used</param>
/// <param name="onDataSentAction">Action to run after the data has been sent</param>
/// <param name="onProgressAction">Action to run when there is download/conversion progress</param>
/// <param name="onErrorAction">Action to run on error</param>
/// <exception cref="SpeckleException"></exception>
public void Send(string streamId, List<GameObject> gameObjects, Account account = null,
Action<string> onDataSentAction = null,
Action<ConcurrentDictionary<string, int>> onProgressAction = null,
Action<string, Exception> onErrorAction = null)
{
try
{
var data = ConvertRecursivelyToSpeckle(gameObjects);
Task.Run(async () =>
{
var res = await Helpers.Send(streamId, data, "Data from unity!",
account: account,
onErrorAction: onErrorAction,
onProgressAction: onProgressAction);
onDataSentAction?.Invoke(res);
});
}
catch (Exception e)
{
throw new SpeckleException(e.Message, e, true, SentryLevel.Error);
}
}
#region private methods
private Base ConvertRecursivelyToSpeckle(List<GameObject> gos)
{
if (gos.Count == 1)
{
return RecurseTreeToNative(gos[0]);
}
var @base = new Base();
@base["objects"] = gos.Select(x => RecurseTreeToNative(x)).Where(x => x != null).ToList();
return @base;
}
private Base RecurseTreeToNative(GameObject go)
{
var converter = new ConverterUnity();
if (converter.CanConvertToSpeckle(go))
{
try
{
return converter.ConvertToSpeckle(go);
}
catch (Exception e)
{
Debug.LogError(e);
return null;
}
}
if (go.transform.childCount > 0)
{
var @base = new Base();
var objects = new List<Base>();
for (var i = 0; i < go.transform.childCount; i++)
{
var goo = RecurseTreeToNative(go.transform.GetChild(i).gameObject);
if (goo != null)
objects.Add(goo);
}
if (objects.Any())
{
@base["objects"] = objects;
return @base;
}
}
return null;
}
#endregion
}
}
@@ -1,14 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Speckle.ConnectorUnity
{
/// <summary>
/// This class gets attached to GOs and is used to store Speckle's metadata when sending / receiving
/// </summary>
public class SpeckleProperties : MonoBehaviour
{
public Dictionary<string, object> Data { get; set; }
}
}
-44
View File
@@ -1,44 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Speckle.Core.Api;
using Speckle.Core.Credentials;
using Speckle.Core.Logging;
namespace Speckle.ConnectorUnity
{
public static class Streams
{
public static async Task<List<Stream>> List(int limit = 10)
{
Tracker.TrackPageview(Tracker.STREAM_LIST);
var account = AccountManager.GetDefaultAccount();
if (account == null)
return new List<Stream>();
var client = new Client(account);
var res = await client.StreamsGet(limit);
return res;
}
public static async Task<Stream> Get(string streamId, int limit = 10)
{
Tracker.TrackPageview(Tracker.STREAM_GET);
var account = AccountManager.GetDefaultAccount();
if (account == null)
return null;
var client = new Client(account);
var res = await client.StreamGet(streamId, limit);
if (res.branches.items != null)
{
res.branches.items.Reverse();
}
return res;
}
}
}
-23
View File
@@ -1,23 +0,0 @@
using System;
using UnityEngine;
namespace Speckle.ConnectorUnity
{
public static class Utils
{
public static int ToIntColor(this Color c)
{
return
System.Drawing.Color
.FromArgb(Convert.ToInt32(c.r * 255), Convert.ToInt32(c.r * 255), Convert.ToInt32(c.r * 255))
.ToArgb();
}
public static Color ToUnityColor(this int c)
{
var argb = System.Drawing.Color.FromArgb(c);
return new Color(argb.R / 255.0f, argb.G / 255.0f, argb.B / 255.0f);
}
}
}
+113 -112
View File
@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using Speckle.Core.Credentials;
@@ -8,124 +9,124 @@ using Stream = Speckle.Core.Api.Stream;
namespace Speckle.ConnectorUnity
{
public class SpeckleExamples : MonoBehaviour
{
public Text SelectStreamText;
public Text DetailsStreamText;
public Dropdown StreamSelectionDropdown;
public Button AddReceiverBtn;
public Toggle AutoReceiveToggle;
public Button AddSenderBtn;
public GameObject StreamPrefab;
public Canvas StreamsCanvas;
private List<Stream> StreamList = null;
private Stream SelectedStream = null;
private List<GameObject> StreamPrefabs = new List<GameObject>();
async void Start()
[Obsolete]
public class SpeckleExamples : MonoBehaviour
{
if (SelectStreamText == null || StreamSelectionDropdown == null)
{
Debug.Log("Please set all input fields on _SpeckleExamples");
return;
}
public Text SelectStreamText;
public Text DetailsStreamText;
public Dropdown StreamSelectionDropdown;
public Button AddReceiverBtn;
public Toggle AutoReceiveToggle;
public Button AddSenderBtn;
public GameObject StreamPanel;
public Canvas StreamsCanvas;
var defaultAccount = AccountManager.GetDefaultAccount();
if (defaultAccount == null)
{
Debug.Log("Please set a default account in SpeckleManager");
return;
}
private List<Stream> StreamList = null;
private Stream SelectedStream = null;
private List<GameObject> StreamPanels = new List<GameObject>();
SelectStreamText.text = $"Select a stream on {defaultAccount.serverInfo.name}:";
async void Start()
{
if (SelectStreamText == null || StreamSelectionDropdown == null)
{
Debug.Log("Please set all input fields on _SpeckleExamples");
return;
}
StreamList = await Streams.List();
if (!StreamList.Any())
{
Debug.Log("There are no streams in your account, please create one online.");
return;
}
var defaultAccount = AccountManager.GetDefaultAccount();
if (defaultAccount == null)
{
Debug.Log("Please set a default account in SpeckleManager");
return;
}
StreamSelectionDropdown.options.Clear();
foreach (var stream in StreamList)
{
StreamSelectionDropdown.options.Add(new Dropdown.OptionData(stream.name + " - " + stream.id));
}
SelectStreamText.text = $"Select a stream on {defaultAccount.serverInfo.name}:";
StreamSelectionDropdown.onValueChanged.AddListener(StreamSelectionChanged);
//trigger ui refresh, maybe there's a better method
StreamSelectionDropdown.value = -1;
StreamSelectionDropdown.value = 0;
StreamList = await Streams.List(30);
if (!StreamList.Any())
{
Debug.Log("There are no streams in your account, please create one online.");
return;
}
StreamSelectionDropdown.options.Clear();
foreach (var stream in StreamList)
{
StreamSelectionDropdown.options.Add(
new Dropdown.OptionData(stream.name + " - " + stream.id)
);
}
AddReceiverBtn.onClick.AddListener(AddReceiver);
AddSenderBtn.onClick.AddListener(AddSender);
StreamSelectionDropdown.onValueChanged.AddListener(StreamSelectionChanged);
//trigger ui refresh, maybe there's a better method
StreamSelectionDropdown.value = -1;
StreamSelectionDropdown.value = 0;
AddReceiverBtn.onClick.AddListener(AddReceiver);
AddSenderBtn.onClick.AddListener(AddSender);
}
public void StreamSelectionChanged(int index)
{
if (index == -1)
return;
SelectedStream = StreamList[index];
DetailsStreamText.text =
$"Description: {SelectedStream.description}\n"
+ $"Link sharing on: {SelectedStream.isPublic}\n"
+ $"Role: {SelectedStream.role}\n"
+ $"Collaborators: {SelectedStream.collaborators.Count}\n"
+ $"Id: {SelectedStream.id}";
}
// Shows how to create a new Receiver from code and then pull data manually
// Created receivers are added to a List of Receivers for future use
private async void AddReceiver()
{
var autoReceive = AutoReceiveToggle.isOn;
var stream = await Streams.Get(SelectedStream.id, 30);
var streamPrefab = Instantiate(StreamPanel, new Vector3(0, 0, 0), Quaternion.identity);
//set position
streamPrefab.transform.SetParent(StreamsCanvas.transform);
var rt = streamPrefab.GetComponent<RectTransform>();
rt.anchoredPosition = new Vector3(-10, -110 - StreamPanels.Count * 110, 0);
streamPrefab.AddComponent<InteractionLogic>().InitReceiver(stream, autoReceive);
StreamPanels.Add(streamPrefab);
}
private async void AddSender()
{
var stream = await Streams.Get(SelectedStream.id, 10);
var streamPrefab = Instantiate(StreamPanel, new Vector3(0, 0, 0), Quaternion.identity);
streamPrefab.transform.SetParent(StreamsCanvas.transform);
var rt = streamPrefab.GetComponent<RectTransform>();
rt.anchoredPosition = new Vector3(-10, -110 - StreamPanels.Count * 110, 0);
streamPrefab.AddComponent<InteractionLogic>().InitSender(stream);
StreamPanels.Add(streamPrefab);
}
public void RemoveStreamPrefab(GameObject streamPrefab)
{
StreamPanels.RemoveAt(StreamPanels.FindIndex(x => x.name == streamPrefab.name));
ReorderStreamPrefabs();
}
private void ReorderStreamPrefabs()
{
for (var i = 0; i < StreamPanels.Count; i++)
{
var rt = StreamPanels[i].GetComponent<RectTransform>();
rt.anchoredPosition = new Vector3(-10, -110 - i * 110, 0);
}
}
}
public void StreamSelectionChanged(int index)
{
if (index == -1)
return;
SelectedStream = StreamList[index];
DetailsStreamText.text =
$"Description: {SelectedStream.description}\n" +
$"Link sharing on: {SelectedStream.isPublic}\n" +
$"Role: {SelectedStream.role}\n" +
$"Collaborators: {SelectedStream.collaborators.Count}\n" +
$"Id: {SelectedStream.id}";
}
// Shows how to create a new Receiver from code and then pull data manually
// Created receivers are added to a List of Receivers for future use
private async void AddReceiver()
{
var autoReceive = AutoReceiveToggle.isOn;
var stream = await Streams.Get(SelectedStream.id, 10);
var streamPrefab = Instantiate(StreamPrefab, new Vector3(0, 0, 0),
Quaternion.identity);
//set position
streamPrefab.transform.SetParent(StreamsCanvas.transform);
var rt = streamPrefab.GetComponent<RectTransform>();
rt.anchoredPosition = new Vector3(-10, -110 - StreamPrefabs.Count * 110, 0);
streamPrefab.AddComponent<InteractionLogic>().InitReceiver(stream, autoReceive);
StreamPrefabs.Add(streamPrefab);
}
private async void AddSender()
{
var stream = await Streams.Get(SelectedStream.id, 10);
var streamPrefab = Instantiate(StreamPrefab, new Vector3(0, 0, 0),
Quaternion.identity);
streamPrefab.transform.SetParent(StreamsCanvas.transform);
var rt = streamPrefab.GetComponent<RectTransform>();
rt.anchoredPosition = new Vector3(-10, -110 - StreamPrefabs.Count * 110, 0);
streamPrefab.AddComponent<InteractionLogic>().InitSender(stream);
StreamPrefabs.Add(streamPrefab);
}
public void RemoveStreamPrefab(GameObject streamPrefab)
{
StreamPrefabs.RemoveAt(StreamPrefabs.FindIndex(x => x.name == streamPrefab.name));
ReorderStreamPrefabs();
}
private void ReorderStreamPrefabs()
{
for (var i = 0; i < StreamPrefabs.Count; i++)
{
var rt = StreamPrefabs[i].GetComponent<RectTransform>();
rt.anchoredPosition = new Vector3(-10, -110 - i * 110, 0);
}
}
}
}
}
File diff suppressed because it is too large Load Diff
+7
View File
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 17672c7479cd1f64c85c42d113e8ad95
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
Binary file not shown.
Binary file not shown.
+28 -4
View File
@@ -28,6 +28,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 3452469119923756171}
m_RootOrder: 0
@@ -103,6 +104,7 @@ RectTransform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1187114122788282811}
m_RootOrder: 3
@@ -183,6 +185,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 6020342713586502030}
m_Father: {fileID: 7556766085298809888}
@@ -308,6 +311,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 3140626913919314916}
m_RootOrder: 1
@@ -383,6 +387,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 102303468818191937}
m_RootOrder: 0
@@ -463,6 +468,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 603356138192389748}
m_Father: {fileID: 7556766085298809888}
@@ -552,6 +558,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 3140626913919314916}
m_RootOrder: 0
@@ -629,6 +636,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 3452469119923756171}
m_Father: {fileID: 2443777670835029483}
@@ -667,6 +675,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 8259817509940803332}
m_RootOrder: 0
@@ -726,7 +735,7 @@ GameObject:
- component: {fileID: 2100176054962759916}
- component: {fileID: 254853880357269643}
m_Layer: 5
m_Name: StreamPanel 1
m_Name: StreamPanel
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
@@ -742,6 +751,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 102303468818191937}
- {fileID: 3140626913919314916}
@@ -823,6 +833,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 2443777670835029483}
- {fileID: 4467957676443937226}
@@ -931,6 +942,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 7392037013616821269}
- {fileID: 8259817509940803332}
@@ -1063,6 +1075,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 5702098015768582807}
- {fileID: 6679144287931550080}
@@ -1153,6 +1166,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 3452469119923756171}
m_RootOrder: 2
@@ -1233,6 +1247,7 @@ RectTransform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 2052973192117566328}
m_Father: {fileID: 1187114122788282811}
@@ -1321,7 +1336,7 @@ MonoBehaviour:
m_SelectedTrigger: Selected
m_DisabledTrigger: Disabled
m_Interactable: 1
m_TargetGraphic: {fileID: 0}
m_TargetGraphic: {fileID: 7169743734853655954}
m_OnClick:
m_PersistentCalls:
m_Calls: []
@@ -1353,6 +1368,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 2617971973288675133}
m_RootOrder: 0
@@ -1432,6 +1448,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 3452469119923756171}
m_RootOrder: 1
@@ -1507,6 +1524,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 6679144287931550080}
m_RootOrder: 0
@@ -1580,6 +1598,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 4127142461058788395}
m_Father: {fileID: 8259817509940803332}
@@ -1618,6 +1637,7 @@ RectTransform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1187114122788282811}
m_RootOrder: 2
@@ -1698,6 +1718,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 4559588495107889264}
m_Father: {fileID: 4467957676443937226}
@@ -1735,6 +1756,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 5904362841980777272}
- {fileID: 4621970763822558170}
@@ -1823,6 +1845,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 6020342713586502030}
m_RootOrder: 0
@@ -1899,6 +1922,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 817718653825013287}
- {fileID: 8018867261834699774}
@@ -1908,8 +1932,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 146.5, y: -62.2}
m_SizeDelta: {x: 122.9, y: 30}
m_AnchoredPosition: {x: 128.64221, y: -62.2}
m_SizeDelta: {x: 158.6156, y: 30}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &8298570900796106430
CanvasRenderer:
+7
View File
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 56efeb256feb62a4f9822d61f43c9abf
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1c4866de6945b724e94ffe464939d914
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 890dd72b062bca74591b5e697dd9f2e9
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+26
View File
@@ -0,0 +1,26 @@
{
"name": "EditorTests",
"rootNamespace": "Speckle.ConnectorUnity.Tests",
"references": [
"UnityEngine.TestRunner",
"UnityEditor.TestRunner",
"Speckle.Connector"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": true,
"precompiledReferences": [
"nunit.framework.dll",
"SpeckleCore2.dll",
"Objects.dll"
],
"autoReferenced": false,
"defineConstraints": [
"UNITY_INCLUDE_TESTS"
],
"versionDefines": [],
"noEngineReferences": false
}
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: ca14751aa58d61e4eb38517168da0cc6
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 5a4f4baa829261d438b740c7d3028756
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+18
View File
@@ -0,0 +1,18 @@
using NUnit.Framework;
using UnityEngine;
namespace Speckle.ConnectorUnity.Tests
{
public abstract class ComponentTest<T> where T : Component
{
protected T sut;
[SetUp]
public void Setup()
{
GameObject go = new();
sut = go.AddComponent<T>();
Assert.That(sut, Is.Not.Null);
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 4e2fe277dd9c47ad998138dcdbb024ae
timeCreated: 1686757093
@@ -0,0 +1,46 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using NUnit.Framework;
using NUnit.Framework.Constraints;
using Speckle.ConnectorUnity.Components;
using Speckle.ConnectorUnity.Wrappers;
using Speckle.Core.Api;
using Speckle.Core.Models;
using UnityEngine;
namespace Speckle.ConnectorUnity.Tests
{
[TestFixture, TestOf(typeof(RecursiveConverter))]
public class ConvertToNativeTests : ComponentTest<RecursiveConverter>
{
private static IEnumerable<string> TestCases()
{
yield return @"https://latest.speckle.dev/streams/c1faab5c62/commits/704984e22d";
}
private static Base Receive(string stream)
{
return Task.Run(async () => await Helpers.Receive(stream)).Result;
}
[Test, TestCaseSource(nameof(TestCases))]
public void ToNative_Passes(string stream)
{
Base testCase = Receive(stream);
var results = sut.RecursivelyConvertToNative_Sync(testCase, null);
Assert.That(results, Has.Count.GreaterThan(0));
Assert.That(results, HasSomeComponent<Transform>());
Assert.That(results, HasSomeComponent<MeshRenderer>());
Assert.That(results, HasSomeComponent<SpeckleProperties>());
}
private static Constraint HasSomeComponent<T>()
where T : Component
{
return Has.Some.Matches<ConversionResult>(x =>
{
return x.WasSuccessful(out var success, out _) && success.GetComponent<T>();
});
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3d9b0fc7baaf51a4a8e2bcefad8bd7b3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,28 @@
{
"name": "PlayModeTests",
"rootNamespace": "Speckle.ConnectorUnity.Tests",
"references": [
"UnityEngine.TestRunner",
"UnityEditor.TestRunner",
"Speckle.ConnectorUnity.Components",
"Utils",
"Speckle.ConnectorUnity.Wrappers"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": true,
"precompiledReferences": [
"nunit.framework.dll",
"SpeckleCore2.dll",
"Objects.dll"
],
"autoReferenced": false,
"defineConstraints": [
"UNITY_INCLUDE_TESTS"
],
"versionDefines": [],
"noEngineReferences": false
}
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 79301723eb79d2745ab1e1a9360f6f2d
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Some files were not shown because too many files have changed in this diff Show More