Re-added commit creation when sending.
Also replaced ParallelExtensionsExtras.dll with source file for cross platform building
This commit is contained in:
@@ -256,7 +256,6 @@ namespace Objects.Converter.Unity
|
||||
/// </summary>
|
||||
/// <param name="element">The <see cref="Base"/> element from which properties should be grabbed from</param>
|
||||
/// <param name="meshes">Collection of <see cref="Objects.Geometry.Mesh"/>es that shall be converted</param>
|
||||
/// <param name="properties">If provided, will override the properties on the mesh itself</param>
|
||||
/// <returns>A <see cref="GameObject"/> with the converted <see cref="UnityEngine.Mesh"/>, <see cref="MeshFilter"/>, and <see cref="MeshRenderer"/></returns>
|
||||
public GameObject MeshesToNative(Base element, IReadOnlyCollection<Mesh> meshes)
|
||||
{
|
||||
@@ -292,7 +291,6 @@ namespace Objects.Converter.Unity
|
||||
/// Converts <paramref name="speckleMesh"/> to a <see cref="GameObject"/> with a <see cref="MeshRenderer"/>
|
||||
/// </summary>
|
||||
/// <param name="speckleMesh">Mesh to convert</param>
|
||||
/// <param name="properties">If provided, will override the properties on the mesh itself</param>
|
||||
/// <returns></returns>
|
||||
public GameObject MeshToNative(Mesh speckleMesh)
|
||||
{
|
||||
|
||||
@@ -1,15 +1,8 @@
|
||||
using Objects.Geometry;
|
||||
using Speckle.Core.Kits;
|
||||
using Speckle.Core.Kits;
|
||||
using Speckle.Core.Models;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using JetBrains.Annotations;
|
||||
using Objects.BuiltElements;
|
||||
using Unity.Plastic.Antlr3.Runtime.Debug;
|
||||
using UnityEngine;
|
||||
using Mesh = Objects.Geometry.Mesh;
|
||||
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6f8fe4d403d6524498fe19d6a1f1e136
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+199
@@ -0,0 +1,199 @@
|
||||
//--------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
// File: ObservableConcurrentDictionary.cs
|
||||
//
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.ComponentModel;
|
||||
using System.Threading;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace System.Collections.Concurrent
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides a thread-safe dictionary for use with data binding.
|
||||
/// </summary>
|
||||
/// <typeparam name="TKey">Specifies the type of the keys in this collection.</typeparam>
|
||||
/// <typeparam name="TValue">Specifies the type of the values in this collection.</typeparam>
|
||||
[DebuggerDisplay("Count={Count}")]
|
||||
public class ObservableConcurrentDictionary<TKey, TValue> :
|
||||
ICollection<KeyValuePair<TKey, TValue>>, IDictionary<TKey, TValue>,
|
||||
INotifyCollectionChanged, INotifyPropertyChanged
|
||||
{
|
||||
private readonly SynchronizationContext _context;
|
||||
private readonly ConcurrentDictionary<TKey, TValue> _dictionary;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes an instance of the ObservableConcurrentDictionary class.
|
||||
/// </summary>
|
||||
public ObservableConcurrentDictionary()
|
||||
{
|
||||
_context = AsyncOperationManager.SynchronizationContext;
|
||||
_dictionary = new ConcurrentDictionary<TKey, TValue>();
|
||||
}
|
||||
|
||||
/// <summary>Event raised when the collection changes.</summary>
|
||||
public event NotifyCollectionChangedEventHandler CollectionChanged;
|
||||
/// <summary>Event raised when a property on the collection changes.</summary>
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Notifies observers of CollectionChanged or PropertyChanged of an update to the dictionary.
|
||||
/// </summary>
|
||||
private void NotifyObserversOfChange()
|
||||
{
|
||||
var collectionHandler = CollectionChanged;
|
||||
var propertyHandler = PropertyChanged;
|
||||
if (collectionHandler != null || propertyHandler != null)
|
||||
{
|
||||
_context.Post(s =>
|
||||
{
|
||||
if (collectionHandler != null)
|
||||
{
|
||||
collectionHandler(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
|
||||
}
|
||||
if (propertyHandler != null)
|
||||
{
|
||||
propertyHandler(this, new PropertyChangedEventArgs("Count"));
|
||||
propertyHandler(this, new PropertyChangedEventArgs("Keys"));
|
||||
propertyHandler(this, new PropertyChangedEventArgs("Values"));
|
||||
}
|
||||
}, null);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Attempts to add an item to the dictionary, notifying observers of any changes.</summary>
|
||||
/// <param name="item">The item to be added.</param>
|
||||
/// <returns>Whether the add was successful.</returns>
|
||||
private bool TryAddWithNotification(KeyValuePair<TKey, TValue> item)
|
||||
{
|
||||
return TryAddWithNotification(item.Key, item.Value);
|
||||
}
|
||||
|
||||
/// <summary>Attempts to add an item to the dictionary, notifying observers of any changes.</summary>
|
||||
/// <param name="key">The key of the item to be added.</param>
|
||||
/// <param name="value">The value of the item to be added.</param>
|
||||
/// <returns>Whether the add was successful.</returns>
|
||||
private bool TryAddWithNotification(TKey key, TValue value)
|
||||
{
|
||||
bool result = _dictionary.TryAdd(key, value);
|
||||
if (result) NotifyObserversOfChange();
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>Attempts to remove an item from the dictionary, notifying observers of any changes.</summary>
|
||||
/// <param name="key">The key of the item to be removed.</param>
|
||||
/// <param name="value">The value of the item removed.</param>
|
||||
/// <returns>Whether the removal was successful.</returns>
|
||||
private bool TryRemoveWithNotification(TKey key, out TValue value)
|
||||
{
|
||||
bool result = _dictionary.TryRemove(key, out value);
|
||||
if (result) NotifyObserversOfChange();
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>Attempts to add or update an item in the dictionary, notifying observers of any changes.</summary>
|
||||
/// <param name="key">The key of the item to be updated.</param>
|
||||
/// <param name="value">The new value to set for the item.</param>
|
||||
/// <returns>Whether the update was successful.</returns>
|
||||
private void UpdateWithNotification(TKey key, TValue value)
|
||||
{
|
||||
_dictionary[key] = value;
|
||||
NotifyObserversOfChange();
|
||||
}
|
||||
|
||||
#region ICollection<KeyValuePair<TKey,TValue>> Members
|
||||
void ICollection<KeyValuePair<TKey, TValue>>.Add(KeyValuePair<TKey, TValue> item)
|
||||
{
|
||||
TryAddWithNotification(item);
|
||||
}
|
||||
|
||||
void ICollection<KeyValuePair<TKey, TValue>>.Clear()
|
||||
{
|
||||
((ICollection<KeyValuePair<TKey, TValue>>)_dictionary).Clear();
|
||||
NotifyObserversOfChange();
|
||||
}
|
||||
|
||||
bool ICollection<KeyValuePair<TKey, TValue>>.Contains(KeyValuePair<TKey, TValue> item)
|
||||
{
|
||||
return ((ICollection<KeyValuePair<TKey, TValue>>)_dictionary).Contains(item);
|
||||
}
|
||||
|
||||
void ICollection<KeyValuePair<TKey, TValue>>.CopyTo(KeyValuePair<TKey, TValue>[] array, int arrayIndex)
|
||||
{
|
||||
((ICollection<KeyValuePair<TKey, TValue>>)_dictionary).CopyTo(array, arrayIndex);
|
||||
}
|
||||
|
||||
int ICollection<KeyValuePair<TKey, TValue>>.Count
|
||||
{
|
||||
get { return ((ICollection<KeyValuePair<TKey, TValue>>)_dictionary).Count; }
|
||||
}
|
||||
|
||||
bool ICollection<KeyValuePair<TKey, TValue>>.IsReadOnly
|
||||
{
|
||||
get { return ((ICollection<KeyValuePair<TKey, TValue>>)_dictionary).IsReadOnly; }
|
||||
}
|
||||
|
||||
bool ICollection<KeyValuePair<TKey, TValue>>.Remove(KeyValuePair<TKey, TValue> item)
|
||||
{
|
||||
TValue temp;
|
||||
return TryRemoveWithNotification(item.Key, out temp);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IEnumerable<KeyValuePair<TKey,TValue>> Members
|
||||
IEnumerator<KeyValuePair<TKey, TValue>> IEnumerable<KeyValuePair<TKey, TValue>>.GetEnumerator()
|
||||
{
|
||||
return ((ICollection<KeyValuePair<TKey, TValue>>)_dictionary).GetEnumerator();
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return ((ICollection<KeyValuePair<TKey, TValue>>)_dictionary).GetEnumerator();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IDictionary<TKey,TValue> Members
|
||||
public void Add(TKey key, TValue value)
|
||||
{
|
||||
TryAddWithNotification(key, value);
|
||||
}
|
||||
|
||||
public bool ContainsKey(TKey key)
|
||||
{
|
||||
return _dictionary.ContainsKey(key);
|
||||
}
|
||||
|
||||
public ICollection<TKey> Keys
|
||||
{
|
||||
get { return _dictionary.Keys; }
|
||||
}
|
||||
|
||||
public bool Remove(TKey key)
|
||||
{
|
||||
TValue temp;
|
||||
return TryRemoveWithNotification(key, out temp);
|
||||
}
|
||||
|
||||
public bool TryGetValue(TKey key, out TValue value)
|
||||
{
|
||||
return _dictionary.TryGetValue(key, out value);
|
||||
}
|
||||
|
||||
public ICollection<TValue> Values
|
||||
{
|
||||
get { return _dictionary.Values; }
|
||||
}
|
||||
|
||||
public TValue this[TKey key]
|
||||
{
|
||||
get { return _dictionary[key]; }
|
||||
set { UpdateWithNotification(key, value); }
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fbc4646478df067419b8bc7844c0ebfd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "Speckle.ParallelExtensionsExtras",
|
||||
"rootNamespace": "",
|
||||
"references": [],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": true
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 24f666972ea7e9149abddaae766b9c1d
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Binary file not shown.
-33
@@ -1,33 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0706f206487a18346b0a60f8be817381
|
||||
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:
|
||||
@@ -25,19 +25,25 @@ namespace Speckle.ConnectorUnity
|
||||
public class Sender : MonoBehaviour
|
||||
{
|
||||
|
||||
private ServerTransport trasnport;
|
||||
|
||||
private ServerTransport transport;
|
||||
|
||||
/// <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="branchName">Name of branch to send to</param>
|
||||
/// <param name="createCommit">When true, will create a commit using the root object</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,
|
||||
public void Send(string streamId,
|
||||
List<GameObject> gameObjects,
|
||||
Account account = null,
|
||||
string branchName = "main",
|
||||
bool createCommit = true,
|
||||
Action<string> onDataSentAction = null,
|
||||
Action<ConcurrentDictionary<string, int>> onProgressAction = null,
|
||||
Action<string, Exception> onErrorAction = null)
|
||||
@@ -45,21 +51,36 @@ namespace Speckle.ConnectorUnity
|
||||
try
|
||||
{
|
||||
var data = ConvertRecursivelyToSpeckle(gameObjects);
|
||||
|
||||
trasnport = new ServerTransport(account ?? AccountManager.GetDefaultAccount() , streamId);
|
||||
|
||||
var client = new Client(account ?? AccountManager.GetDefaultAccount());
|
||||
transport = new ServerTransport(client.Account, streamId);
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
var res = await Operations.Send(
|
||||
data,
|
||||
new List<ITransport>() { trasnport },
|
||||
new List<ITransport>() { transport },
|
||||
useDefaultCache: true,
|
||||
disposeTransports: true,
|
||||
onProgressAction: onProgressAction,
|
||||
onProgressAction: onProgressAction,
|
||||
onErrorAction: onErrorAction
|
||||
);
|
||||
|
||||
trasnport?.Dispose();
|
||||
Analytics.TrackEvent(client.Account, Analytics.Events.Send);
|
||||
|
||||
if (createCommit)
|
||||
{
|
||||
await client.CommitCreate(
|
||||
new CommitCreateInput
|
||||
{
|
||||
streamId = streamId,
|
||||
branchName = branchName,
|
||||
objectId = res,
|
||||
message = "No message",
|
||||
sourceApplication = VersionedHostApplications.Unity,
|
||||
});
|
||||
}
|
||||
|
||||
transport?.Dispose();
|
||||
onDataSentAction?.Invoke(res);
|
||||
});
|
||||
}
|
||||
@@ -71,7 +92,7 @@ namespace Speckle.ConnectorUnity
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
trasnport?.Dispose();
|
||||
transport?.Dispose();
|
||||
}
|
||||
|
||||
#region private methods
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
{
|
||||
"name": "Speckle.Connector"
|
||||
"name": "Speckle.Connector",
|
||||
"references":[ "GUID:24f666972ea7e9149abddaae766b9c1d" ]
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ UnityConnectSettings:
|
||||
m_EventOldUrl: https://api.uca.cloud.unity3d.com/v1/events
|
||||
m_EventUrl: https://cdp.cloud.unity3d.com/v1/events
|
||||
m_ConfigUrl: https://config.uca.cloud.unity3d.com
|
||||
m_DashboardUrl: https://dashboard.unity3d.com
|
||||
m_TestInitMode: 0
|
||||
CrashReportingSettings:
|
||||
m_EventUrl: https://perf-events.cloud.unity3d.com
|
||||
|
||||
Reference in New Issue
Block a user