From ad43e4ff6d4eb47c1bc14b49834fd680edc812c1 Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Tue, 16 Feb 2016 12:56:34 -0800 Subject: [PATCH] Fixed multiple particle tabs appearing --- examples/edit.js | 12 ++++++++---- examples/particle_explorer/particleExplorerTool.js | 4 ++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/examples/edit.js b/examples/edit.js index c0037d1212..9321c130c0 100644 --- a/examples/edit.js +++ b/examples/edit.js @@ -1260,6 +1260,7 @@ function selectAllEtitiesInCurrentSelectionBox(keepIfTouching) { function deleteSelectedEntities() { if (SelectionManager.hasSelection()) { + selectedParticleEntity = 0; particleExplorerTool.destroyWebView(); SelectionManager.saveProperties(); var savedProperties = []; @@ -1888,17 +1889,19 @@ entityListTool.webView.eventBridge.webEventReceived.connect(function(data) { var ids = data.entityIds; if(ids.length === 1) { if (Entities.getEntityProperties(ids[0], "type").type === "ParticleEffect" ) { - if (JSON.stringify(selectedParticleEntity) !== JSON.stringify(ids[0])) { - // We already had a particle entity selected, so destroy that one and create the new one - particleExplorerTool.destroyWebView(); + if (JSON.stringify(selectedParticleEntity) === JSON.stringify(ids[0])) { + // This particle entity is already selected, so return + return; } - // Now we want to activate the partice explorer panel! + // Destroy the old particles web view first + particleExplorerTool.destroyWebView(); particleExplorerTool.createWebView(); var properties = Entities.getEntityProperties(ids[0]); var particleData = { messageType: "particle_settings", currentProperties: properties }; + selectedParticleEntity = ids[0]; particleExplorerTool.setActiveParticleEntity(ids[0]); particleExplorerTool.webView.eventBridge.webEventReceived.connect(function(data) { @@ -1908,6 +1911,7 @@ entityListTool.webView.eventBridge.webEventReceived.connect(function(data) { } }); } else { + selectedParticleEntity = 0; particleExplorerTool.destroyWebView(); } } diff --git a/examples/particle_explorer/particleExplorerTool.js b/examples/particle_explorer/particleExplorerTool.js index 03979b6cfa..20dfa6f1ba 100644 --- a/examples/particle_explorer/particleExplorerTool.js +++ b/examples/particle_explorer/particleExplorerTool.js @@ -32,10 +32,14 @@ ParticleExplorerTool = function() { that.destroyWebView = function() { if (!that.webView) { + print("EBL CAN'ZT CLOSE WEB VIEW- IT DOESNT EXISTS!") return; } + + print("EBL CLOSING WEB VIEW") that.webView.close(); that.webView = null; + that.activeParticleEntity = 0; } that.webEventReceived = function(data) {