Skip to content

Commit

Permalink
feat(wdb): import wdb should dispose inspector canvas gameObject
Browse files Browse the repository at this point in the history
  • Loading branch information
AmyOrz committed Apr 16, 2019
1 parent 29ddbef commit 07e54bf
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -609,11 +609,11 @@ module AssetTree = {
(editorState, engineState),
);

let (editorState, engineState) =
let (editorState, engineState, inspectorEngineState) =
extractedMaterialAssetDataArr
|> WonderCommonlib.ArrayService.reduceOneParam(
(.
(editorState, engineState),
(editorState, engineState, inspectorEngineState),
((material, materialType), (getNameFunc, setNameFunc)),
) => {
let materialName =
Expand Down Expand Up @@ -643,14 +643,15 @@ module AssetTree = {
editorState,
);

(editorState, StateInspectorEngineService.unsafeGetState())
|> AssetTreeInspectorUtils.disposeContainerGameObjectAllChildren
|> MaterialInspectorEngineUtils.createMaterialSphereIntoInspectorCanvas(
MaterialDataAssetType.LightMaterial,
material,
(editorState, engineState),
)
|> StateLogicService.refreshInspectorEngineState;
let inspectorEngineState =
(editorState, inspectorEngineState)
|> AssetTreeInspectorUtils.disposeContainerGameObjectAllChildren
|> MaterialInspectorEngineUtils.createMaterialSphereIntoInspectorCanvas(
MaterialDataAssetType.LightMaterial,
material,
(editorState, engineState),
)
|> DirectorEngineService.loopBody(0.);

let editorState =
editorState
Expand Down Expand Up @@ -679,15 +680,18 @@ module AssetTree = {
newNodeId,
);

(editorState, engineState);
(editorState, engineState, inspectorEngineState);
},
(editorState, engineState),
(
editorState,
engineState,
StateInspectorEngineService.unsafeGetState(),
),
);

(editorState, StateInspectorEngineService.unsafeGetState())
(editorState, inspectorEngineState)
|> AssetTreeInspectorUtils.disposeContainerGameObjectAllChildren
|> StateInspectorEngineService.setState
|> ignore;
|> StateInspectorEngineService.setState;

(editorState, engineState);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ let fileLoad = ((uiState, dispatchFunc), createJsZipFunc, event) => {
FileReader.makeSureCanLoadSameNameFileAgain(target);

dispatchFunc(
AppStore.UpdateAction(Update([|UpdateStore.Project|])),
AppStore.UpdateAction(Update([|UpdateStore.Inspector,UpdateStore.Project|])),
);

resolve();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
module Method = {
let didMount = () => AssetTreeInspectorUtils.showInspectorCanvas();
let didMount = () => {
Js.log("wdb did mount");
let state = StateInspectorEngineService.unsafeGetState();

let game = state |> SceneEngineService.getSceneGameObject;

state |> HierarchyGameObjectEngineService.getAllChildren(game) |> Js.log;

AssetTreeInspectorUtils.showInspectorCanvas();
};

let willUnmount = AssetTreeInspectorUtils.hideInspectorCanvasAndDisposeContainerGameObjectAllChildren;
};
Expand Down

0 comments on commit 07e54bf

Please sign in to comment.