An interactive Augmented Reality experience featuring an intelligent holographic cube guardian system. Place virtual cubes in AR space that change state based on proximity to the camera, with visual feedback through dynamic colors and glow effects.
AR Guardian Cube is a Unity-based AR application that demonstrates real-time proximity detection and visual state management in augmented reality. Users can tap to place holographic cubes in AR space that respond to camera proximity with color changes and status warnings.
- Tap-to-Place: Easy gesture-based placement of AR objects on detected planes
- Proximity Detection: Real-time distance monitoring between camera and placed objects
- Dynamic Visual States:
- Green (Safe): Object at normal distance (>0.5m)
- Yellow (Warning): Restricted area (0.2m - 0.5m)
- Red (Critical): Too close (<0.2m)
- Holographic Effects: Custom shader with glow intensity that responds to proximity
- Billboard UI: Status text that always faces the camera for optimal readability
- ARCore Support: Plane detection and spatial understanding using ARCore/ARFoundation
- Unity Version: 6000.2.14f1 (Latest LTS)
- Platform: Android with ARCore support
- Device Requirements: ARCore-compatible device with camera and tracking capabilities
Core AR packages:
com.unity.xr.arfoundation(6.2.1) - AR frameworkcom.unity.xr.arcore(6.2.1) - Android AR supportcom.unity.inputsystem(1.16.0) - Input handlingcom.unity.shadergraph(17.2.0) - Custom shader creationcom.unity.textmeshpro- Advanced text rendering
AR_Guardian_Cube_2.0/
├── Assets/
│ ├── Scripts/ # Core gameplay scripts
│ │ ├── GuardianState.cs # Proximity detection & state management
│ │ ├── TapToPlace.cs # AR placement system
│ │ └── Billboard.cs # Camera-facing UI
│ ├── Resources/ # Prefabs and references
│ ├── Scenes/
│ │ └── SampleScene.unity # Main AR scene
│ ├── XR/ # AR configuration
│ └── HologramShader.shadergraph # Custom shader for hologram effect
├── Builds/ # Built application files
├── Packages/
│ └── manifest.json # Package dependencies
└── ProjectSettings/ # Unity configuration
Manages the cube's visual state based on camera proximity:
- Monitors distance between AR camera and cube object
- Updates material color and glow intensity
- Displays proximity warnings via TextMeshPro
Distance Thresholds:
- < 0.2m: CRITICAL (Red, Glow 4.0)
- 0.2m - 0.5m: WARNING (Yellow, Glow 2.5)
-
0.5m: SAFE (Green, Glow 1.2)
Handles AR object placement through touch input:
- Uses ARRaycastManager for plane detection
- Places objects on detected horizontal planes
- Maintains proper object orientation and position
Ensures UI text always faces the camera:
- Billboard behavior for status text display
- Improves readability in AR space
- Open the project in Unity 6000.2.14f1 or later
- Build settings are pre-configured for Android with ARCore
- Connect an ARCore-compatible Android device
- Go to File > Build Settings
- Select Android as target platform
- Configure player settings as needed
- Click Build and Run
- Launch the app on an ARCore device
- Allow camera permissions when prompted
- Move device to detect planes (floor/table surfaces)
- Tap on a detected plane to place the Guardian Cube
- Move closer/farther to observe proximity-based color changes
Edit distance values in GuardianState.cs:
if (distance < 0.2f) // Critical threshold (in meters)
if (distance < 0.5f) // Warning threshold (in meters)Change color and glow values in GuardianState.cs:
cubeRenderer.material.SetColor(BaseColorID, Color.red);
cubeRenderer.material.SetFloat(GlowID, 4f); // Glow intensityUpdate text in GuardianState.cs:
statusText.text = "Your custom message";The holographic appearance is created using a custom ShaderGraph (HologramShader.shadergraph) that supports:
- Dynamic base color changes
- Adjustable glow intensity
- Real-time material property updates
App crashes on startup: Ensure ARCore is installed on your device and app has camera permissions
Cube not appearing: Check that planes are being detected (usually floor surfaces in good lighting)
Text not visible: Ensure the Billboard script is attached to the status text object
No proximity changes: Verify GuardianState script is assigned the correct AR Camera reference
- Optimized for mobile AR with minimal GPU overhead
- Proximity checks run every frame for real-time response
- Shader-based visual effects reduce CPU load
- Android: ARCore 6.2.1+
- iOS: Consider adding ARKit support via UnityXR plugins
- Multiple cube instances with independent states
- Sound effects for proximity warnings
- Gesture-based cube manipulation
- Data logging and analytics
- Cloud-based cube placement sharing
Project created for AR demonstration purposes.
For issues or questions, review the scripts and ensure all AR setup is properly configured in ProjectSettings.