diff --git a/Assets/Extra/Test Materials.meta b/Assets/Extra/Test Materials.meta new file mode 100644 index 0000000..04f2842 --- /dev/null +++ b/Assets/Extra/Test Materials.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 56f15216bd310954bb57d0900839c613 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Extra/Test Materials/Normals.mat b/Assets/Extra/Test Materials/Normals.mat new file mode 100644 index 0000000..7496300 --- /dev/null +++ b/Assets/Extra/Test Materials/Normals.mat @@ -0,0 +1,28 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Normals + m_Shader: {fileID: 4800000, guid: 75756b5b04ca7b5438e346a8f9f754ba, type: 3} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: [] + m_Colors: [] + m_BuildTextureStacks: [] diff --git a/Assets/Extra/Test Materials/Normals.mat.meta b/Assets/Extra/Test Materials/Normals.mat.meta new file mode 100644 index 0000000..b5851b7 --- /dev/null +++ b/Assets/Extra/Test Materials/Normals.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 763d54739fbe63e4bbd1598690d1af38 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Extra/Test Materials/Normals.shader b/Assets/Extra/Test Materials/Normals.shader new file mode 100644 index 0000000..88de22e --- /dev/null +++ b/Assets/Extra/Test Materials/Normals.shader @@ -0,0 +1,49 @@ +Shader "Unlit/Normals" +{ + Properties + { + } + SubShader + { + Tags { "RenderType"="Opaque" } + LOD 100 + + Pass + { + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + + #include "UnityCG.cginc" + + struct appdata + { + float4 vertex : POSITION; + half3 normal : NORMAL; + }; + + struct v2f + { + float4 vertex : SV_POSITION; + half3 normal : NORMAL; + }; + + v2f vert (appdata v) + { + v2f o; + o.vertex = UnityObjectToClipPos(v.vertex); + o.normal = v.normal; + + return o; + } + + half4 frag (v2f i) : SV_Target + { + half4 color = 0; + color.rgb = i.normal * 0.5 + 0.5; + return color; + } + ENDCG + } + } +} diff --git a/Assets/Extra/Test Materials/Normals.shader.meta b/Assets/Extra/Test Materials/Normals.shader.meta new file mode 100644 index 0000000..f819ed1 --- /dev/null +++ b/Assets/Extra/Test Materials/Normals.shader.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 75756b5b04ca7b5438e346a8f9f754ba +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + preprocessorOverride: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Extra/Test Materials/SpeckleSurface.mat b/Assets/Extra/Test Materials/SpeckleSurface.mat new file mode 100644 index 0000000..cc748d2 --- /dev/null +++ b/Assets/Extra/Test Materials/SpeckleSurface.mat @@ -0,0 +1,87 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: SpeckleSurface + m_Shader: {fileID: 4800000, guid: 837fc98dbf6a92c479b902184ca947bf, type: 3} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _GridSize: 128 + - _Margin: 0.15 + - _Metallic: 0 + - _Mode: 0 + - _Mul: 8192 + - _NormalSaturation: 0.03 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _Saturation: 0.323 + - _SmoothnessSaturation: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _Thickness: 0.32 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _Color0: {r: 0.6, g: 0.6, b: 0.6, a: 1} + - _Color1: {r: 0.57, g: 0.57, b: 0.57, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} + m_BuildTextureStacks: [] diff --git a/Assets/Extra/Test Materials/SpeckleSurface.mat.meta b/Assets/Extra/Test Materials/SpeckleSurface.mat.meta new file mode 100644 index 0000000..c7e9f8d --- /dev/null +++ b/Assets/Extra/Test Materials/SpeckleSurface.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2830afbce900e634985de6a3930d9608 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Extra/Test Materials/SpeckleSurface.shader b/Assets/Extra/Test Materials/SpeckleSurface.shader new file mode 100644 index 0000000..4965ffa --- /dev/null +++ b/Assets/Extra/Test Materials/SpeckleSurface.shader @@ -0,0 +1,128 @@ +Shader "Custom/SpeckleSurface" +{ + Properties + { + [Header(Cube)] + _Thickness("Thickness", Range(0, 1)) = 0.32 + _Margin("Margin", Range(0, 1)) = 0.15 + _NormalSaturation("Normal Saturation", range(0,1)) = 0.03 + _SmoothnessSaturation("Smoothness Saturation", range(0,1)) = 0.02 + + [Header(Tiling)] + _Mul("Multiple", int) = 8192 + _GridSize("Grid Size", int) = 128 + + _Color0("Color 0", Color) = (0.6, 0.6, 0.6, 1) + _Color1("Color 1", Color) = (0.57, 0.57, 0.57, 1) + _MainTex ("Albedo (RGB)", 2D) = "white" {} + } + SubShader + { + Tags { "RenderType"="Opaque" } + LOD 200 + + CGPROGRAM + // Physically based Standard lighting model, and enable shadows on all light types + #pragma surface surf Standard fullforwardshadows + + // Use shader model 3.0 target, to get nicer looking lighting + //#pragma target 3.0 + + struct Input + { + float2 uv_MainTex; + }; + + sampler2D _MainTex; + + float _Thickness; + float _Margin; + int _Mul; + int _GridSize; + + fixed4 _Color0; + fixed4 _Color1; + float _NormalSaturation; + float _SmoothnessSaturation; + + // Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader. + // See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing. + // #pragma instancing_options assumeuniformscaling + //UNITY_INSTANCING_BUFFER_START(Props) + // put more per-instance properties here + //UNITY_INSTANCING_BUFFER_END(Props) + + + fixed speckleSample(float2 pos) + { + // sample the texture + const fixed top = +0.5; + const fixed left = -1; + const fixed base = -0.5; + + bool invert; + { //Fine Grid + float2 grid_pos = (pos + 0.5) * _Mul / 2.0; + grid_pos = grid_pos - floor(grid_pos); + invert = grid_pos.x > 0.5 ^ grid_pos.y > 0.5; + } + + + float2 cell_pos = (pos + 0.5) * _Mul; + cell_pos = cell_pos - floor(cell_pos); + //cell_pos between 0-1 for each Speckle cube + + fixed grey; + + //Cube + { + if(cell_pos.x + cell_pos.y < 1.0) + grey = left; + else + grey = top; + + if(cell_pos.x > _Thickness && cell_pos.y < 1.0 -_Thickness) + grey = base; + } + + if(invert) grey = grey - 1; + + //Ears + if( cell_pos.x + cell_pos.y < _Thickness + || 1.0 - cell_pos.x + 1.0 - cell_pos.y < _Thickness) + { + grey = 0; + } + + //Margins + const bool inCube = cell_pos.x > _Margin && cell_pos.y < 1.0 -_Margin; + if(!inCube) grey = 0; + + return grey; + } + + + void surf (Input IN, inout SurfaceOutputStandard o) + { + fixed4 background = _Color0; + + //Coarse grid + float2 grid_pos = (IN.uv_MainTex + 0.5) * _Mul / _GridSize; + grid_pos = grid_pos - floor(grid_pos); + if(grid_pos.x > 0.5 ^ grid_pos.y > 0.5) + { + background = _Color1; + } + + const half grey = speckleSample(IN.uv_MainTex); + + o.Albedo = background; + o.Metallic = 0.0; + o.Normal = o.Normal + (grey + 1) * _NormalSaturation; + o.Smoothness = grey * _SmoothnessSaturation; + o.Alpha = background.a; + } + ENDCG + } + FallBack "Diffuse" +} diff --git a/Assets/Extra/Test Materials/SpeckleSurface.shader.meta b/Assets/Extra/Test Materials/SpeckleSurface.shader.meta new file mode 100644 index 0000000..a7414fb --- /dev/null +++ b/Assets/Extra/Test Materials/SpeckleSurface.shader.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 837fc98dbf6a92c479b902184ca947bf +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + preprocessorOverride: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Extra/Test Materials/UVs.shader b/Assets/Extra/Test Materials/UVs.shader new file mode 100644 index 0000000..a5c15c9 --- /dev/null +++ b/Assets/Extra/Test Materials/UVs.shader @@ -0,0 +1,47 @@ +Shader "Unlit/UVs" +{ + Properties + { + } + SubShader + { + Tags { "RenderType"="Opaque" } + LOD 100 + + Pass + { + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + + #include "UnityCG.cginc" + + struct appdata + { + float4 vertex : POSITION; + float2 uv : TEXCOORD0; + }; + + struct v2f + { + float4 vertex : SV_POSITION; + float2 colors : TEXCOORD0; + }; + + v2f vert (appdata v) + { + v2f o; + o.vertex = UnityObjectToClipPos(v.vertex); + o.colors = v.uv; + + return o; + } + + half4 frag (v2f i) : SV_Target + { + return half4(i.colors.x, i.colors.y, 0, 0); + } + ENDCG + } + } +} diff --git a/Assets/Extra/Test Materials/UVs.shader.meta b/Assets/Extra/Test Materials/UVs.shader.meta new file mode 100644 index 0000000..ab78e04 --- /dev/null +++ b/Assets/Extra/Test Materials/UVs.shader.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: f6778d5072232804689f36bb771a2122 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + preprocessorOverride: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Extra/Test Materials/Uvs.mat b/Assets/Extra/Test Materials/Uvs.mat new file mode 100644 index 0000000..e20006f --- /dev/null +++ b/Assets/Extra/Test Materials/Uvs.mat @@ -0,0 +1,78 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Uvs + m_Shader: {fileID: 4800000, guid: f6778d5072232804689f36bb771a2122, type: 3} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} + m_BuildTextureStacks: [] diff --git a/Assets/Extra/Test Materials/Uvs.mat.meta b/Assets/Extra/Test Materials/Uvs.mat.meta new file mode 100644 index 0000000..bf39cd8 --- /dev/null +++ b/Assets/Extra/Test Materials/Uvs.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6fe0ba5d1c59c7548be17ef9fb8e2e40 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Extra/Test Materials/VertexColors.mat b/Assets/Extra/Test Materials/VertexColors.mat new file mode 100644 index 0000000..f41fdc9 --- /dev/null +++ b/Assets/Extra/Test Materials/VertexColors.mat @@ -0,0 +1,35 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: VertexColors + m_Shader: {fileID: 4800000, guid: 3b849de517d871d46874414758a096f2, type: 3} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _Shininess: 0.078125 + m_Colors: + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _SpecColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_BuildTextureStacks: [] diff --git a/Assets/Extra/Test Materials/VertexColors.mat.meta b/Assets/Extra/Test Materials/VertexColors.mat.meta new file mode 100644 index 0000000..93148f6 --- /dev/null +++ b/Assets/Extra/Test Materials/VertexColors.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c84690dfb148c6e4f8343f76b3cad987 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Extra/Test Materials/VertexColors.shader b/Assets/Extra/Test Materials/VertexColors.shader new file mode 100644 index 0000000..b6c9314 --- /dev/null +++ b/Assets/Extra/Test Materials/VertexColors.shader @@ -0,0 +1,47 @@ +Shader "Unlit/VertexColors" +{ + Properties + { + } + SubShader + { + Tags { "RenderType"="Opaque" } + LOD 100 + + Pass + { + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + + #include "UnityCG.cginc" + + struct appdata + { + float4 vertex : POSITION; + half4 color : COLOR0; + }; + + struct v2f + { + float4 vertex : SV_POSITION; + half4 color : COLOR0; + }; + + v2f vert (appdata v) + { + v2f o; + o.vertex = UnityObjectToClipPos(v.vertex); + o.color = v.color; + + return o; + } + + half4 frag (v2f i) : SV_Target + { + return i.color; + } + ENDCG + } + } +} diff --git a/Assets/Extra/Test Materials/VertexColors.shader.meta b/Assets/Extra/Test Materials/VertexColors.shader.meta new file mode 100644 index 0000000..02649ea --- /dev/null +++ b/Assets/Extra/Test Materials/VertexColors.shader.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 3b849de517d871d46874414758a096f2 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + preprocessorOverride: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/InteractionLogic.cs b/Assets/InteractionLogic.cs index 87a517e..0d14906 100644 --- a/Assets/InteractionLogic.cs +++ b/Assets/InteractionLogic.cs @@ -3,6 +3,7 @@ using System.Collections; using System.Collections.Generic; using System.Linq; using Speckle.Core.Api; +using Speckle.Core.Logging; using UnityEngine; using UnityEngine.UI; @@ -157,6 +158,13 @@ namespace Speckle.ConnectorUnity statusText.text = $"Sent {commitId}"; sendProgress.gameObject.SetActive(false); //hide }); + }, + onErrorAction: (id, e) => + { + MakeButtonsInteractable(true); + statusText.text = $"Error {id}"; + sendProgress.gameObject.SetActive(false); //hide + throw new SpeckleException(e.Message, e); }); } ); diff --git a/Assets/SpeckleExamples.cs b/Assets/SpeckleExamples.cs index 3f4edd7..e17fa36 100644 --- a/Assets/SpeckleExamples.cs +++ b/Assets/SpeckleExamples.cs @@ -22,6 +22,7 @@ namespace Speckle.ConnectorUnity private List StreamList = null; private Stream SelectedStream = null; private List StreamPanels = new List(); + async void Start() { @@ -40,7 +41,7 @@ namespace Speckle.ConnectorUnity SelectStreamText.text = $"Select a stream on {defaultAccount.serverInfo.name}:"; - StreamList = await Streams.List(); + StreamList = await Streams.List(30); if (!StreamList.Any()) { Debug.Log("There are no streams in your account, please create one online."); @@ -82,7 +83,7 @@ namespace Speckle.ConnectorUnity private async void AddReceiver() { var autoReceive = AutoReceiveToggle.isOn; - var stream = await Streams.Get(SelectedStream.id, 10); + var stream = await Streams.Get(SelectedStream.id, 30); var streamPrefab = Instantiate(StreamPanel, new Vector3(0, 0, 0), Quaternion.identity); diff --git a/Assets/SpecklePlayground.unity b/Assets/SpecklePlayground.unity index ef25382..8fe6ff4 100644 --- a/Assets/SpecklePlayground.unity +++ b/Assets/SpecklePlayground.unity @@ -1245,7 +1245,7 @@ MeshCollider: m_GameObject: {fileID: 512580998} m_Material: {fileID: 0} m_IsTrigger: 0 - m_Enabled: 1 + m_Enabled: 0 serializedVersion: 4 m_Convex: 1 m_CookingOptions: 30 @@ -1269,7 +1269,7 @@ MeshRenderer: m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: - - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 2100000, guid: 2830afbce900e634985de6a3930d9608, type: 2} m_StaticBatchInfo: firstSubMesh: 0 subMeshCount: 0 @@ -1298,7 +1298,7 @@ MeshFilter: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 512580998} - m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} + m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!4 &512581002 Transform: m_ObjectHideFlags: 0 @@ -1308,7 +1308,7 @@ Transform: m_GameObject: {fileID: 512580998} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: -2.5, z: 0} - m_LocalScale: {x: 500, y: 0.1, z: 500} + m_LocalScale: {x: 512, y: 1, z: 512} m_Children: [] m_Father: {fileID: 0} m_RootOrder: 2 @@ -4181,7 +4181,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 2068176107} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 1, z: -30.5} + m_LocalPosition: {x: 0, y: 1, z: -32} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} diff --git a/Packages/manifest.json b/Packages/manifest.json index c0719ab..1b369d8 100644 --- a/Packages/manifest.json +++ b/Packages/manifest.json @@ -2,10 +2,10 @@ "dependencies": { "com.unity.2d.sprite": "1.0.0", "com.unity.collab-proxy": "1.13.5", - "com.unity.ide.rider": "2.0.7", - "com.unity.ide.visualstudio": "2.0.11", + "com.unity.ide.rider": "3.0.7", + "com.unity.ide.visualstudio": "2.0.12", "com.unity.ide.vscode": "1.2.4", - "com.unity.test-framework": "1.1.29", + "com.unity.test-framework": "1.1.30", "com.unity.textmeshpro": "3.0.6", "com.unity.timeline": "1.4.8", "com.unity.ugui": "1.0.0", diff --git a/Packages/packages-lock.json b/Packages/packages-lock.json index ece3a18..5a33166 100644 --- a/Packages/packages-lock.json +++ b/Packages/packages-lock.json @@ -24,16 +24,16 @@ "url": "https://packages.unity.com" }, "com.unity.ide.rider": { - "version": "2.0.7", + "version": "3.0.7", "depth": 0, "source": "registry", "dependencies": { - "com.unity.test-framework": "1.1.1" + "com.unity.ext.nunit": "1.0.6" }, "url": "https://packages.unity.com" }, "com.unity.ide.visualstudio": { - "version": "2.0.11", + "version": "2.0.12", "depth": 0, "source": "registry", "dependencies": { @@ -65,7 +65,7 @@ "url": "https://packages.unity.com" }, "com.unity.test-framework": { - "version": "1.1.29", + "version": "1.1.30", "depth": 0, "source": "registry", "dependencies": { diff --git a/Packages/systems.speckle.speckle-unity/ConverterUnity.Geometry.cs b/Packages/systems.speckle.speckle-unity/ConverterUnity.Geometry.cs index a55207d..1dd4e0d 100644 --- a/Packages/systems.speckle.speckle-unity/ConverterUnity.Geometry.cs +++ b/Packages/systems.speckle.speckle-unity/ConverterUnity.Geometry.cs @@ -1,22 +1,29 @@ -using Objects.Geometry; -using System; +using System; +using Objects.Geometry; using System.Collections.Generic; using System.Linq; using System.Reflection; using Objects.Other; -using Objects.Primitive; +using Objects.Utils; using Speckle.ConnectorUnity; using Speckle.Core.Models; using UnityEditor; using UnityEngine; +using UnityEngine.Rendering; using Mesh = Objects.Geometry.Mesh; -using Object = UnityEngine.Object; +using SColor = System.Drawing.Color; namespace Objects.Converter.Unity { public partial class ConverterUnity { + + private static readonly int EmissionColor = Shader.PropertyToID("_EmissionColor"); + private static readonly int Metallic = Shader.PropertyToID("_Metallic"); + private static readonly int Glossiness = Shader.PropertyToID("_Glossiness"); + #region helper methods + /// /// /// @@ -57,14 +64,14 @@ namespace Objects.Converter.Unity /// /// /// - public Vector3[] ArrayToPoints(IEnumerable arr, string units) + public Vector3[] ArrayToPoints(IList arr, string units) { - if (arr.Count() % 3 != 0) throw new Exception("Array malformed: length%3 != 0."); + 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); + Vector3[] points = new Vector3[arr.Count / 3]; + + for (int i = 2, k = 0; i < arr.Count; i += 3) + points[k++] = VectorByCoordinates(arr[i - 2], arr[i - 1], arr[i], units); return points; @@ -109,53 +116,62 @@ namespace Objects.Converter.Unity /// - /// Converts a Speckle mesh to a GameObject with a mesh renderer + /// Converts the component on into a Speckle /// - /// - /// + /// The Unity to convert + /// The converted , if no on exists public Mesh MeshToSpeckle(GameObject go) { //TODO: support multiple filters? var filter = go.GetComponent(); - if (filter == null) + if (filter == null) return null; + + var nativeMesh = filter.mesh; + + var nTriangles = nativeMesh.triangles; + List sFaces = new List(nTriangles.Length * 4); + for (int i = 2; i < nTriangles.Length; i += 3) { - return null; + sFaces.Add(0); //Triangle cardinality indicator + + sFaces.Add(nTriangles[i]); + sFaces.Add(nTriangles[i - 1]); + sFaces.Add(nTriangles[i - 2]); } - //convert triangle array into speckleMesh faces - List faces = new List(); - int i = 0; - //store them here, makes it like 1000000x faster? - var triangles = filter.mesh.triangles; - while (i < triangles.Length) + var nVertices = nativeMesh.vertices; + List sVertices = new List(nVertices.Length * 3); + foreach (var vertex in nVertices) { - faces.Add(0); + var p = go.transform.TransformPoint(vertex); + sVertices.Add(p.x); + sVertices.Add(p.z); //z and y swapped + sVertices.Add(p.y); + } + + var nColors = nativeMesh.colors; + List sColors = new List(nColors.Length); + sColors.AddRange(nColors.Select(c => c.ToIntColor())); - faces.Add(triangles[i + 0]); - faces.Add(triangles[i + 2]); - faces.Add(triangles[i + 1]); - i += 3; + var nTexCoords = nativeMesh.uv; + List sTexCoords = new List(nTexCoords.Length * 2); + foreach (var uv in nTexCoords) + { + sTexCoords.Add(uv.x); + sTexCoords.Add(uv.y); } 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.vertices = sVertices; + mesh.faces = sFaces; + mesh.colors = sColors; + mesh.textureCoordinates = sTexCoords; 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 @@ -181,7 +197,7 @@ namespace Objects.Converter.Unity } /// - /// Converts a Speckle point to a GameObject with a line renderer + /// Converts a Speckle to a with a /// /// /// @@ -189,13 +205,13 @@ namespace Objects.Converter.Unity { Vector3 newPt = VectorByCoordinates(point.x, point.y, point.z, point.units); - var go = NewPointBasedGameObject(new Vector3[2] { newPt, newPt }, point.speckle_type); + var go = NewPointBasedGameObject(new Vector3[] { newPt, newPt }, point.speckle_type); return go; } /// - /// Converts a Speckle line to a GameObject with a line renderer + /// Converts a Speckle to a with a /// /// /// @@ -208,145 +224,52 @@ namespace Objects.Converter.Unity } /// - /// Converts a Speckle polyline to a GameObject with a line renderer + /// Converts a Speckle to a with a /// /// /// public GameObject PolylineToNative(Polyline polyline) { - var points = polyline.points.Select(x => VectorFromPoint(x)); + var points = polyline.GetPoints().Select(VectorFromPoint); var go = NewPointBasedGameObject(points.ToArray(), polyline.speckle_type); return go; } /// - /// Converts a Speckle curve to a GameObject with a line renderer + /// Converts a Speckle to a with a /// /// /// public GameObject CurveToNative(Curve curve) { var points = ArrayToPoints(curve.points, curve.units); - var go = NewPointBasedGameObject(points.ToArray(), curve.speckle_type); + var go = NewPointBasedGameObject(points, 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()); - } + /// - /// Converts a Speckle mesh to a GameObject with a mesh renderer + /// Converts multiple (e.g. with different materials) into one native mesh /// - /// Mesh to convert - /// If provided will override the renderMaterial on the mesh itself - /// If provided will override the properties on the mesh itself - /// - public GameObject MeshToNative( - Mesh speckleMesh, RenderMaterial renderMaterial = null, - Dictionary properties = null - ) + /// The element from which properties should be grabbed from + /// Collection of es that shall be converted + /// If provided, will override the properties on the mesh itself + /// A with the converted , , and + public GameObject MeshesToNative(Base element, IReadOnlyCollection meshes, Dictionary properties = null) { - if (speckleMesh.vertices.Count == 0 || speckleMesh.faces.Count == 0) + MeshDataToNative(meshes, out var nativeMesh, out var nativeMaterials); + + var go = new GameObject { - return null; - } - - var recenterMeshTransforms = true; //TODO: figure out how best to change this? - - - var verts = ArrayToPoints(speckleMesh.vertices, speckleMesh.units); - - - //convert speckleMesh.faces into triangle array - List tris = new List(); - int i = 0; - // TODO: Check if this is causing issues with normals for mesh - 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 { name = speckleMesh.speckle_type }; - var mesh = new UnityEngine.Mesh { name = speckleMesh.speckle_type }; - - if (verts.Length >= 65535) - mesh.indexFormat = UnityEngine.Rendering.IndexFormat.UInt32; - - - // center transform pivot according to the bounds of the model - if (recenterMeshTransforms) - { - Bounds meshBounds = new Bounds - { - center = verts[0] - }; - - foreach (var vert in verts) - { - meshBounds.Encapsulate(vert); - } - - go.transform.position = meshBounds.center; - - // offset mesh vertices - for (int l = 0; l < verts.Length; l++) - { - verts[l] -= meshBounds.center; - } - } - - - - - mesh.SetVertices(verts); - mesh.SetTriangles(tris, 0); - - if (speckleMesh.bbox != null) - { - var uv = GenerateUV(verts, (float)speckleMesh.bbox.xSize.Length, (float)speckleMesh.bbox.ySize.Length).ToList(); - mesh.SetUVs(0, uv); - - } - - // BUG: causing some funky issues with meshes - // mesh.RecalculateNormals( ); - mesh.Optimize(); - // Setting mesh to filter once all mesh modifying is done - go.SafeMeshSet(mesh, true); - - + name = element.speckle_type + }; + + go.SafeMeshSet(nativeMesh, true); + var meshRenderer = go.AddComponent(); - var speckleMaterial = renderMaterial ?? (RenderMaterial)speckleMesh["renderMaterial"]; - meshRenderer.sharedMaterial = GetMaterial(speckleMaterial); + meshRenderer.sharedMaterials = nativeMaterials; //Add mesh collider // MeshCollider mc = go.AddComponent( ); // mc.sharedMesh = mesh; @@ -357,16 +280,164 @@ namespace Objects.Converter.Unity //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); + var meshprops = typeof(Base).GetProperties(BindingFlags.Instance | BindingFlags.Public).Select(x => x.Name) + .ToList(); + properties = element.GetMembers() + .Where(x => !meshprops.Contains(x.Key)) + .ToDictionary(x => x.Key, x => x.Value); } AttachSpeckleProperties(go, properties); return go; } + + /// + /// Converts to a with a + /// + /// Mesh to convert + /// If provided, will override the properties on the mesh itself + /// + public GameObject MeshToNative(Mesh speckleMesh, Dictionary properties = null) + { + if (speckleMesh.vertices.Count == 0 || speckleMesh.faces.Count == 0) + { + return null; + } + + return MeshesToNative(speckleMesh, new[] {speckleMesh}, properties); + } + + /// + /// + /// + /// meshes to be converted as SubMeshes + /// The converted native mesh + /// The converted materials (one per converted sub-mesh) + public void MeshDataToNative(IReadOnlyCollection meshes, out UnityEngine.Mesh nativeMesh, out Material[] nativeMaterials) + { + var verts = new List(); + + var uvs = new List(); + var vertexColors = new List(); + + var materials = new List(meshes.Count); + var subMeshes = new List>(meshes.Count); + + foreach (Mesh m in meshes) + { + if(m.vertices.Count == 0 || m.faces.Count == 0 ) continue; + List tris = new List(); + SubmeshToNative(m, verts, tris, uvs, vertexColors, materials); + subMeshes.Add(tris); + } + nativeMaterials = materials.ToArray(); + + nativeMesh = new UnityEngine.Mesh(); + + //TODO not sure if this is necessary, could just set the GameObject transform like we are in unreal? + // center transform pivot according to the bounds of the model + // if (recenterMeshTransforms) + // { + // Bounds meshBounds = new Bounds + // { + // center = verts[0] + // }; + // + // foreach (var vert in verts) + // { + // meshBounds.Encapsulate(vert); + // } + // + // // offset mesh vertices + // for (int l = 0; l < verts.Count; l++) + // { + // verts[l] -= meshBounds.center; + // } + // } + + nativeMesh.subMeshCount = subMeshes.Count; + + nativeMesh.SetVertices(verts); + nativeMesh.SetUVs(0, uvs); + nativeMesh.SetColors(vertexColors); + + + int j = 0; + foreach(var subMeshTriangles in subMeshes) + { + nativeMesh.SetTriangles(subMeshTriangles, j); + j++; + } + + if (nativeMesh.vertices.Length >= UInt16.MaxValue) + nativeMesh.indexFormat = IndexFormat.UInt32; + + nativeMesh.Optimize(); + nativeMesh.RecalculateBounds(); + nativeMesh.RecalculateNormals(); + nativeMesh.RecalculateTangents(); + } + + + private void SubmeshToNative(Mesh speckleMesh, List verts, List tris, List texCoords, List vertexColors, List materials) + { + speckleMesh.AlignVerticesWithTexCoordsByIndex(); + speckleMesh.TriangulateMesh(); + + int indexOffset = verts.Count; + + // Convert Vertices + verts.AddRange(ArrayToPoints(speckleMesh.vertices, speckleMesh.units)); + + // Convert texture coordinates + bool hasValidUVs = speckleMesh.TextureCoordinatesCount == speckleMesh.VerticesCount; + if(speckleMesh.textureCoordinates.Count > 0 && !hasValidUVs) Debug.LogWarning($"Expected number of UV coordinates to equal vertices. Got {speckleMesh.TextureCoordinatesCount} expected {speckleMesh.VerticesCount}. \nID = {speckleMesh.id}"); + + if (hasValidUVs) + { + texCoords.Capacity += speckleMesh.TextureCoordinatesCount; + for (int j = 0; j < speckleMesh.TextureCoordinatesCount; j++) + { + var (u, v) = speckleMesh.GetTextureCoordinate(j); + texCoords.Add(new Vector2((float)u,(float)v)); + } + } + else if (speckleMesh.bbox != null) + { + //Attempt to generate some crude UV coordinates using bbox //TODO this will be broken for submeshes + texCoords.AddRange(GenerateUV(verts, (float)speckleMesh.bbox.xSize.Length, (float)speckleMesh.bbox.ySize.Length)); + } + + // Convert vertex colors + if (speckleMesh.colors != null) + { + if (speckleMesh.colors.Count == speckleMesh.VerticesCount) + { + vertexColors.AddRange(speckleMesh.colors.Select(c => c.ToUnityColor())); + } + else if (speckleMesh.colors.Count != 0) + { + //TODO what if only some submeshes have colors? + Debug.LogWarning($"{typeof(Mesh)} {speckleMesh.id} has invalid number of vertex {nameof(Mesh.colors)}. Expected 0 or {speckleMesh.VerticesCount}, got {speckleMesh.colors.Count}"); + } + } + + // Convert faces + tris.Capacity += (int) (speckleMesh.faces.Count / 4f) * 3; + + for (int i = 0; i < speckleMesh.faces.Count; i += 4) + { + //We can safely assume all faces are triangles since we called TriangulateMesh + tris.Add(speckleMesh.faces[i + 1] + indexOffset); + tris.Add(speckleMesh.faces[i + 3] + indexOffset); + tris.Add(speckleMesh.faces[i + 2] + indexOffset); + } + + // Convert RenderMaterial + materials.Add(GetMaterial(speckleMesh["renderMaterial"] as RenderMaterial)); + } + + private static IEnumerable GenerateUV(IReadOnlyList verts, float xSize, float ySize) { @@ -416,10 +487,16 @@ namespace Objects.Converter.Unity } var c = renderMaterial.diffuse.ToUnityColor(); - mat.color = new Color(c.r, c.g, c.b, Convert.ToSingle(renderMaterial.opacity)); - mat.name = renderMaterial.name == null ? "material-"+ Guid.NewGuid().ToString().Substring(0,8) : renderMaterial.name; - + mat.color = new Color(c.r, c.g, c.b, (float)renderMaterial.opacity); + mat.name = renderMaterial.name ?? "material-"+ Guid.NewGuid().ToString().Substring(0,8); + + mat.SetFloat(Metallic, (float)renderMaterial.metalness); + mat.SetFloat(Glossiness, 1 - (float)renderMaterial.roughness); + if (renderMaterial.emissive != SColor.Black.ToArgb()) mat.EnableKeyword ("_EMISSION"); + mat.SetColor(EmissionColor, renderMaterial.emissive.ToUnityColor()); + + #if UNITY_EDITOR if (StreamManager.GenerateMaterials) { @@ -429,8 +506,7 @@ namespace Objects.Converter.Unity if (AssetDatabase.LoadAllAssetsAtPath("Assets/Resources/Materials/Speckle Generated/" + mat.name + ".mat").Length == 0) AssetDatabase.CreateAsset(mat, "Assets/Resources/Materials/Speckle Generated/" + mat.name + ".mat"); } #endif - - + return mat; } // 3. if not renderMaterial was passed, the default shader will be used diff --git a/Packages/systems.speckle.speckle-unity/ConverterUnity.cs b/Packages/systems.speckle.speckle-unity/ConverterUnity.cs index 54d9edd..d320ef7 100644 --- a/Packages/systems.speckle.speckle-unity/ConverterUnity.cs +++ b/Packages/systems.speckle.speckle-unity/ConverterUnity.cs @@ -7,6 +7,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Objects.BuiltElements; +using Unity.Plastic.Antlr3.Runtime.Debug; using UnityEngine; using Mesh = Objects.Geometry.Mesh; @@ -16,6 +17,8 @@ namespace Objects.Converter.Unity { #region implemented methods + public void SetConverterSettings(object settings) => throw new NotImplementedException(); + public string Description => "Default Speckle Kit for Unity"; public string Name => nameof(ConverterUnity); public string Author => "Speckle"; @@ -66,20 +69,23 @@ namespace Objects.Converter.Unity // 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(); + if (@object["displayValue"] is Base b) + return ConvertToNative(b); + if (@object["displayValue"] is IEnumerable bs) + return MeshesToNative(@object, bs.OfType().ToList()); + if (@object["displayMesh"] is Base m) + return ConvertToNative(m); + Debug.LogWarning($"Skipping {@object.GetType()} {@object.id} - Not supported type"); + return null; } + } public List ConvertToSpeckle(List objects) { - return objects.Select(x => ConvertToSpeckle(x)).ToList(); + return objects.Select(ConvertToSpeckle).ToList(); } public List ConvertToNative(List objects) @@ -115,12 +121,16 @@ namespace Objects.Converter.Unity // return true; // case View2D _: // return false; - case IDisplayMesh _: - return true; case Mesh _: return true; default: - return @object["displayMesh"] is Mesh; + if (@object["displayValue"] is Base) + return true; + if (@object["displayValue"] is IEnumerable) + return true; + if (@object["displayMesh"] is Base) + return true; + return false; } } diff --git a/Packages/systems.speckle.speckle-unity/Core/Sentry.dll.meta b/Packages/systems.speckle.speckle-unity/Core/Sentry.dll.meta index 4078770..a949454 100644 --- a/Packages/systems.speckle.speckle-unity/Core/Sentry.dll.meta +++ b/Packages/systems.speckle.speckle-unity/Core/Sentry.dll.meta @@ -7,7 +7,7 @@ PluginImporter: executionOrder: {} defineConstraints: [] isPreloaded: 0 - isOverridable: 0 + isOverridable: 1 isExplicitlyReferenced: 0 validateReferences: 1 platformData: diff --git a/Packages/systems.speckle.speckle-unity/Core/SpeckleCore2.dll b/Packages/systems.speckle.speckle-unity/Core/SpeckleCore2.dll index aa3c801..83b1e56 100644 Binary files a/Packages/systems.speckle.speckle-unity/Core/SpeckleCore2.dll and b/Packages/systems.speckle.speckle-unity/Core/SpeckleCore2.dll differ diff --git a/Packages/systems.speckle.speckle-unity/Core/SpeckleCore2.xml b/Packages/systems.speckle.speckle-unity/Core/SpeckleCore2.xml index ab8bdd6..8e42172 100644 --- a/Packages/systems.speckle.speckle-unity/Core/SpeckleCore2.xml +++ b/Packages/systems.speckle.speckle-unity/Core/SpeckleCore2.xml @@ -706,6 +706,12 @@ + + + Some converters need to be able to receive some settings to modify their internal behaviour (i.e. Rhino's Brep Meshing options). Use this method to set them. + + The object representing the settings for your converter. + Returns all the object types (the object model) provided by this kit. @@ -774,6 +780,74 @@ The reference assembly name. A boolean value indicating if there is a reference. + + + Anonymous telemetry to help us understand how to make a better Speckle. + This really helps us to deliver a better open source project and product! + + + + + Default Mixpanel events + + + + + Event triggered when data is sent to a Speckle Server + + + + + Event triggered when data is received from a Speckle Server + + + + + Event triggered when a node is executed in a visual programming environment, it should contain the name of the action and the host application + + + + + Event triggered when an action is executed in Desktop UI, it should contain the name of the action and the host application + + + + + Cached email + + + + + Cached server URL + + + + + Tracks an event without specifying the email and server. + It's not always possible to know which account the user has selected, especially in visual programming. + Therefore we are caching the email and server values so that they can be used also when nodes such as "Serialize" are used. + If no account info is cached, we use the default account data. + + Name of the even + Additional parameters to pass in to event + + + + Tracks an event from a specified account, anonymizes personal information + + Account to use, it will be anonymized + Name of the event + Additional parameters to pass to the event + + + + Tracks an event from a specified email and server, anonymizes personal information + + Email of the user, it will be anonymized + Server URL, it will be anonymized + Name of the event + Additional parameters to pass to the event + Anonymous telemetry to help us understand how to make a better Speckle. @@ -958,7 +1032,7 @@ - Wrapper around other, thrid party, classes that are not coming from a speckle kit. + Wrapper around other, third party, classes that are not coming from a speckle kit. Serialization and deserialization of the base object happens through default Newtonsoft converters. If your object does not de/serialize correctly, this class will not prevent that from happening. Limitations: - Base object needs to be serializable. diff --git a/Packages/systems.speckle.speckle-unity/Editor/StreamManagerEditor.cs b/Packages/systems.speckle.speckle-unity/Editor/StreamManagerEditor.cs index f0e119d..49f1e46 100644 --- a/Packages/systems.speckle.speckle-unity/Editor/StreamManagerEditor.cs +++ b/Packages/systems.speckle.speckle-unity/Editor/StreamManagerEditor.cs @@ -24,77 +24,81 @@ namespace Speckle.ConnectorUnity private int _totalChildrenCount = 0; private StreamManager _streamManager; + public int StreamsLimit { get; set; } = 30; + public int BranchesLimit { get; set; } = 30; + public int CommitsLimit { get; set; } = 25; + private int SelectedAccountIndex { - get { return _streamManager.SelectedAccountIndex; } - set { _streamManager.SelectedAccountIndex = value; } + get => _streamManager.SelectedAccountIndex; + set => _streamManager.SelectedAccountIndex = value; } private int SelectedStreamIndex { - get { return _streamManager.SelectedStreamIndex; } - set { _streamManager.SelectedStreamIndex = value; } + get => _streamManager.SelectedStreamIndex; + set => _streamManager.SelectedStreamIndex = value; } private int SelectedBranchIndex { - get { return _streamManager.SelectedBranchIndex; } - set { _streamManager.SelectedBranchIndex = value; } + get => _streamManager.SelectedBranchIndex; + set => _streamManager.SelectedBranchIndex = value; } private int SelectedCommitIndex { - get { return _streamManager.SelectedCommitIndex; } - set { _streamManager.SelectedCommitIndex = value; } + get => _streamManager.SelectedCommitIndex; + set => _streamManager.SelectedCommitIndex = value; } private int OldSelectedAccountIndex { - get { return _streamManager.OldSelectedAccountIndex; } - set { _streamManager.OldSelectedAccountIndex = value; } + get => _streamManager.OldSelectedAccountIndex; + set => _streamManager.OldSelectedAccountIndex = value; } private int OldSelectedStreamIndex { - get { return _streamManager.OldSelectedStreamIndex; } - set { _streamManager.OldSelectedStreamIndex = value; } + get => _streamManager.OldSelectedStreamIndex; + set => _streamManager.OldSelectedStreamIndex = value; } private Client Client { - get { return _streamManager.Client; } - set { _streamManager.Client = value; } + get => _streamManager.Client; + set => _streamManager.Client = value; } private Account SelectedAccount { - get { return _streamManager.SelectedAccount; } - set { _streamManager.SelectedAccount = value; } + get => _streamManager.SelectedAccount; + set => _streamManager.SelectedAccount = value; } private Stream SelectedStream { - get { return _streamManager.SelectedStream; } - set { _streamManager.SelectedStream = value; } + get => _streamManager.SelectedStream; + set => _streamManager.SelectedStream = value; } public List Accounts { - get { return _streamManager.Accounts; } - set { _streamManager.Accounts = value; } + get => _streamManager.Accounts; + set => _streamManager.Accounts = value; } private List Streams { - get { return _streamManager.Streams; } - set { _streamManager.Streams = value; } + get => _streamManager.Streams; + set => _streamManager.Streams = value; } private List Branches { - get { return _streamManager.Branches; } + get => _streamManager.Branches; - set { _streamManager.Branches = value; } + set => _streamManager.Branches = value; } private async Task LoadAccounts() @@ -124,7 +128,7 @@ namespace Speckle.ConnectorUnity private async Task LoadStreams() { EditorUtility.DisplayProgressBar("Loading streams...", "", 0); - Streams = await Client.StreamsGet(); + Streams = await Client.StreamsGet(StreamsLimit); EditorUtility.ClearProgressBar(); if (Streams.Any()) await SelectStream(0); @@ -137,7 +141,7 @@ namespace Speckle.ConnectorUnity SelectedStream = Streams[i]; EditorUtility.DisplayProgressBar("Loading stream details...", "", 0); - Branches = await Client.StreamGetBranches(SelectedStream.id); + Branches = await Client.StreamGetBranches(SelectedStream.id, BranchesLimit, CommitsLimit); if (Branches.Any()) { SelectedBranchIndex = 0; diff --git a/Packages/systems.speckle.speckle-unity/Objects/Objects.dll b/Packages/systems.speckle.speckle-unity/Objects/Objects.dll index ad3b857..d794543 100644 Binary files a/Packages/systems.speckle.speckle-unity/Objects/Objects.dll and b/Packages/systems.speckle.speckle-unity/Objects/Objects.dll differ diff --git a/Packages/systems.speckle.speckle-unity/Utils.cs b/Packages/systems.speckle.speckle-unity/Utils.cs index 267055a..f6d134a 100644 --- a/Packages/systems.speckle.speckle-unity/Utils.cs +++ b/Packages/systems.speckle.speckle-unity/Utils.cs @@ -54,18 +54,24 @@ namespace Speckle.ConnectorUnity } + /// + /// Converts a Unity color to an ARBG int + /// public static int ToIntColor(this Color c) { return System.Drawing.Color - .FromArgb(Convert.ToInt32(c.r * 255), Convert.ToInt32(c.r * 255), Convert.ToInt32(c.r * 255)) + .FromArgb(Convert.ToInt32(c.r * 255), Convert.ToInt32(c.g * 255), Convert.ToInt32(c.b * 255)) .ToArgb(); } - + + /// + /// Converts a ARGB formatted int to a Unity Color + /// public static Color ToUnityColor(this int c) { var argb = System.Drawing.Color.FromArgb(c); - return new Color(argb.R / 255.0f, argb.G / 255.0f, argb.B / 255.0f); + return new Color(argb.R / 255f, argb.G / 255f, argb.B / 255f); } }