// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved. using System.Net; using FlaxEditor.GUI.ContextMenu; using FlaxEditor.SceneGraph.GUI; using FlaxEngine; namespace FlaxEditor.SceneGraph.Actors { /// /// Actor tree node for objects. /// /// [HideInEditor] public sealed class SceneNode : ActorNode { private bool _isEdited; /// /// Gets or sets a value indicating whether this scene is edited. /// public bool IsEdited { get => _isEdited; set { if (_isEdited != value) { _isEdited = value; _treeNode.UpdateText(); } } } /// /// Gets the scene. /// public Scene Scene => _actor as Scene; /// /// Initializes a new instance of the class. /// /// The scene. public SceneNode(Scene scene) : base(scene, new SceneTreeNode()) { } /// public override bool CanCreatePrefab => false; /// public override bool CanCopyPaste => false; /// public override bool CanDuplicate => false; /// public override bool CanDelete => false; /// public override bool CanDrag => false; /// public override SceneNode ParentScene => this; /// public override void OnContextMenu(ContextMenu contextMenu) { contextMenu.AddSeparator(); contextMenu.AddButton("Save scene", OnSave).LinkTooltip("Saves this scene.").Enabled = IsEdited && !Editor.IsPlayMode; contextMenu.AddButton("Unload scene", OnUnload).LinkTooltip("Unloads this scene.").Enabled = Editor.Instance.StateMachine.CurrentState.CanChangeScene; base.OnContextMenu(contextMenu); } private void OnSave() { Editor.Instance.Scene.SaveScene(this); } private void OnUnload() { Editor.Instance.Scene.CloseScene(Scene); } } }