Clean up logging
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using Core;
|
||||
using Pixelplacement;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
@@ -79,10 +80,10 @@ namespace UI.DragAndDrop.Core
|
||||
|
||||
protected virtual void Initialize()
|
||||
{
|
||||
Debug.Log($"[DraggableObject] Initializing {name} at world pos {transform.position}, local pos {transform.localPosition}, parent: {(transform.parent != null ? transform.parent.name : "NULL")}");
|
||||
Logging.Debug($"[DraggableObject] Initializing {name} at world pos {transform.position}, local pos {transform.localPosition}, parent: {(transform.parent != null ? transform.parent.name : "NULL")}");
|
||||
|
||||
_canvas = GetComponentInParent<Canvas>();
|
||||
Debug.Log($"[DraggableObject] {name} found canvas: {(_canvas != null ? _canvas.name : "NULL")}, canvas pos: {(_canvas != null ? _canvas.transform.position.ToString() : "N/A")}");
|
||||
Logging.Debug($"[DraggableObject] {name} found canvas: {(_canvas != null ? _canvas.name : "NULL")}, canvas pos: {(_canvas != null ? _canvas.transform.position.ToString() : "N/A")}");
|
||||
|
||||
_imageComponent = GetComponent<Image>();
|
||||
_canvasGroup = GetComponent<CanvasGroup>();
|
||||
@@ -95,7 +96,7 @@ namespace UI.DragAndDrop.Core
|
||||
_imageComponent = gameObject.AddComponent<Image>();
|
||||
_imageComponent.color = new Color(1, 1, 1, 0.01f); // Nearly transparent (0 doesn't work)
|
||||
_imageComponent.raycastTarget = true;
|
||||
Debug.Log($"[DraggableObject] Added invisible Image to {name} for raycast detection");
|
||||
Logging.Debug($"[DraggableObject] Added invisible Image to {name} for raycast detection");
|
||||
}
|
||||
|
||||
// Use assigned visual, or find in children recursively if not assigned
|
||||
@@ -190,19 +191,19 @@ namespace UI.DragAndDrop.Core
|
||||
if (eventData.button != PointerEventData.InputButton.Left)
|
||||
return;
|
||||
|
||||
Debug.Log($"[DraggableObject] OnBeginDrag called on {name}. _isDraggingEnabled={_isDraggingEnabled}");
|
||||
Logging.Debug($"[DraggableObject] OnBeginDrag called on {name}. _isDraggingEnabled={_isDraggingEnabled}");
|
||||
|
||||
// Check if dragging is enabled BEFORE setting any state
|
||||
if (!_isDraggingEnabled)
|
||||
{
|
||||
Debug.Log($"[DraggableObject] OnBeginDrag blocked - dragging disabled on {name}");
|
||||
Logging.Debug($"[DraggableObject] OnBeginDrag blocked - dragging disabled on {name}");
|
||||
return;
|
||||
}
|
||||
|
||||
_isDragging = true;
|
||||
_wasDragged = true;
|
||||
|
||||
Debug.Log($"[DraggableObject] Drag started on {name}");
|
||||
Logging.Debug($"[DraggableObject] Drag started on {name}");
|
||||
|
||||
// ...existing code...
|
||||
if (_canvas != null && _canvas.renderMode == RenderMode.ScreenSpaceOverlay && RectTransform != null)
|
||||
@@ -413,7 +414,7 @@ namespace UI.DragAndDrop.Core
|
||||
if (slot == null)
|
||||
return;
|
||||
|
||||
Debug.Log($"[DraggableObject] Assigning {name} to slot {slot.name}, animate={animate}, current pos={transform.position}, slot pos={slot.transform.position}");
|
||||
Logging.Debug($"[DraggableObject] Assigning {name} to slot {slot.name}, animate={animate}, current pos={transform.position}, slot pos={slot.transform.position}");
|
||||
|
||||
DraggableSlot previousSlot = _currentSlot;
|
||||
_currentSlot = slot;
|
||||
@@ -429,7 +430,7 @@ namespace UI.DragAndDrop.Core
|
||||
transform.SetParent(slot.transform);
|
||||
transform.localPosition = _isSelected ? new Vector3(0, selectionOffset, 0) : Vector3.zero;
|
||||
transform.localRotation = Quaternion.identity;
|
||||
Debug.Log($"[DraggableObject] {name} assigned to slot {slot.name}, new world pos={transform.position}, local pos={transform.localPosition}");
|
||||
Logging.Debug($"[DraggableObject] {name} assigned to slot {slot.name}, new world pos={transform.position}, local pos={transform.localPosition}");
|
||||
}
|
||||
|
||||
OnSlotChanged?.Invoke(this, slot);
|
||||
@@ -510,14 +511,14 @@ namespace UI.DragAndDrop.Core
|
||||
/// </summary>
|
||||
public virtual void SetDraggingEnabled(bool enabled)
|
||||
{
|
||||
Debug.Log($"[DraggableObject] SetDraggingEnabled({enabled}) called on {name}. _isDragging={_isDragging}, _isDraggingEnabled={_isDraggingEnabled}");
|
||||
Logging.Debug($"[DraggableObject] SetDraggingEnabled({enabled}) called on {name}. _isDragging={_isDragging}, _isDraggingEnabled={_isDraggingEnabled}");
|
||||
|
||||
_isDraggingEnabled = enabled;
|
||||
|
||||
// If disabling dragging while actively dragging, stop the drag
|
||||
if (!enabled && _isDragging)
|
||||
{
|
||||
Debug.Log($"[DraggableObject] Stopping active drag on {name}");
|
||||
Logging.Debug($"[DraggableObject] Stopping active drag on {name}");
|
||||
_isDragging = false;
|
||||
|
||||
// Re-enable raycasting
|
||||
@@ -529,7 +530,7 @@ namespace UI.DragAndDrop.Core
|
||||
_canvasGroup.blocksRaycasts = true;
|
||||
}
|
||||
|
||||
Debug.Log($"[DraggableObject] After SetDraggingEnabled: _isDragging={_isDragging}, _isDraggingEnabled={_isDraggingEnabled}");
|
||||
Logging.Debug($"[DraggableObject] After SetDraggingEnabled: _isDragging={_isDragging}, _isDraggingEnabled={_isDraggingEnabled}");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Pixelplacement;
|
||||
using Core;
|
||||
using Pixelplacement;
|
||||
using Pixelplacement.TweenSystem;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem; // Added for new Input System
|
||||
@@ -67,14 +68,14 @@ namespace UI.DragAndDrop.Core
|
||||
_parentDraggable = parent;
|
||||
|
||||
Canvas parentCanvas = parent.GetComponentInParent<Canvas>();
|
||||
Debug.Log($"[DraggableVisual] Initializing visual for {parent.name} at world pos {parent.transform.position}, parent canvas: {(parentCanvas != null ? parentCanvas.name + " (renderMode: " + parentCanvas.renderMode + ")" : "NULL")}");
|
||||
Logging.Debug($"[DraggableVisual] Initializing visual for {parent.name} at world pos {parent.transform.position}, parent canvas: {(parentCanvas != null ? parentCanvas.name + " (renderMode: " + parentCanvas.renderMode + ")" : "NULL")}");
|
||||
|
||||
// CRITICAL: Reparent visual to canvas (not base) so it can move independently
|
||||
// This enables the delayed follow effect
|
||||
if (parentCanvas != null)
|
||||
{
|
||||
transform.SetParent(parentCanvas.transform, true); // worldPositionStays = true
|
||||
Debug.Log($"[DraggableVisual] Reparented visual {name} to canvas {parentCanvas.name} for independent movement");
|
||||
Logging.Debug($"[DraggableVisual] Reparented visual {name} to canvas {parentCanvas.name} for independent movement");
|
||||
}
|
||||
|
||||
// Get components if assigned (don't auto-create Canvas to avoid Unity's auto-reparenting)
|
||||
@@ -106,7 +107,7 @@ namespace UI.DragAndDrop.Core
|
||||
tiltParent.localRotation = Quaternion.identity;
|
||||
}
|
||||
|
||||
Debug.Log($"[DraggableVisual] Visual {name} initialized at world pos {transform.position}, local pos {transform.localPosition}, local rotation {transform.localRotation.eulerAngles}, parent at world pos {parent.transform.position}, local pos {parent.transform.localPosition}, rotation {parent.transform.rotation.eulerAngles}");
|
||||
Logging.Debug($"[DraggableVisual] Visual {name} initialized at world pos {transform.position}, local pos {transform.localPosition}, local rotation {transform.localRotation.eulerAngles}, parent at world pos {parent.transform.position}, local pos {parent.transform.localPosition}, rotation {parent.transform.rotation.eulerAngles}");
|
||||
|
||||
_isInitialized = true;
|
||||
|
||||
@@ -202,7 +203,7 @@ namespace UI.DragAndDrop.Core
|
||||
float distance = Vector3.Distance(currentPosition, targetPosition);
|
||||
if (distance > 500f)
|
||||
{
|
||||
Debug.LogWarning($"[DraggableVisual] Large position delta detected! Visual {name} at {currentPosition}, target {targetPosition}, parent {_parentDraggable.name}, distance: {distance}");
|
||||
Logging.Warning($"[DraggableVisual] Large position delta detected! Visual {name} at {currentPosition}, target {targetPosition}, parent {_parentDraggable.name}, distance: {distance}");
|
||||
}
|
||||
|
||||
// Apply follow logic with snappy easing
|
||||
|
||||
Reference in New Issue
Block a user