public CInspectorEntityComponentViewModel(IInspectorViewModel viewModel, string name, SEntityComponentId componentId) : base(viewModel, name) { ComponentId = componentId; DeleteComponentCommand = new CRelayCommand(arg => { EditorEntityUtility.DestroyComponent(ComponentId); m_viewModel.QueueEntityInformationUpdate(ComponentId.EntityId, true); }); }
private void OnKeyDown(object e) { KeyEventArgs args = (KeyEventArgs)e; if (IsActive && args.Key == Key.Delete) { var outliner = CWorkspace.Instance.GetTool <CWorldOutlinerViewModel>(); if (outliner.SelectedEntityViewModel != null) { EditorEntityUtility.DestroyEntity(outliner.SelectedEntityViewModel.EntityId); } } }
public CInspectorViewModel() : base("Inspector") { SetIconSourcePath("Resources/Images/Tabs/inspector.png"); Content = new Inspector(); m_view = Content as IInspectorView; InitializeEntityMenues(); RenameEntityCommand = new CRelayCommand(InternalRenameEntity); AddComponentCommand = new CRelayCommand(InternalAddComponent); ToggleAddComponentMenuCommand = new CRelayCommand((obj) => AddComponentMenuOpen = !AddComponentMenuOpen); ToggleEntityCommandsMenuCommand = new CRelayCommand((obj) => EntityCommandsMenuOpen = !EntityCommandsMenuOpen); CWorkspace.Instance.OnSelectedEditableObjectChanged += (oldObj, newObj) => { m_view?.ClearInspector(); m_view?.LockInspector(true); if (newObj != null) { m_view.SetInspectorVisible(true); switch (newObj.Type) { case CEditableObject.EObjectType.Entity: InspectEntity(newObj.EntityId); if (oldObj?.GetTargetEntityId() != newObj?.GetTargetEntityId()) { QueueEntityInformationUpdate(newObj.GetTargetEntityId(), true); } EditorEntityUtility.PickRootComponent(newObj.EntityId); break; case CEditableObject.EObjectType.Component: InspectComponent(newObj.ComponentId); break; } } else { m_view?.SetInspectorVisible(false); Reset(); EditorEntityUtility.PickComponent(SEntityComponentId.Invalid); } }; }
public CWorldOutlinerViewModel() : base("World Outliner") { SetIconSourcePath("Resources/Images/Tabs/outliner.png"); Content = new WorldOutliner(); m_view = Content as IOutlinerView; CWorkspace.Instance.OnSelectedEditableObjectChanged += (oldObj, newObj) => { if (newObj != null) { switch (newObj.Type) { case CEditableObject.EObjectType.Entity: HighlightEntity(newObj.EntityId); break; case CEditableObject.EObjectType.Component: HighlightEntity(newObj.ComponentId.EntityId); break; } } else { SelectedEntityViewModel?.MarkInOutliner(false); } }; KeyDownCommand = new CRelayCommand(param => { KeyEventArgs args = (KeyEventArgs)param; if (IsActive && args.Key == Key.Delete) { if (SelectedEntityViewModel != null) { EditorEntityUtility.DestroyEntity(SelectedEntityViewModel.EntityId); } } }); }
private void OnDeleteCommand(object arg) { EditorEntityUtility.DestroyEntity(EntityId); }
private void OnDetachCommand(object argument) { EditorEntityUtility.DetachEntityFromAllParents(EntityId); }
protected virtual void OnMakeRoot(object argument) { EditorEntityUtility.MakeComponentRoot(ComponentId); m_viewModel.QueueEntityInformationUpdate(ComponentId.EntityId, true); }
protected virtual void OnDeleteComponent(object argument) { EditorEntityUtility.DestroyComponent(ComponentId); m_viewModel.QueueEntityInformationUpdate(ComponentId.EntityId, true); }