/// <inheritdoc/> protected internal override void PreInput() { Matrix4 transform = volume.SceneObject.WorldTransform; probeInfos = volume.GetProbes(); for (int i = 0; i < probeInfos.Length; i++) { if (i == nodeColliders.Count) { nodeColliders.Add(new HandleSliderSphere(this, 1.0f, false)); } Vector3 position = probeInfos[i].position; position = transform.MultiplyAffine(position); nodeColliders[i].Position = position; } while (nodeColliders.Count > probeInfos.Length) { nodeColliders[nodeColliders.Count - 1].Destroy(); nodeColliders.RemoveAt(nodeColliders.Count - 1); } if (selectedNode != uint.MaxValue) { if (moveHandle == null) { moveHandle = new MoveHandle(); } Vector3 position = Vector3.Zero; for (int i = 0; i < probeInfos.Length; i++) { if (probeInfos[i].handle == selectedNode) { position = transform.MultiplyAffine(probeInfos[i].position); break; } } moveHandle.Position = position; moveHandle.PreInput(); } }
/// <inheritdoc/> protected internal override void PostInput() { if (activeHandle != null) { if (activeHandle.IsDragged()) { if (!isDragged) { isDragged = true; SceneObject[] selectedSceneObjects = Selection.SceneObjects; activeSelection = new HandledObject[selectedSceneObjects.Length]; for (int i = 0; i < selectedSceneObjects.Length; i++) { activeSelection[i] = new HandledObject(selectedSceneObjects[i]); } initialHandlePosition = activeHandle.Position; initialHandleRotation = activeHandle.Rotation; } } else { isDragged = false; activeSelection = null; } activeHandle.PostInput(); if (activeHandle.IsDragged()) { switch (activeHandleType) { case SceneViewTool.Move: MoveHandle moveHandle = (MoveHandle)activeHandle; foreach (var selectedObj in activeSelection) { selectedObj.so.LocalPosition = selectedObj.initialPosition + moveHandle.Delta; } break; case SceneViewTool.Rotate: { RotateHandle rotateHandle = (RotateHandle)activeHandle; // Make sure we transform relative to the handle position SceneObject temporarySO = new SceneObject("Temp"); temporarySO.Position = initialHandlePosition; temporarySO.LocalRotation = initialHandleRotation; SceneObject[] originalParents = new SceneObject[activeSelection.Length]; for (int i = 0; i < activeSelection.Length; i++) { originalParents[i] = activeSelection[i].so.Parent; activeSelection[i].so.LocalPosition = activeSelection[i].initialPosition; activeSelection[i].so.LocalRotation = activeSelection[i].initialRotation; activeSelection[i].so.Parent = temporarySO; } temporarySO.LocalRotation *= rotateHandle.Delta; for (int i = 0; i < activeSelection.Length; i++) { activeSelection[i].so.Parent = originalParents[i]; } temporarySO.Destroy(); } break; case SceneViewTool.Scale: { ScaleHandle scaleHandle = (ScaleHandle)activeHandle; // Make sure we transform relative to the handle position SceneObject temporarySO = new SceneObject("Temp"); temporarySO.Position = activeHandle.Position; SceneObject[] originalParents = new SceneObject[activeSelection.Length]; for (int i = 0; i < activeSelection.Length; i++) { originalParents[i] = activeSelection[i].so.Parent; activeSelection[i].so.LocalPosition = activeSelection[i].initialPosition; activeSelection[i].so.LocalRotation = activeSelection[i].initialRotation; activeSelection[i].so.LocalScale = activeSelection[i].initialScale; activeSelection[i].so.Parent = temporarySO; } temporarySO.LocalScale += scaleHandle.Delta; for (int i = 0; i < activeSelection.Length; i++) { activeSelection[i].so.Parent = originalParents[i]; } temporarySO.Destroy(); } break; } EditorApplication.SetSceneDirty(); } } else { isDragged = false; activeSelection = null; } }