Add pinch controls to statue dressup game
This commit is contained in:
@@ -26,9 +26,8 @@ namespace Minigames.StatueDressup.Controllers
|
||||
[SerializeField] private GameObject statue;
|
||||
[SerializeField] private DecorationDraggableInstance draggablePrefab; // Prefab for spawning decorations
|
||||
|
||||
[Header("Edit UI")]
|
||||
[SerializeField] private UI.DecorationEditUI editUIPrefab; // Prefab for edit UI
|
||||
private UI.DecorationEditUI _editUIInstance;
|
||||
[Header("Pinch Controls")]
|
||||
private UI.DecorationPinchController _pinchControllerInstance;
|
||||
|
||||
[Header("UI Pages")]
|
||||
[SerializeField] private UI.PlayAreaPage playAreaPage;
|
||||
@@ -460,35 +459,37 @@ namespace Minigames.StatueDressup.Controllers
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Show edit UI for a placed decoration
|
||||
/// Show pinch controls for a placed decoration
|
||||
/// </summary>
|
||||
public void ShowEditUI(DecorationDraggableInstance decoration)
|
||||
{
|
||||
if (decoration == null)
|
||||
{
|
||||
Logging.Warning("[StatueDecorationController] Cannot show edit UI - decoration is null");
|
||||
Logging.Warning("[StatueDecorationController] Cannot show pinch controls - decoration is null");
|
||||
return;
|
||||
}
|
||||
|
||||
// Create edit UI instance if needed
|
||||
if (_editUIInstance == null)
|
||||
// Create pinch controller instance if needed
|
||||
if (_pinchControllerInstance == null)
|
||||
{
|
||||
if (editUIPrefab == null)
|
||||
{
|
||||
Logging.Error("[StatueDecorationController] Edit UI prefab is not assigned!");
|
||||
return;
|
||||
}
|
||||
|
||||
// Instantiate as child of canvas (find appropriate parent)
|
||||
// Find canvas transform
|
||||
Transform canvasTransform = statueArea != null ? statueArea.root : transform.root;
|
||||
_editUIInstance = Instantiate(editUIPrefab, canvasTransform);
|
||||
_editUIInstance.transform.SetAsLastSibling(); // Ensure it's on top
|
||||
|
||||
Logging.Debug("[StatueDecorationController] Created edit UI instance");
|
||||
// Create new GameObject with DecorationPinchController component
|
||||
GameObject pinchControllerObj = new GameObject("DecorationPinchController");
|
||||
pinchControllerObj.transform.SetParent(canvasTransform, false);
|
||||
|
||||
// Add the component (it will auto-create RectTransform, Image, CanvasGroup, PinchGestureHandler in Awake)
|
||||
_pinchControllerInstance = pinchControllerObj.AddComponent<UI.DecorationPinchController>();
|
||||
|
||||
// Ensure it's on top
|
||||
pinchControllerObj.transform.SetAsLastSibling();
|
||||
|
||||
Logging.Debug("[StatueDecorationController] Created pinch controller instance dynamically");
|
||||
}
|
||||
|
||||
// Show the UI
|
||||
_editUIInstance.Show(decoration);
|
||||
// Show the pinch controls
|
||||
_pinchControllerInstance.Show(decoration);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user