4.8 KiB
4.8 KiB
Photo Gallery Scene Setup Guide
Current Scene Status
✅ MainCanvas exists
✅ StatueDecorationController exists
✅ PhotoCaptureTestController exists (testing only)
Required Scene Setup
1. Create UIPage Wrappers
PlayAreaPage
- Create empty GameObject under
MainCanvas→ name:PlayAreaPage - Add component:
PlayAreaPage.cs - Move existing decoration UI as children under PlayAreaPage:
- Decoration menu
- Take photo button
- Any other play area UI
PhotoGalleryPage
- Create empty GameObject under
MainCanvas→ name:PhotoGalleryPage - Add component:
PhotoGalleryPage.cs - Set initially inactive (will be shown when opened)
2. Setup Photo Gallery UI (under PhotoGalleryPage)
PhotoGalleryPage
├── GalleryController (GameObject)
│ └── StatuePhotoGalleryController.cs
├── GridContainer (GameObject with GridLayoutGroup)
├── EnlargedContainer (GameObject - top layer)
├── Backdrop (UI Image - dark/black, alpha 0.8)
├── PageStatusText (UI Text - shows "Page X/Y")
└── Navigation
├── PreviousPageButton (UI Button - "< Prev")
└── NextPageButton (UI Button - "Next >")
Components to assign on StatuePhotoGalleryController:
gridContainer→ GridContainer transformgridItemPrefab→ Create prefab with PhotoGridItem.cs + UI ImageenlargedContainer→ EnlargedContainer transformbackdrop→ Backdrop GameObjectenlargedPreviewPrefab→ Same as gridItemPrefab (or leave null to clone item)previousPageButton→ Previous page buttonnextPageButton→ Next page buttonpageStatusText→ Optional status text showing page info
GridLayoutGroup Settings (on GridContainer):
- Cell Size: e.g., 200x200
- Spacing: e.g., 10x10
- Constraint: Fixed Column Count (3-4 columns recommended)
- Child Alignment: Upper Left (or as preferred)
3. Create PhotoGridItem Prefab
- Create UI → Image in scene
- Add
PhotoGridItem.cscomponent - Assign
thumbnailImage→ the Image component itself - Optional: Add loading indicator child (simple spinner/text)
- Drag to Prefabs folder → name:
PhotoGridItem - Delete from scene
4. Update StatueDecorationController
Assign in Inspector:
playAreaPage→ PlayAreaPage GameObjectphotoGalleryPage→ PhotoGalleryPage GameObjectopenGalleryButton→ Create button in PlayAreaPage UI, assign herephotoArea→ RectTransform defining capture area (statue + decorations)takePhotoButton→ Existing button (uncomment line 97 in code when ready)
5. Create Gallery Open Button
- Add Button in PlayAreaPage UI → name: "OpenGalleryButton"
- Button Text: "📷 Gallery" or "View Photos"
- Assign to StatueDecorationController's
openGalleryButtonfield
6. Page Navigation (PhotoGalleryPage)
- Create two buttons for Previous/Next page
- Buttons will be auto-wired by StatuePhotoGalleryController
- Controller auto-disables buttons when at first/last page
- Grid clears and reloads on each page change
Key Features
✅ Button-Based Pagination
- Previous/Next buttons navigate pages
- Grid clears completely and shows only current page
- Buttons auto-disable at boundaries (first/last page)
- Status text shows "Page X/Y (total photos)"
✅ Grid Clearing
- Grid is cleared on initialization
- Grid clears when switching pages
- Prevents leftover items from scene setup
✅ Enlarge System
- Click photo → spawns preview clone, animates to center
- Click again → shrinks back, destroys preview
- Original grid items never move
- Backdrop blocks grid interaction
Testing Checklist
Photo Capture (Already Working)
- ✅ PhotoCaptureTestController captures and saves photos
- ✅ Photos saved to
Application.persistentDataPath/StatuePhotos/
Gallery Integration (New Setup)
- Play scene
- Click "Open Gallery" button → Gallery page shows
- First page of photos loads in grid
- Click "Next" → Grid clears, next page loads
- Click "Previous" → Grid clears, previous page loads
- Click photo → Enlarges to center with backdrop
- Click enlarged photo → Shrinks back to grid
- Back button → Returns to play area
Quick Setup Time
- PlayAreaPage wrapper: 2 minutes
- PhotoGalleryPage structure: 5 minutes
- PhotoGridItem prefab: 3 minutes
- Wire references: 5 minutes
Total: ~15 minutes
Configuration Variables
Set these on StatuePhotoGalleryController:
itemsPerPage: 20 (photos per page)thumbnailSize: 256 (pixels)maxCachedThumbnails: 50 (LRU cache)enlargedScale: 2.5 (zoom amount)animationDuration: 0.3s
Cleanup (Optional)
Once gallery works, you can:
- Remove
PhotoCaptureTestControllerGameObject - Keep for quick testing if preferred