private void ClearSelectedObjectsAndGizmos() { Debug.Print("ClearSelectedObjectsAndGizmos entered ..."); Debug.Print("ClearSelectedObjectsAndGizmos - calling DisplayScene.SelectedSceneObjects.ResetGizmosAndMaterials ..."); DisplayScene.SelectedSceneObjects.ResetGizmosAndMaterials(); Debug.Print("ClearSelectedObjectsAndGizmos - calling DisplayScene.SelectedSceneObjects.Clear ... "); DisplayScene.SelectedSceneObjects.Clear(); //Using this event and passing null to inform the scenetree form that any previously selected node should be cleared (as nothing was hit and we've reset all gizmos and materials) Debug.Print("ClearSelectedObjectsAndGizmos - Invoking SceneNodeClicked..."); SceneNodeClicked?.Invoke(SceneObjectType.Node, null, false); Debug.Print("ClearSelectedObjectsAndGizmos - Calling SendResetPropertiesWindowMessage ..."); SendResetPropertiesWindowMessage(); Debug.Print("ClearSelectedObjectsAndGizmos - exiting"); }
public void CheckForSelection(Node hitNode, Drawable hitDrawable, bool treeViewSelection = false) { bool multipleSelect = true; BaseEntity baseEntity = null; if (Input.GetMouseButtonPress(MouseButton.Left)) { _treeviewNodeClicked = false; //if the node is null, we should remove all items from the list if (hitNode != null) { if (!hitNode.Name.Contains("wirePlane")) { if (hitNode.Components.Count > 0) { if (!hitNode.Name.ToLower().Contains("gizmo")) { //baseEntity from component baseEntity = hitNode.GetComponent <BaseEntity>(); if (baseEntity == null) { return; } } else { //baseEntity from gizmo (parent/parent/baseentity) var parent1 = hitNode.Parent; if (parent1 != null) { var parent2 = parent1.Parent; if (parent2 != null) { if (parent2.Components.Count > 0) { var parent2Gizmo = parent2.GetComponent <Gizmo>(); if (parent2Gizmo != null) { baseEntity = parent2Gizmo.BaseEntity; } } } } } } else { Debug.Print("CheckForSelection - Calling ClearSelectedObjectsAndGizmos because hitNode.Components.Count is zero..."); ClearSelectedObjectsAndGizmos(); return; } if (baseEntity != null) { if (!baseEntity.HasGizmo) { baseEntity.CreateGizmo(); } if (!baseEntity.IsSelected) { //if the user has pressed Shift button, then we need to add to the selected object list, otherwise //we should clear the list first if (!Input.GetKeyDown(Key.Shift)) { multipleSelect = false; DisplayScene.SelectedSceneObjects.ResetGizmosAndMaterials(); DisplayScene.SelectedSceneObjects.Clear(); SendResetPropertiesWindowMessage(); } if (!hitNode.Name.Contains("wirePlane")) { SelectedObject selectedObject = new SelectedObject { SelectedNode = hitNode, Drawable = hitDrawable }; if (baseEntity != null) { baseEntity.SetAsSelected(); //send a message to show the object properties PulsarMessage message = new PulsarMessage() { Type = PulsarMessage.MessageType.ShowObjectProperties, Iterations = 1 }; message.Properties.Add("sceneObjectType", GetSceneObjectType(hitNode)); message.Properties.Add("sceneObject", hitNode); message.Properties.Add("externallySet", false); if (message != null) { MessageQueue.PushMessage(message); } } SceneNodeClicked?.Invoke(SceneObjectType.Node, hitNode, multipleSelect); DisplayScene.SelectedSceneObjects.AddSelectedObject(selectedObject); } } } else { Debug.Print("CheckForSelection - baseEntity was NULL!"); } } else { Debug.Print("CheckForSelection - Calling ClearSelectedObjectsAndGizmos because hitNode was the wirePlane..."); ClearSelectedObjectsAndGizmos(); } } else { Debug.Print("CheckForSelection - Calling ClearSelectedObjectsAndGizmos because hitNode was null..."); ClearSelectedObjectsAndGizmos(); } } }
public void CheckForSelection(Node hitNode, Drawable hitDrawable, bool treeViewSelection = false) { bool multipleSelect = true; BaseEntity baseEntity = null; if (Input.GetMouseButtonPress(MouseButton.Left)) { _treeviewNodeClicked = false; //if the node is null, we should remove all items from the list if (hitNode != null) { if (!hitNode.Name.Contains("wirePlane")) { if (hitNode.Components.Count > 0) { if (!hitNode.Name.ToLower().Contains("gizmo")) { //baseEntity from component baseEntity = hitNode.GetComponent <BaseEntity>(); if (baseEntity == null) { return; } } else { //baseEntity from gizmo (parent/parent/baseentity) var parent1 = hitNode.Parent; if (parent1 != null) { var parent2 = parent1.Parent; if (parent2 != null) { if (parent2.Components.Count > 0) { var parent2Gizmo = parent2.GetComponent <Gizmo>(); if (parent2Gizmo != null) { baseEntity = parent2Gizmo.BaseEntity; } } } } } } else { return; } if (baseEntity != null) { if (!baseEntity.IsSelected) { //if the user has pressed Shift button, then we need to add to the selected object list, otherwise //we should clear the list first if (!Input.GetKeyDown(Key.Shift)) { multipleSelect = false; DisplayScene.SelectedSceneObjects.ResetGizmosAndMaterials(); DisplayScene.SelectedSceneObjects.Clear(); SendResetPropertiesWindowMessage(); } if (!hitNode.Name.Contains("wirePlane")) { SelectedObject selectedObject = new SelectedObject { SelectedNode = hitNode, Drawable = hitDrawable }; if (baseEntity != null) { baseEntity.SetAsSelected(); //send a message to show the object properties PulsarMessage message = new PulsarMessage() { Type = PulsarMessage.MessageType.ShowObjectProperties, Iterations = 1 }; message.Properties.Add("sceneObjectType", GetSceneObjectType(hitNode)); message.Properties.Add("sceneObject", hitNode); message.Properties.Add("externallySet", false); if (message != null) { MessageQueue.PushMessage(message); } } SceneNodeClicked?.Invoke(SceneObjectType.Node, hitNode, multipleSelect); DisplayScene.SelectedSceneObjects.AddSelectedObject(selectedObject); } } } } else { DisplayScene.SelectedSceneObjects.ResetGizmosAndMaterials(); DisplayScene.SelectedSceneObjects.Clear(); //Using this event and passing null to inform the scenetree form that any previously selected node should be cleared (as wirePanel was hit and we've reset all gizmos and materials) SceneNodeClicked?.Invoke(SceneObjectType.Node, null, false); //Send message to properties window to clear its display SendResetPropertiesWindowMessage(); } } else { DisplayScene.SelectedSceneObjects.ResetGizmosAndMaterials(); DisplayScene.SelectedSceneObjects.Clear(); //Using this event and passing null to inform the scenetree form that any previously selected node should be cleared (as nothing was hit and we've reset all gizmos and materials) SceneNodeClicked?.Invoke(SceneObjectType.Node, null, false); SendResetPropertiesWindowMessage(); } } }