コード例 #1
0
 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);
 }
コード例 #2
0
        private void SyncManager_InstanceAdded(SyncInstance instance)
        {
            _syncInstances.Add(instance);

            UpdateBounds();

            // Subscribing to Prefab Changed Event.
            instance.onPrefabChanged += Instance_PrefabChanged;
        }
コード例 #3
0
        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;
        }
コード例 #4
0
        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++;
            }
        }
コード例 #5
0
 private void Instance_PrefabChanged(SyncInstance instance, Unity.Reflect.Model.SyncPrefab prefab)
 {
     UpdateBounds();
 }
コード例 #6
0
    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);
    }
コード例 #7
0
 private void SyncManager_InstanceAdded(SyncInstance instance)
 {
     instance.onObjectCreated   += Instance_ObjectCreated;
     instance.onObjectDestroyed += Instance_ObjectDestroyed;
     _instances.Add(instance);
 }
コード例 #8
0
 /// <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);
 }
コード例 #9
0
 private void Instance_onPrefabChanged(SyncInstance instance, SyncPrefab prefab)
 {
     DebugLine("PREFAB CHANGED : {0}", "green", null, prefab.Name);
 }
コード例 #10
0
 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());
 }
コード例 #11
0
 private void SyncManager_InstanceAdded(SyncInstance instance)
 {
     instance.onPrefabLoaded  += Instance_PrefabLoaded;
     instance.onObjectCreated += Instance_ObjectCreated;
 }