/// <summary> /// Creates new editor scene data. /// </summary> /// <param name="root">Root object of the scene to create editor scene data for.</param> /// <returns>New editor scene data object, initialized with the hierarchy of the provided scene.</returns> public static EditorSceneData FromScene(SceneObject root) { EditorSceneData output = new EditorSceneData(); output.Root = EditorSceneObject.FromSceneObject(root); return(output); }
/// <summary> /// Loads hierarchy state from the stored scene data. /// </summary> /// <param name="sceneData">Scene data to restore the hierarcy state from.</param> internal void LoadHierarchyState(EditorSceneData sceneData) { SceneTreeViewState state = treeView.State; Dictionary <UUID, EditorSceneObject> lookup = sceneData.GetLookup(); SceneTreeViewElement[] elements = state.Elements; for (int i = 0; i < elements.Length; i++) { if (lookup.TryGetValue(elements[i].sceneObject.UUID, out EditorSceneObject editorSO)) { elements[i].isExpanded = editorSO.IsExpanded; } } state.Elements = elements; treeView.State = state; }
/// <summary> /// Updates the scene data with data from the hierarchy view. /// </summary> /// <param name="sceneData">Scene data to append hierarchy state to.</param> internal void SaveHierarchyState(EditorSceneData sceneData) { if (treeView == null) { return; } SceneTreeViewState state = treeView.State; Dictionary <UUID, EditorSceneObject> lookup = sceneData.GetLookup(); foreach (var entry in state.Elements) { if (lookup.TryGetValue(entry.sceneObject.UUID, out EditorSceneObject editorSO)) { editorSO.IsExpanded = entry.isExpanded; } } }