- Brewster - Singleton "God" object that manages collections and application state
- ApplicationManager - Main entry point for the application
- CollectionBrowserManager - Manages collection browsing and navigation
- ViewFactory - Creates and manages views for collections and items
- ItemSelectionManager - Handles selection of items
Before starting development on the Unity portion of CraftSpace, set up your IDE with the following extensions for a more productive workflow:
-
Visual Studio Tools for Unity (essential)
- Enables debugging, code completion, and Unity project navigation
- Properly handles .meta files and Unity-specific file operations
- Maintains the relationship between assets and their metadata
-
Unity Debug (for VS Code)
- Allows attaching the VS Code debugger to the Unity editor
- Supports breakpoints, watch variables, and step debugging
-
C# Extensions
- Enhanced syntax highlighting for C# files
- Code organization features (regions, methods grouping)
-
Unity Code Snippets
- Provides templates for common Unity patterns
- Speeds up creation of MonoBehaviours, ScriptableObjects, etc.
-
Unity Integration
- Configure Cursor to exclude .meta files from the file explorer:
- Open Settings → Features → Explorer → Files: Exclude
- Add
*.meta
to the patterns list
- Cursor will still maintain these files when moving/renaming assets
- Configure Cursor to exclude .meta files from the file explorer:
-
Recommended Settings
- Enable "Auto Save" to ensure changes are saved when Unity reimports assets
- Configure bracket pair colorization for better C# readability
- Set up a reasonable tab size (4 spaces) to match Unity's default formatting
-
File Association
- Ensure .cs files open with Cursor by default
- Associate Unity scene and prefab files with Unity Editor
-
Git LFS Setup
- Configure Git LFS for Unity asset files (.asset, .fbx, etc.)
- Avoid LFS for code files to maintain good diff visibility
-
.gitignore Configuration
- Use Unity's recommended .gitignore settings
- Ensure meta files are included in version control
- Exclude user-specific Unity files (UserSettings folder, etc.)
By properly configuring your development environment, you can avoid common pitfalls with Unity development, like broken references due to improper handling of meta files or synchronization issues between your IDE and Unity.
- Purpose: Displays and manages a collection of items in a grid layout
- Components:
- CollectionView script
- CollectionGridLayout script
- Child GameObject named "Content" (container for items)
- Purpose: Displays and manages a single item
- Components:
- ItemView script
- Box Collider (for interaction)
- Optional renderers depending on content type:
- SingleImageRenderer (for images)
- TextMetadataRenderer (for text)
- SimpleItemCardRenderer (for general items)
-
Core Manager GameObject (required)
- ApplicationManager component
- Brewster component
- CollectionBrowserManager component
- ViewFactory component
- ImageLoader component
- Create a child GameObject named "Collections Container"
- This will hold all instantiated collection views
-
Camera Setup
- Create an empty GameObject named "CameraRig"
- Add CameraController component to this GameObject
- Make the Main Camera a child of CameraRig
- Position CameraRig at an appropriate height (Y=10)
- Rotate Main Camera to look down (X=90, Y=0, Z=0)
- Consider using Orthographic projection for clean top-down view
- In the CollectionBrowserManager, drag the CameraRig into the "Camera Rig" field
-
Selection Manager
- GameObject with ItemSelectionManager component
- Brewster acts as the central data manager, holding references to all collections
- CollectionView registers itself with its Collection model
- CollectionGridLayout handles the spatial arrangement of ItemViews
- CameraController can focus on specific CollectionGridLayouts
- ItemSelectionManager handles selection events from ItemViews
- Collections are loaded via CollectionLoader
- Brewster manages the loaded Collections
- CollectionBrowserManager creates CollectionView instances using ViewFactory
- CollectionGridLayout organizes ItemViews spatially
- User interacts with ItemViews, which report to ItemSelectionManager
- CameraController navigates between collections and items
- Ensure all prefabs have the correct component references set
- Check that the Brewster singleton is initialized before any collection operations
- Make sure the CameraController's parameters match your scene scale
- Verify that the CollectionGridLayout settings provide appropriate spacing for your items
Unity's built-in JSON utilities (JsonUtility
) have significant limitations that make them unsuitable for robust data handling:
- Cannot serialize/deserialize simple arrays without wrapper classes
- No support for dictionaries or complex nested structures
- Requires exact class structure matching with no flexibility
- Limited error reporting when deserialization fails
- No dynamic JSON navigation capabilities
For these reasons, we use Newtonsoft.Json (JSON.net) throughout CraftSpace:
// DO NOT USE:
List<string> items = JsonUtility.FromJson<List<string>>(jsonText); // Will fail!
// INSTEAD USE:
// For simple arrays:
JArray itemsArray = JArray.Parse(jsonText);
List<string> items = new List<string>();
foreach (JToken token in itemsArray)
{
items.Add(token.ToString());
}
// For complex objects:
Item item = JsonConvert.DeserializeObject<Item>(jsonText);
// For dynamic navigation:
JObject obj = JObject.Parse(jsonText);
string title = obj["metadata"]?["title"]?.ToString() ?? "Untitled";
- JToken/JObject/JArray classes for flexible JSON navigation
- LINQ integration for powerful queries and transformations
- Robust error handling with detailed exception information
- Schema validation capabilities
- Well-maintained and industry standard library
- Avoid creating custom JSON helpers or wrappers around JSON.net
- Use direct JArray.Parse() for handling collection indices (simple string arrays)
- Use JsonConvert.DeserializeObject() for model classes
- For debugging, JObject.Parse() + property access can inspect any JSON structure
By consistently using JSON.net throughout the codebase, we ensure reliable data handling regardless of the JSON structure complexity.