Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8ea383c70e | |||
| 6db3fbf37c | |||
| 6da38a7f93 | |||
| 799ca6228c | |||
| 5fa0416bf9 | |||
| fd4d515004 | |||
| b701b4d1f6 | |||
| ab00f1911b | |||
| ef21c7d885 | |||
| b2f08d6ff0 | |||
| 9a2d042b75 |
-210
@@ -1,210 +0,0 @@
|
||||
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
|
||||
+5
-9
@@ -10,9 +10,6 @@
|
||||
/[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/
|
||||
@@ -45,14 +42,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
|
||||
@@ -73,8 +70,7 @@ 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/
|
||||
# Unity Plugins
|
||||
/[Aa]ssets/[Pp]lugins/
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
<?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
@@ -0,0 +1,8 @@
|
||||
<?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
@@ -0,0 +1,7 @@
|
||||
<?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>
|
||||
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"version": "1.0",
|
||||
"components": [
|
||||
"Microsoft.VisualStudio.Workload.ManagedGame"
|
||||
]
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f7f8762fcd0c1174782d2ba683cb6b74
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,62 +0,0 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b5627857f30c8994c87469d287b2d115
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+175
-175
@@ -22,193 +22,193 @@ using UnityEngine;
|
||||
|
||||
public class CameraOperate : MonoBehaviour
|
||||
{
|
||||
[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;
|
||||
[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;
|
||||
|
||||
//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()
|
||||
{
|
||||
m_transform = transform;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (operate)
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
//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系数使得当rotateYSpeed,rotateXSpeed为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;
|
||||
}
|
||||
|
||||
|
||||
m_transform = transform;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (operate)
|
||||
{
|
||||
//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系数使得当rotateYSpeed,rotateXSpeed为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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6c972b8c7391a8243869747abd85964f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,67 +0,0 @@
|
||||
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.Models;
|
||||
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 () =>
|
||||
{
|
||||
using ServerTransport transport = new(account, streamId);
|
||||
MemoryTransport localTransport = new();
|
||||
|
||||
Base speckleObject = await Operations.Receive(
|
||||
objectId,
|
||||
remoteTransport: transport,
|
||||
localTransport: localTransport
|
||||
);
|
||||
|
||||
Dispatcher
|
||||
.Instance()
|
||||
.Enqueue(() =>
|
||||
{
|
||||
var parentObject = new GameObject(name);
|
||||
|
||||
receiver.RecursivelyConvertToNative_Sync(speckleObject, parentObject.transform);
|
||||
|
||||
Debug.Log($"Receive {objectId} completed");
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 66c38558aa523bf4290b4fd84411df46
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,84 +0,0 @@
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Speckle.ConnectorUnity.Components;
|
||||
using Speckle.Core.Api;
|
||||
using Speckle.Core.Credentials;
|
||||
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)
|
||||
{
|
||||
Client client = sender.Account.Client!;
|
||||
Stream stream = sender.Stream.Selected;
|
||||
Account selectedAccount = sender.Account.Selected!;
|
||||
|
||||
using ServerTransport transport = new(selectedAccount, stream!.id);
|
||||
|
||||
string branchId = await client.BranchCreate(
|
||||
new BranchCreateInput() { streamId = stream.id, name = branchName }
|
||||
);
|
||||
|
||||
return await SpeckleSender.SendDataAsync(
|
||||
remoteTransport: transport,
|
||||
data,
|
||||
client,
|
||||
branchId,
|
||||
true
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#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
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c98b93e32c844fb488992e2e376447a1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +1,7 @@
|
||||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
using UnityEngine;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Speckle.ConnectorUnity
|
||||
{
|
||||
@@ -22,7 +21,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))
|
||||
{
|
||||
@@ -30,5 +29,4 @@ namespace Speckle.ConnectorUnity
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
+32
-30
@@ -4,43 +4,45 @@ 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()
|
||||
{
|
||||
Bounds totalBounds = new Bounds();
|
||||
|
||||
var renderers = this.gameObject.GetComponents<MeshRenderer>();
|
||||
|
||||
foreach (var r in renderers)
|
||||
public Bounds GetObjectBounds()
|
||||
{
|
||||
if (totalBounds.center == Vector3.zero)
|
||||
{
|
||||
totalBounds = r.bounds;
|
||||
}
|
||||
else
|
||||
{
|
||||
totalBounds.Encapsulate(r.bounds);
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
return totalBounds;
|
||||
}
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
//Add this Object to global list
|
||||
if (!SelectionManager.selectables.Contains(this))
|
||||
void OnEnable()
|
||||
{
|
||||
SelectionManager.selectables.Add(this);
|
||||
//Add this Object to global list
|
||||
if (!SelectionManager.selectables.Contains(this))
|
||||
{
|
||||
SelectionManager.selectables.Add(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OnDisable()
|
||||
{
|
||||
SelectionManager.selectables.Remove(this);
|
||||
SelectionManager.selectedObjects.Remove(this);
|
||||
}
|
||||
void OnDisable()
|
||||
{
|
||||
//Remove this Object from global list
|
||||
if (SelectionManager.selectables.Contains(this))
|
||||
{
|
||||
SelectionManager.selectables.Remove(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,6 @@ 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;
|
||||
@@ -33,7 +32,7 @@ public class SelectionManager : MonoBehaviour
|
||||
Vector3 mousePosition1;
|
||||
|
||||
public static List<Selectable> selectables = new List<Selectable>();
|
||||
public static List<Selectable> selectedObjects = new List<Selectable>();
|
||||
public static List<int> selectedObjects = new List<int>();
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
@@ -60,14 +59,14 @@ public class SelectionManager : MonoBehaviour
|
||||
Camera camera = Camera.main;
|
||||
if (camera == null)
|
||||
return;
|
||||
|
||||
|
||||
selectedObjects.Clear();
|
||||
Bounds viewportBounds = GetViewportBounds(camera, mousePosition1, Input.mousePosition);
|
||||
foreach (var t in selectables)
|
||||
for (int i = 0; i < selectables.Count; i++)
|
||||
{
|
||||
if (viewportBounds.Contains(camera.WorldToViewportPoint(t.transform.position)))
|
||||
Bounds viewportBounds = GetViewportBounds(camera, mousePosition1, Input.mousePosition);
|
||||
if (viewportBounds.Contains(camera.WorldToViewportPoint(selectables[i].transform.position)))
|
||||
{
|
||||
selectedObjects.Add(t);
|
||||
selectedObjects.Add(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -87,7 +86,7 @@ public class SelectionManager : MonoBehaviour
|
||||
Camera camera = Camera.main;
|
||||
for (int i = 0; i < selectedObjects.Count; i++)
|
||||
{
|
||||
DrawSelectionIndicator(camera, selectedObjects[i].GetObjectBounds());
|
||||
DrawSelectionIndicator(camera, selectables[selectedObjects[i]].GetObjectBounds());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 06440602a29587942a9b041f6e277a93
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"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
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5e69a9305ecfb37438ec1f98750d0b13
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,28 +0,0 @@
|
||||
%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: []
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 763d54739fbe63e4bbd1598690d1af38
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,49 +0,0 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 75756b5b04ca7b5438e346a8f9f754ba
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,87 +0,0 @@
|
||||
%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: []
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2830afbce900e634985de6a3930d9608
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,128 +0,0 @@
|
||||
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"
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 837fc98dbf6a92c479b902184ca947bf
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,47 +0,0 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f6778d5072232804689f36bb771a2122
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,78 +0,0 @@
|
||||
%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: []
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6fe0ba5d1c59c7548be17ef9fb8e2e40
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,35 +0,0 @@
|
||||
%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: []
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c84690dfb148c6e4f8343f76b3cad987
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,47 +0,0 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3b849de517d871d46874414758a096f2
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+178
-227
@@ -1,244 +1,195 @@
|
||||
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
|
||||
{
|
||||
[Obsolete]
|
||||
public class InteractionLogic : MonoBehaviour
|
||||
public class InteractionLogic : MonoBehaviour
|
||||
{
|
||||
private Receiver receiver;
|
||||
|
||||
public void InitReceiver(Stream stream, bool autoReceive)
|
||||
{
|
||||
private Receiver _receiver;
|
||||
gameObject.name = $"receiver-{stream.id}-{Guid.NewGuid().ToString()}";
|
||||
InitRemove();
|
||||
|
||||
public void InitReceiver(Stream stream, bool autoReceive)
|
||||
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) =>
|
||||
{
|
||||
gameObject.name = $"receiver-{stream.id}-{Guid.NewGuid().ToString()}";
|
||||
InitRemove();
|
||||
statusText.text = $"Received {go.name}";
|
||||
MakeButtonsInteractable(true);
|
||||
receiveProgress.value = 0;
|
||||
receiveProgress.gameObject.SetActive(false);
|
||||
|
||||
_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();
|
||||
List<Branch> branches = _receiver.Stream.branches.items;
|
||||
branches.Reverse();
|
||||
foreach (Branch branch in branches)
|
||||
{
|
||||
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 =>
|
||||
{
|
||||
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();
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recursively adds custom components to all children of a GameObject
|
||||
/// </summary>
|
||||
/// <param name="go"></param>
|
||||
private void AddComponents(GameObject go)
|
||||
AddComponents(go);
|
||||
},
|
||||
onTotalChildrenCountKnown: (count) => { receiver.TotalChildrenCount = count; },
|
||||
onProgressAction: (dict) =>
|
||||
{
|
||||
for (var i = 0; i < go.transform.childCount; i++)
|
||||
{
|
||||
var child = go.transform.GetChild(i);
|
||||
//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;
|
||||
});
|
||||
});
|
||||
|
||||
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>();
|
||||
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);
|
||||
});
|
||||
}
|
||||
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) =>
|
||||
{
|
||||
//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) =>
|
||||
{
|
||||
Dispatcher.Instance.Enqueue(() =>
|
||||
{
|
||||
MakeButtonsInteractable(true);
|
||||
statusText.text = $"Sent {commitId}";
|
||||
sendProgress.gameObject.SetActive(false); //hide
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
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);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9e8bc8cda58ea6c41a8d9c89bf68f726
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 978be06c8e5f29d42910ca9985d0e9ab
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5b42d273c4ee09a43b5dff30f6e05988
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e50a8f3b511f13748b134a3a5e000b0f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f823114029cf4814c962a9b71f81705d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 98d0614354f7fc04cb4b030f4c54810f
|
||||
guid: 2822f83843986b844820ecb3fe7c2c98
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
@@ -0,0 +1,29 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,390 @@
|
||||
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];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f434d359a9ac0f342be2b2f2128af995
|
||||
guid: 20fa550ba5944159a7676339936db5dd
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
Binary file not shown.
+2
-2
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5e6c835b7544a374095e58eddb5d2f1c
|
||||
guid: b247945d70e245344bcffce2b041c942
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -7,7 +7,7 @@ PluginImporter:
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 1
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
Binary file not shown.
+2
-2
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3e49710593731cc49b9d22a0ba82b5d1
|
||||
guid: 0601d89c02d114748b2642d1dd3c3cc5
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -7,7 +7,7 @@ PluginImporter:
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 1
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
Binary file not shown.
+2
-2
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b875f05888babdd4db73c70d39a33feb
|
||||
guid: aa2b8d95b1a2f42488ab6f2b82873878
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -7,7 +7,7 @@ PluginImporter:
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 1
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
Binary file not shown.
+2
-2
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c822f631fa258514f8b76cdcaacc1b36
|
||||
guid: ca23b8455384460469452d484a0b94f0
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -7,7 +7,7 @@ PluginImporter:
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 1
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
Binary file not shown.
@@ -0,0 +1,33 @@
|
||||
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.
@@ -0,0 +1,33 @@
|
||||
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.
@@ -0,0 +1,33 @@
|
||||
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:
|
||||
Binary file not shown.
@@ -0,0 +1,33 @@
|
||||
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:
|
||||
@@ -0,0 +1,455 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6940276f6a5ab054d93a08a3133be230
|
||||
guid: b324aeb46f92c0e4caaad218755a9866
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
Binary file not shown.
@@ -0,0 +1,33 @@
|
||||
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.
@@ -0,0 +1,33 @@
|
||||
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.
@@ -0,0 +1,33 @@
|
||||
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:
|
||||
@@ -0,0 +1,33 @@
|
||||
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.
Binary file not shown.
@@ -0,0 +1,33 @@
|
||||
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:
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 56f15216bd310954bb57d0900839c613
|
||||
guid: addaa5ebcd10c5245bf8d074437d5b37
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
Binary file not shown.
@@ -0,0 +1,27 @@
|
||||
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:
|
||||
@@ -0,0 +1,146 @@
|
||||
/*
|
||||
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.Runtime.CompilerServices;
|
||||
using System.Threading.Tasks;
|
||||
using Speckle.Core.Kits;
|
||||
using Speckle.Core.Logging;
|
||||
using Unity.EditorCoroutines.Editor;
|
||||
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>
|
||||
///
|
||||
[ExecuteAlways]
|
||||
public class Dispatcher : MonoBehaviour {
|
||||
|
||||
private static readonly Queue<Action> _executionQueue = new Queue<Action>( );
|
||||
|
||||
private static Dispatcher _instance;
|
||||
|
||||
EditorCoroutine m_LoggerCoroutine;
|
||||
|
||||
public static bool Ownerless { get; set; }
|
||||
|
||||
public static Dispatcher Instance { get; set; }
|
||||
// public static Dispatcher Instance {
|
||||
// get {
|
||||
// if ( _instance == null )
|
||||
// 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;
|
||||
// }
|
||||
// set => _instance = value;
|
||||
// }
|
||||
|
||||
private void OnEnable( )
|
||||
{
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
void Awake( )
|
||||
{
|
||||
Instance = this;
|
||||
Setup.Init( Applications.Unity );
|
||||
|
||||
if ( _instance == null ) {
|
||||
_instance = this;
|
||||
if ( Application.isPlaying )
|
||||
DontDestroyOnLoad( this.gameObject );
|
||||
}
|
||||
}
|
||||
|
||||
void OnDestroy( )
|
||||
{
|
||||
_instance = null;
|
||||
}
|
||||
|
||||
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 ) {
|
||||
if ( Application.isEditor ) {
|
||||
Debug.Log( "Calling from Editor" );
|
||||
_executionQueue.Enqueue( ( ) => {
|
||||
if ( Ownerless )
|
||||
EditorCoroutineUtility.StartCoroutineOwnerless( action );
|
||||
else
|
||||
EditorCoroutineUtility.StartCoroutine( action, this );
|
||||
} );
|
||||
} else {
|
||||
Debug.Log( "Calling from Play" );
|
||||
_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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,308 @@
|
||||
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>
|
||||
[ExecuteAlways]
|
||||
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;
|
||||
public Action ReceiveCompleteAction;
|
||||
|
||||
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; }
|
||||
|
||||
/// <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( string branchName = "" )
|
||||
{
|
||||
if ( Client == null || string.IsNullOrEmpty( StreamId ) )
|
||||
throw new Exception( "Receiver has not been initialized. Please call Init()." );
|
||||
|
||||
if ( !string.IsNullOrEmpty( branchName ) )
|
||||
BranchName = branchName;
|
||||
|
||||
Task.Run( async ( ) => {
|
||||
try {
|
||||
Debug.Log( $"Trying for Branch: {BranchName} on Stream: {StreamId} " );
|
||||
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 ];
|
||||
// TODO send info for what objects are being converted
|
||||
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 )
|
||||
{
|
||||
Debug.Log( "Converting new objects" );
|
||||
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 ) {
|
||||
if ( Application.isPlaying )
|
||||
Destroy( ReceivedData );
|
||||
else {
|
||||
DestroyImmediate( ReceivedData );
|
||||
}
|
||||
}
|
||||
ReceivedData = go;
|
||||
OnDataReceivedAction?.Invoke( go );
|
||||
} );
|
||||
Debug.Log( "Try State Done" );
|
||||
ReceiveCompleteAction?.Invoke( );
|
||||
|
||||
}
|
||||
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 {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
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user