2.18 Update

This commit is contained in:
Jedd Morgan
2024-02-22 18:31:09 +00:00
parent edeec70993
commit 1b2eeed3eb
24 changed files with 776 additions and 418 deletions
@@ -23,7 +23,7 @@ public class AttachSpecklePropertiesExample : MonoBehaviour
public virtual void Start() public virtual void Start()
{ {
Client speckleClient = new(AccountManager.GetDefaultAccount()); Client speckleClient = new(AccountManager.GetDefaultAccount()!);
StartCoroutine(AttachSpeckleProperties(speckleClient, streamId, objectId)); StartCoroutine(AttachSpeckleProperties(speckleClient, streamId, objectId));
} }
+23 -27
View File
@@ -1,10 +1,10 @@
using System;
using System.Collections; using System.Collections;
using System.Threading.Tasks; using System.Threading.Tasks;
using Speckle.ConnectorUnity; using Speckle.ConnectorUnity;
using Speckle.ConnectorUnity.Components; using Speckle.ConnectorUnity.Components;
using Speckle.Core.Api; using Speckle.Core.Api;
using Speckle.Core.Credentials; using Speckle.Core.Credentials;
using Speckle.Core.Models;
using Speckle.Core.Transports; using Speckle.Core.Transports;
using UnityEngine; using UnityEngine;
@@ -12,60 +12,56 @@ using UnityEngine;
[RequireComponent(typeof(RecursiveConverter))] [RequireComponent(typeof(RecursiveConverter))]
public class ManualReceive : MonoBehaviour public class ManualReceive : MonoBehaviour
{ {
public string authToken; public string authToken;
public string serverUrl; public string serverUrl;
public string streamId, objectId; public string streamId,
objectId;
private RecursiveConverter receiver;
private RecursiveConverter receiver;
void Awake() void Awake()
{ {
receiver = GetComponent<RecursiveConverter>(); receiver = GetComponent<RecursiveConverter>();
} }
IEnumerator Start() IEnumerator Start()
{ {
Debug.developerConsoleVisible = true; Debug.developerConsoleVisible = true;
if(Time.timeSinceLevelLoad > 20) yield return null; if (Time.timeSinceLevelLoad > 20)
yield return null;
Receive(); Receive();
} }
[ContextMenu(nameof(Receive))] [ContextMenu(nameof(Receive))]
public void Receive() public void Receive()
{ {
var account = new Account() var account = new Account()
{ {
token = authToken, token = authToken,
serverInfo = new ServerInfo() {url = serverUrl}, serverInfo = new ServerInfo() { url = serverUrl },
}; };
Task.Run(async () => Task.Run(async () =>
{ {
var transport = new ServerTransport(account, streamId); using ServerTransport transport = new(account, streamId);
var localTransport = new MemoryTransport(); MemoryTransport localTransport = new();
var @base = await Operations.Receive( Base speckleObject = await Operations.Receive(
objectId, objectId,
remoteTransport: transport, remoteTransport: transport,
localTransport: localTransport, localTransport: localTransport
onErrorAction: (m, e) => Debug.LogError(m + e),
disposeTransports: true
); );
if (@base == null) throw new Exception("received data was null!");
Dispatcher.Instance().Enqueue(() =>
{
var parentObject = new GameObject(name);
receiver.RecursivelyConvertToNative_Sync(@base, parentObject.transform);
Debug.Log($"Receive {objectId} completed"); Dispatcher
}); .Instance()
.Enqueue(() =>
{
var parentObject = new GameObject(name);
receiver.RecursivelyConvertToNative_Sync(speckleObject, parentObject.transform);
Debug.Log($"Receive {objectId} completed");
});
}); });
} }
} }
+22 -17
View File
@@ -2,6 +2,7 @@ using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Speckle.ConnectorUnity.Components; using Speckle.ConnectorUnity.Components;
using Speckle.Core.Api; using Speckle.Core.Api;
using Speckle.Core.Credentials;
using Speckle.Core.Models; using Speckle.Core.Models;
using Speckle.Core.Transports; using Speckle.Core.Transports;
using UnityEngine; using UnityEngine;
@@ -18,24 +19,25 @@ namespace Extra
{ {
[Range(0, 100)] [Range(0, 100)]
public int numberOfIterations = 10; public int numberOfIterations = 10;
public Vector3 translation = Vector3.forward * 100; public Vector3 translation = Vector3.forward * 100;
public GameObject objectToSend; public GameObject objectToSend;
private SpeckleSender sender; private SpeckleSender sender;
private void Awake() private void Awake()
{ {
sender = GetComponent<SpeckleSender>(); sender = GetComponent<SpeckleSender>();
} }
public async Task SendIterations() public async Task SendIterations()
{ {
GameObject go = new GameObject(); GameObject go = new GameObject();
for (int i = 0; i < numberOfIterations; i++) for (int i = 0; i < numberOfIterations; i++)
{ {
Instantiate(objectToSend, translation * i, Quaternion.identity, go.transform); Instantiate(objectToSend, translation * i, Quaternion.identity, go.transform);
Base b = sender.Converter.RecursivelyConvertToSpeckle(go, _ => true); Base b = sender.Converter.RecursivelyConvertToSpeckle(go, _ => true);
await Send(b, $"{i}"); await Send(b, $"{i}");
} }
@@ -44,20 +46,23 @@ namespace Extra
private async Task<string> Send(Base data, string branchName) private async Task<string> Send(Base data, string branchName)
{ {
var client = sender.Account.Client; Client client = sender.Account.Client!;
var stream = sender.Stream.Selected; Stream stream = sender.Stream.Selected;
ServerTransport transport = new ServerTransport(sender.Account.Selected, stream!.id); Account selectedAccount = sender.Account.Selected!;
await client.BranchCreate(new BranchCreateInput(){streamId = stream.id, name = branchName}); using ServerTransport transport = new(selectedAccount, stream!.id);
return await SpeckleSender.SendDataAsync(CancellationToken.None, string branchId = await client.BranchCreate(
new BranchCreateInput() { streamId = stream.id, name = branchName }
);
return await SpeckleSender.SendDataAsync(
remoteTransport: transport, remoteTransport: transport,
data: data, data,
client: client!, client,
branchName: branchName, branchId,
createCommit: true, true
onProgressAction: null, );
onErrorAction: (m, e) => throw e);
} }
} }
@@ -68,7 +73,7 @@ namespace Extra
public override async void OnInspectorGUI() public override async void OnInspectorGUI()
{ {
DrawDefaultInspector(); DrawDefaultInspector();
if (GUILayout.Button("Create and send")) if (GUILayout.Button("Create and send"))
{ {
await ((PerformanceTestSender)target).SendIterations(); await ((PerformanceTestSender)target).SendIterations();
-1
View File
@@ -3,7 +3,6 @@ using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using Speckle.Core.Credentials; using Speckle.Core.Credentials;
using System.Linq; using System.Linq;
using UnityEngine.Events;
using UnityEngine.UI; using UnityEngine.UI;
using Stream = Speckle.Core.Api.Stream; using Stream = Speckle.Core.Api.Stream;
+2 -2
View File
@@ -1,14 +1,14 @@
{ {
"dependencies": { "dependencies": {
"com.unity.2d.sprite": "1.0.0", "com.unity.2d.sprite": "1.0.0",
"com.unity.collab-proxy": "2.0.5", "com.unity.collab-proxy": "2.0.7",
"com.unity.ide.rider": "3.0.24", "com.unity.ide.rider": "3.0.24",
"com.unity.ide.visualstudio": "2.0.18", "com.unity.ide.visualstudio": "2.0.18",
"com.unity.ide.vscode": "1.2.5", "com.unity.ide.vscode": "1.2.5",
"com.unity.test-framework": "1.1.33", "com.unity.test-framework": "1.1.33",
"com.unity.textmeshpro": "3.0.6", "com.unity.textmeshpro": "3.0.6",
"com.unity.timeline": "1.6.5", "com.unity.timeline": "1.6.5",
"com.unity.toolchain.win-x86_64-linux-x86_64": "2.0.2", "com.unity.toolchain.win-x86_64-linux-x86_64": "2.0.4",
"com.unity.ugui": "1.0.0", "com.unity.ugui": "1.0.0",
"com.unity.modules.ai": "1.0.0", "com.unity.modules.ai": "1.0.0",
"com.unity.modules.androidjni": "1.0.0", "com.unity.modules.androidjni": "1.0.0",
+4 -4
View File
@@ -7,7 +7,7 @@
"dependencies": {} "dependencies": {}
}, },
"com.unity.collab-proxy": { "com.unity.collab-proxy": {
"version": "2.0.5", "version": "2.0.7",
"depth": 0, "depth": 0,
"source": "registry", "source": "registry",
"dependencies": {}, "dependencies": {},
@@ -94,12 +94,12 @@
"url": "https://packages.unity.com" "url": "https://packages.unity.com"
}, },
"com.unity.toolchain.win-x86_64-linux-x86_64": { "com.unity.toolchain.win-x86_64-linux-x86_64": {
"version": "2.0.2", "version": "2.0.4",
"depth": 0, "depth": 0,
"source": "registry", "source": "registry",
"dependencies": { "dependencies": {
"com.unity.sysroot": "2.0.3", "com.unity.sysroot": "2.0.5",
"com.unity.sysroot.linux-x86_64": "2.0.2" "com.unity.sysroot.linux-x86_64": "2.0.4"
}, },
"url": "https://packages.unity.com" "url": "https://packages.unity.com"
}, },
@@ -163,7 +163,7 @@ namespace Speckle.ConnectorUnity.Components.Editor
bool BeforeConvert(TraversalContext context) bool BeforeConvert(TraversalContext context)
{ {
Base b = context.current; Base b = context.Current;
//NOTE: progress wont reach 100% because not all objects are convertable //NOTE: progress wont reach 100% because not all objects are convertable
float progress = (childrenConverted + childrenFailed) / totalChildrenFloat; float progress = (childrenConverted + childrenFailed) / totalChildrenFloat;
@@ -77,7 +77,6 @@ namespace Speckle.ConnectorUnity.Components.Editor
), ),
}; };
//TODO onError action?
if (data["@objects"] is IList l && l.Count == 0) if (data["@objects"] is IList l && l.Count == 0)
{ {
Debug.LogWarning($"Nothing to send", speckleSender); Debug.LogWarning($"Nothing to send", speckleSender);
@@ -64,7 +64,7 @@ namespace Speckle.ConnectorUnity
cancellationTokenSource = new CancellationTokenSource(); cancellationTokenSource = new CancellationTokenSource();
var client = new Client(account ?? AccountManager.GetDefaultAccount()); var client = new Client(account ?? AccountManager.GetDefaultAccount()!);
transport = new ServerTransport(client.Account, streamId); transport = new ServerTransport(client.Account, streamId);
transport.CancellationToken = cancellationTokenSource.Token; transport.CancellationToken = cancellationTokenSource.Token;
@@ -49,7 +49,8 @@ namespace Speckle.ConnectorUnity.Components
); );
var accountTask = new Utils.Utils.WaitForTask<Account>( var accountTask = new Utils.Utils.WaitForTask<Account>(
async () => await GetAccount(sw) async () => await GetAccount(sw),
_tokenSource.Token
); );
yield return accountTask; yield return accountTask;
@@ -57,8 +58,10 @@ namespace Speckle.ConnectorUnity.Components
using Client c = new(accountTask.Result); using Client c = new(accountTask.Result);
var objectIdTask = new Utils.Utils.WaitForTask<(string, Commit?)>( var objectIdTask = new Utils.Utils.WaitForTask<(string, Commit?)>(
async () => await GetObjectID(sw, c) async () => await GetObjectID(sw, c),
_tokenSource.Token
); );
yield return objectIdTask; yield return objectIdTask;
(string objectId, Commit? commit) = objectIdTask.Result; (string objectId, Commit? commit) = objectIdTask.Result;
@@ -72,7 +75,8 @@ namespace Speckle.ConnectorUnity.Components
objectId, objectId,
commit, commit,
cancellationToken: _tokenSource.Token cancellationToken: _tokenSource.Token
) ),
_tokenSource.Token
); );
yield return receiveTask; yield return receiveTask;
@@ -92,7 +92,7 @@ namespace Speckle.ConnectorUnity.Components
public bool WasSuccessful() => this.exception == null; public bool WasSuccessful() => this.exception == null;
public Base SpeckleObject => traversalContext.current; public Base SpeckleObject => traversalContext.Current;
} }
public partial class RecursiveConverter public partial class RecursiveConverter
@@ -143,7 +143,7 @@ namespace Speckle.ConnectorUnity.Components
var objectsToConvert = traversalFunc var objectsToConvert = traversalFunc
.Traverse(rootObject) .Traverse(rootObject)
.Where(x => ConverterInstance.CanConvertToNative(x.current)) .Where(x => ConverterInstance.CanConvertToNative(x.Current))
.Where(x => userPredicate(x)); .Where(x => userPredicate(x));
Dictionary<Base, GameObject?> created = new(); Dictionary<Base, GameObject?> created = new();
@@ -186,9 +186,9 @@ namespace Speckle.ConnectorUnity.Components
{ {
Transform? currentParent = GetParent(tc, outCreatedObjects) ?? parent; Transform? currentParent = GetParent(tc, outCreatedObjects) ?? parent;
var converted = ConvertToNative(tc.current, currentParent); var converted = ConvertToNative(tc.Current, currentParent);
result = new ConversionResult(tc, converted); result = new ConversionResult(tc, converted);
outCreatedObjects.TryAdd(tc.current, result.converted); outCreatedObjects.TryAdd(tc.Current, result.converted);
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -209,11 +209,11 @@ namespace Speckle.ConnectorUnity.Components
if (tc == null) if (tc == null)
return null; //We've reached the root object, and still not found a converted parent return null; //We've reached the root object, and still not found a converted parent
if (createdObjects.TryGetValue(tc.current, out GameObject? p) && p != null) if (createdObjects.TryGetValue(tc.Current, out GameObject? p) && p != null)
return p.transform; return p.transform;
//Go one level up, and repeat! //Go one level up, and repeat!
return GetParent(tc.parent, createdObjects); return GetParent(tc.Parent, createdObjects);
} }
protected GameObject ConvertToNative(Base speckleObject, Transform? parentTransform) protected GameObject ConvertToNative(Base speckleObject, Transform? parentTransform)
@@ -327,7 +327,18 @@ namespace Speckle.ConnectorUnity.Components
{ {
object? converted = null; object? converted = null;
if (predicate(baseObject)) if (predicate(baseObject))
converted = ConverterInstance.ConvertToNative(baseObject); {
try
{
converted = ConverterInstance.ConvertToNative(baseObject);
}
catch (Exception ex) when (!ex.IsFatal())
{
Debug.LogWarning(
$"Failed to convert {baseObject.speckle_type} - {baseObject.id}\n{ex}"
);
}
}
// Handle new GameObjects // Handle new GameObjects
Transform? nextParent = parent; Transform? nextParent = parent;
@@ -259,42 +259,20 @@ namespace Speckle.ConnectorUnity.Components
CancellationToken cancellationToken = default CancellationToken cancellationToken = default
) )
{ {
using var transport = new ServerTransportV2(client.Account, streamId); using var transport = new ServerTransport(client.Account, streamId);
transport.CancellationToken = cancellationToken; transport.CancellationToken = cancellationToken;
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
Base? requestedObject = await Operations Base requestedObject = await Operations
.Receive( .Receive(
objectId: objectId, objectId,
cancellationToken: cancellationToken, transport,
remoteTransport: transport, null,
onProgressAction: onProgressAction, onProgressAction,
onErrorAction: (s, ex) => onTotalChildrenCountKnown,
{ cancellationToken
//Don't wrap cancellation exceptions!
if (ex is OperationCanceledException)
throw ex;
//HACK: Sometimes, the task was cancelled, and Operations.Receive doesn't fail in a reliable way. In this case, the exception is often simply a symptom of a cancel.
if (cancellationToken.IsCancellationRequested)
{
SpeckleLog.Logger.Warning(
ex,
"A task was cancelled, ignoring potentially symptomatic exception"
);
cancellationToken.ThrowIfCancellationRequested();
}
//Treat all operation errors as fatal
throw new SpeckleException(
$"Failed to receive requested object {objectId} from server: {s}",
ex
);
},
onTotalChildrenCountKnown: onTotalChildrenCountKnown,
disposeTransports: false
) )
.ConfigureAwait(false); .ConfigureAwait(false);
@@ -317,9 +295,6 @@ namespace Speckle.ConnectorUnity.Components
} }
); );
if (requestedObject == null)
throw new SpeckleException($"Operation {nameof(Operations.Receive)} returned null");
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
//Read receipt //Read receipt
@@ -340,10 +315,10 @@ namespace Speckle.ConnectorUnity.Components
) )
.ConfigureAwait(false); .ConfigureAwait(false);
} }
catch (Exception e) catch (Exception ex)
{ {
// Do nothing! // Do nothing!
Debug.LogWarning($"Failed to send read receipt\n{e}"); Debug.LogWarning($"Failed to send read receipt\n{ex}");
} }
return requestedObject; return requestedObject;
@@ -447,12 +422,9 @@ namespace Speckle.ConnectorUnity.Components
/// <summary> /// <summary>
/// Fetches the commit preview for the currently selected commit /// Fetches the commit preview for the currently selected commit
/// </summary> /// </summary>
/// <param name="allAngles">when <see langword="true"/>, will fetch 360 degree preview image</param>
/// <param name="callback">Callback function to be called when the web request completes</param> /// <param name="callback">Callback function to be called when the web request completes</param>
/// <returns>The executing <see cref="Coroutine"/> or <see langword="null"/> if <see cref="Account"/>, <see cref="Stream"/>, or <see cref="Commit"/> was <see langword="null"/></returns> /// <returns>The executing <see cref="Coroutine"/> or <see langword="null"/> if <see cref="Account"/>, <see cref="Stream"/>, or <see cref="Commit"/> was <see langword="null"/></returns>
public Coroutine? GetPreviewImage( /*bool allAngles,*/ public Coroutine? GetPreviewImage(Action<Texture2D?> callback)
Action<Texture2D?> callback
)
{ {
Account? account = Account.Selected; Account? account = Account.Selected;
if (account == null) if (account == null)
@@ -476,25 +448,25 @@ namespace Speckle.ConnectorUnity.Components
[ContextMenu("Open Speckle Stream in Browser")] [ContextMenu("Open Speckle Stream in Browser")]
protected void OpenUrlInBrowser() protected void OpenUrlInBrowser()
{ {
string url = GetSelectedUrl(); Uri url = GetSelectedUrl();
Application.OpenURL(url); Application.OpenURL(url.ToString());
} }
#endif #endif
public string GetSelectedUrl() public Uri GetSelectedUrl()
{ {
string serverUrl = Account.Selected!.serverInfo.url; Account selectedAccount = Account.Selected!;
string? streamId = Stream.Selected?.id; StreamWrapper sw =
string? branchName = Branch.Selected?.name; new()
string? commitId = Commit.Selected?.id; {
ServerUrl = selectedAccount.serverInfo.url,
StreamId = Stream.Selected!.id,
BranchName = Branch.Selected?.id,
CommitId = Commit.Selected?.id
};
sw.SetAccount(selectedAccount);
if (string.IsNullOrEmpty(streamId)) return sw.ToServerUri();
return serverUrl;
if (!string.IsNullOrEmpty(commitId))
return $"{serverUrl}/streams/{streamId}/commits/{commitId}";
if (!string.IsNullOrEmpty(branchName))
return $"{serverUrl}/streams/{streamId}/branches/{branchName}";
return $"{serverUrl}/streams/{streamId}";
} }
public void Awake() public void Awake()
@@ -36,6 +36,7 @@ namespace Speckle.ConnectorUnity.Components
[HideInInspector] [HideInInspector]
public BranchSelectionEvent OnBranchSelectionChange; public BranchSelectionEvent OnBranchSelectionChange;
[Obsolete("No longer used")]
[HideInInspector] [HideInInspector]
public ErrorActionEvent OnErrorAction; public ErrorActionEvent OnErrorAction;
@@ -61,40 +62,44 @@ namespace Speckle.ConnectorUnity.Components
) )
throw new SpeckleException(error); throw new SpeckleException(error);
ServerTransport transport = new ServerTransport(client.Account, stream.id); using ServerTransport transport = new(client.Account, stream.id);
transport.CancellationToken = CancellationTokenSource.Token; transport.CancellationToken = CancellationTokenSource.Token;
return await SendDataAsync( return await SendDataAsync(
CancellationTokenSource.Token,
remoteTransport: transport, remoteTransport: transport,
data: data, data,
client: client, client,
branchName: branch.name, branch.id,
createCommit: createCommit, createCommit,
onProgressAction: dict => OnSendProgressAction.Invoke(dict), dict => OnSendProgressAction.Invoke(dict),
onErrorAction: (m, e) => OnErrorAction.Invoke(m, e) CancellationTokenSource.Token
); );
} }
/// <param name="remoteTransport">The transport to send to</param>
/// <param name="data">The data to send</param>
/// <param name="client">An authenticated Speckle Client</param>
/// <param name="branchId">The branch name or id</param>
/// <param name="createCommit">when <see langword="true"/> will call <see cref="Client.CommitCreate"/>, otherwise only the object data is sent</param>
/// <param name="onProgressAction">Called every progress tick of the <see cref="Operations.Send"/></param>
/// <param name="cancellationToken">Optional cancellation token</param>
/// <returns>The id (hash) of the object sent</returns>
public static async Task<string> SendDataAsync( public static async Task<string> SendDataAsync(
CancellationToken cancellationToken,
ServerTransport remoteTransport, ServerTransport remoteTransport,
Base data, Base data,
Client client, Client client,
string branchName, string branchId,
bool createCommit, bool createCommit,
Action<ConcurrentDictionary<string, int>>? onProgressAction = null, Action<ConcurrentDictionary<string, int>>? onProgressAction = null,
Action<string, Exception>? onErrorAction = null CancellationToken cancellationToken = default
) )
{ {
string res = await Operations.Send( string res = await Operations.Send(
data, data,
cancellationToken: cancellationToken, remoteTransport,
new List<ITransport> { remoteTransport }, true,
useDefaultCache: true, onProgressAction,
disposeTransports: true, cancellationToken
onProgressAction: onProgressAction,
onErrorAction: onErrorAction
); );
Analytics.TrackEvent( Analytics.TrackEvent(
@@ -115,15 +120,26 @@ namespace Speckle.ConnectorUnity.Components
string commitMessage = $"Sent {data.totalChildrenCount} objects from {unityVer}"; string commitMessage = $"Sent {data.totalChildrenCount} objects from {unityVer}";
string commitId = await CreateCommit( string commitId = await CreateCommit(
cancellationToken,
data, data,
client, client,
streamId, streamId,
branchName, branchId,
res, res,
commitMessage commitMessage,
cancellationToken
); );
string url = $"{client.ServerUrl}/streams/{streamId}/commits/{commitId}";
StreamWrapper sw =
new()
{
ServerUrl = client.ServerUrl,
StreamId = streamId,
BranchName = branchId,
CommitId = commitId,
};
sw.SetAccount(client.Account);
string url = sw.ToServerUri().GetLeftPart(UriPartial.Path);
Debug.Log($"Data successfully sent to <a href=\"{url}\">{url}</a>"); Debug.Log($"Data successfully sent to <a href=\"{url}\">{url}</a>");
} }
@@ -131,13 +147,13 @@ namespace Speckle.ConnectorUnity.Components
} }
public static async Task<string> CreateCommit( public static async Task<string> CreateCommit(
CancellationToken cancellationToken,
Base data, Base data,
Client client, Client client,
string streamId, string streamId,
string branchName, string branchName,
string objectId, string objectId,
string message string message,
CancellationToken cancellationToken
) )
{ {
string commitId = await client.CommitCreate( string commitId = await client.CommitCreate(
@@ -249,5 +265,28 @@ namespace Speckle.ConnectorUnity.Components
{ {
Initialise(); Initialise();
} }
[Obsolete("use other overload")]
public static async Task<string> SendDataAsync(
CancellationToken cancellationToken,
ServerTransport remoteTransport,
Base data,
Client client,
string branchName,
bool createCommit,
Action<ConcurrentDictionary<string, int>>? onProgressAction = null,
Action<string, Exception>? onErrorAction = null
)
{
return await SendDataAsync(
remoteTransport,
data,
client,
branchName,
createCommit,
onProgressAction,
cancellationToken
);
}
} }
} }
@@ -10,9 +10,7 @@ using UnityEngine.Rendering;
using Material = UnityEngine.Material; using Material = UnityEngine.Material;
using Mesh = UnityEngine.Mesh; using Mesh = UnityEngine.Mesh;
using SMesh = Objects.Geometry.Mesh; using SMesh = Objects.Geometry.Mesh;
using SColor = System.Drawing.Color;
using Transform = UnityEngine.Transform; using Transform = UnityEngine.Transform;
using STransform = Objects.Other.Transform;
#nullable enable #nullable enable
namespace Objects.Converter.Unity namespace Objects.Converter.Unity
@@ -8,7 +8,6 @@ using UnityEngine;
using Material = UnityEngine.Material; using Material = UnityEngine.Material;
using SMesh = Objects.Geometry.Mesh; using SMesh = Objects.Geometry.Mesh;
using SColor = System.Drawing.Color; using SColor = System.Drawing.Color;
using STransform = Objects.Other.Transform;
namespace Objects.Converter.Unity namespace Objects.Converter.Unity
{ {
@@ -76,7 +75,7 @@ namespace Objects.Converter.Unity
// 3. Otherwise, convert fresh! // 3. Otherwise, convert fresh!
string name = CoreUtils.GenerateObjectName(renderMaterial); string name = CoreUtils.GenerateObjectName(renderMaterial);
Color diffuse = renderMaterial.diffuse.ToUnityColor(); Color diffuse = renderMaterial.diffuse.ToUnityColor();
bool isOpaque = Math.Abs(renderMaterial.opacity - 1d) < Constants.Eps; bool isOpaque = Math.Abs(renderMaterial.opacity - 1d) < Constants.EPS;
Color color = new(diffuse.r, diffuse.g, diffuse.b, (float)renderMaterial.opacity); Color color = new(diffuse.r, diffuse.g, diffuse.b, (float)renderMaterial.opacity);
float metalic = (float)renderMaterial.metalness; float metalic = (float)renderMaterial.metalness;
float gloss = 1f - (float)renderMaterial.roughness; float gloss = 1f - (float)renderMaterial.roughness;
File diff suppressed because it is too large Load Diff
@@ -98,7 +98,7 @@ namespace Speckle.ConnectorUnity
yield return null; yield return null;
} }
private static Dispatcher _instance = null; private static Dispatcher _instance;
public static bool Exists() public static bool Exists()
{ {
@@ -1,6 +1,7 @@
#nullable enable #nullable enable
using System; using System;
using System.Collections; using System.Collections;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using UnityEngine; using UnityEngine;
using UnityEngine.Networking; using UnityEngine.Networking;
@@ -111,9 +112,9 @@ namespace Speckle.ConnectorUnity.Utils
public readonly Task Task; public readonly Task Task;
public override bool keepWaiting => !Task.IsCompleted; public override bool keepWaiting => !Task.IsCompleted;
public WaitForTask(Func<Task> function) public WaitForTask(Func<Task> function, CancellationToken cancellationToken = default)
{ {
Task = Task.Run(function); Task = Task.Run(function, cancellationToken);
} }
} }
@@ -124,9 +125,12 @@ namespace Speckle.ConnectorUnity.Utils
public TResult Result => Task.Result; public TResult Result => Task.Result;
public override bool keepWaiting => !Task.IsCompleted; public override bool keepWaiting => !Task.IsCompleted;
public WaitForTask(Func<Task<TResult>> function) public WaitForTask(
Func<Task<TResult>> function,
CancellationToken cancellationToken = default
)
{ {
this.Task = System.Threading.Tasks.Task.Run(function); this.Task = System.Threading.Tasks.Task.Run(function, cancellationToken);
} }
} }
} }
@@ -30,7 +30,7 @@ namespace Speckle.ConnectorUnity.Wrappers.Selection
if (value is null) if (value is null)
return null; return null;
return value.id + Crypt.Hash(value.serverInfo.url ?? ""); return value.id + Crypt.Md5(value.serverInfo.url ?? "", "X2");
} }
public override void RefreshOptions() public override void RefreshOptions()
@@ -1,6 +1,6 @@
{ {
"name": "systems.speckle.speckle-unity", "name": "systems.speckle.speckle-unity",
"version": "2.17.1", "version": "2.18.0-rc1",
"displayName": "Speckle Unity Connector", "displayName": "Speckle Unity Connector",
"description": "AEC Interoperability for Unity through Speckle", "description": "AEC Interoperability for Unity through Speckle",
"unity": "2021.1", "unity": "2021.1",
@@ -21,4 +21,4 @@
"email": "hello@speckle.systems", "email": "hello@speckle.systems",
"url": "https://speckle.systems" "url": "https://speckle.systems"
} }
} }
+2 -2
View File
@@ -1,2 +1,2 @@
m_EditorVersion: 2021.3.22f1 m_EditorVersion: 2021.3.30f1
m_EditorVersionWithRevision: 2021.3.22f1 (b6c551784ba3) m_EditorVersionWithRevision: 2021.3.30f1 (b4360d7cdac4)