private void SyncManager_InstanceAdded(SyncInstance instance) { //Debug.Log("<color=yellow>New instance added.</color>"); instance.onObjectCreated += Instance_ObjectCreated; instance.onObjectDestroyed += Instance_ObjectDestroyed; _instances.Add(instance); }
private void SyncManager_InstanceAdded(SyncInstance instance) { _syncInstances.Add(instance); UpdateBounds(); // Subscribing to Prefab Changed Event. instance.onPrefabChanged += Instance_PrefabChanged; }
private void SyncManager_onInstanceAdded(SyncInstance instance) { //foreach (PersistentKey k in instance.Manifest.Content.Keys) // DebugLine("Manifest Key : name: {0}, typeName: {1}", "gray", null, k.name, k.typeName); //foreach (ManifestEntry m in instance.Manifest.Content.Values) // DebugLine("Manifest Content : {0}", "gray", null, m.DstPath); DebugLine("INSTANCE ADDED.", "green"); instance.onObjectCreated += Instance_onObjectCreated; instance.onObjectDestroyed += Instance_onObjectDestroyed; instance.onPrefabLoaded += Instance_onPrefabLoaded; instance.onPrefabChanged += Instance_onPrefabChanged; }
private void Instance_PrefabLoaded(SyncInstance instance, SyncPrefab prefab) { foreach (SyncObjectInstance syncObjectInstance in prefab.Instances) { //Debug.LogFormat("<color=cyan>{0}</color>", syncObjectInstance.Id.Value); if (_syncIDs.Contains(syncObjectInstance.Id.Value)) { continue; } _syncIDs.Add(syncObjectInstance.Id.Value); _totalNumberOfSyncObjects++; } }
private void Instance_PrefabChanged(SyncInstance instance, Unity.Reflect.Model.SyncPrefab prefab) { UpdateBounds(); }
async Task DownloadManifestDiff(IPlayerClient client, SyncManifest oldManifest, SyncManifest newManifest, UnityProject project, string sourceId, PlayerStorage storage) { List <ManifestEntry> entries; if (oldManifest == null) { var content = newManifest.Content; entries = content.Values.ToList(); } else { ParseManifest(oldManifest.Content, newManifest.Content, out var modified, out var deleted); entries = modified.ToList(); // TODO Handle deleted models } var destinationFolder = storage.GetSourceProjectFolder(project, sourceId); var downloadFolder = Path.Combine(destinationFolder, k_TemporaryFolder); var progress = new ProjectManagerInternal.DownloadProgress(); progress.SetTotal(entries.Count); var tasks = entries.Select(entry => ProjectManagerInternal.DownloadAndStore(client, sourceId, entry, newManifest, downloadFolder, progress)).ToList(); // Don't forget the manifest itself tasks.Add(ProjectManagerInternal.RunFileIOOperation(() => { newManifest.EditorSave(downloadFolder); return(Task.CompletedTask); })); // Wait for all download to finish var task = Task.WhenAll(tasks); while (!task.IsCompleted) { lock (m_ProgressLock) { m_Progress = progress.percent; } await Task.Delay(200); } // TODO Handle errors in the DownloadProgress // Backward compatibility with local viewer cache that have SyncPrefab as a file. var prefabPath = SyncInstance.GetPrefabPath(downloadFolder); if (prefabPath == null) { var prefabName = sourceId + SyncPrefab.Extension; var syncPrefab = SyncInstance.GenerateSyncPrefabFromManifest(prefabName, downloadFolder, newManifest); var fullPath = Path.Combine(downloadFolder, prefabName); PlayerFile.Save(syncPrefab, fullPath); } // Delete SyncInstances since they cannot be imported var instancesFolder = Path.Combine(downloadFolder, "instances"); if (Directory.Exists(instancesFolder)) { Directory.Delete(instancesFolder, true); } // Move all content from temporary download folder to the final destination MoveDirectory(downloadFolder, destinationFolder); }
private void SyncManager_InstanceAdded(SyncInstance instance) { instance.onObjectCreated += Instance_ObjectCreated; instance.onObjectDestroyed += Instance_ObjectDestroyed; _instances.Add(instance); }
/// <summary> /// Grows the Bounds to fit the SyncInstance BoundingBoxes /// </summary> /// <param name="bounds"></param> /// <param name="syncInstance"></param> public static void Encapsulate(this Bounds bounds, SyncInstance syncInstance) { bounds.Encapsulate(syncInstance.Manifest); }
private void Instance_onPrefabChanged(SyncInstance instance, SyncPrefab prefab) { DebugLine("PREFAB CHANGED : {0}", "green", null, prefab.Name); }
private void Instance_onPrefabLoaded(SyncInstance instance, SyncPrefab prefab) { DebugLine("PREFAB LOADED. Name : {0}, Id : {1}, Instance(s) Count : {2}", "green", null, prefab?.Name, prefab?.Id.Value.ToString(), prefab?.Instances.Count.ToString()); }
private void SyncManager_InstanceAdded(SyncInstance instance) { instance.onPrefabLoaded += Instance_PrefabLoaded; instance.onObjectCreated += Instance_ObjectCreated; }