Skip to content

Latest commit

 

History

History
325 lines (207 loc) · 6.86 KB

File metadata and controls

325 lines (207 loc) · 6.86 KB

API Reference

Complete API documentation for all scripts and components in the Life in Between XR project.

Table of Contents

Core Scripts

Line.cs

Data structure representing a transit line.

Namespace: Global

Type: [System.Serializable] class

Properties

Property Type Description
name string Name of the transit line (e.g., "Red Line", "Blue Line")
selected bool Whether this line is currently selected by the user
color Color Visual color representation of the line
button GameObject Associated UI button GameObject for this line

Example Usage

// Create a new line
Line redLine = new Line {
    name = "Red Line",
    selected = false,
    color = Color.red,
    button = redLineButtonGameObject
};

// Check if line is selected
if (redLine.selected) {
    Debug.Log($"{redLine.name} is selected");
}

File Location: Assets/Scripts/Line.cs


LineSelector.cs

Manages transit line selection logic and state.

Namespace: Global

Type: MonoBehaviour

Public Properties

Property Type Description
LinesList List<Line> List of all available transit lines

Public Methods

SelectLine(string selectedLineName)

Selects a specific line and deselects all others.

Parameters:

  • selectedLineName (string): The name of the line to select

Behavior:

  • Iterates through LinesList
  • Sets selected = true for matching line
  • Sets selected = false for all other lines

Example Usage:

LineSelector selector = GetComponent<LineSelector>();

// Select the Red Line
selector.SelectLine("Red Line");

// Verify selection
foreach (Line line in selector.LinesList) {
    if (line.selected) {
        Debug.Log($"Selected: {line.name}");
    }
}

File Location: Assets/Scripts/LineSelector.cs


Stop.cs

Data structure representing a transit stop.

Namespace: Global

Type: [System.Serializable] class

Properties

Property Type Description
name string Name of the transit stop

Nested Types

Stop.color (enum)

Color classification for transit stops.

Values:

  • red
  • blue
  • green
  • yellow

Example Usage

// Create a new stop
Stop station = new Stop {
    name = "Central Station"
};

// Use color enum (example)
// Note: The enum is defined but not currently used as a property

File Location: Assets/Scripts/Stop.cs


UIManager.cs

Manages UI state and visibility, ensuring proper UI element coordination.

Namespace: Global

Type: MonoBehaviour

Public Properties

Property Type Description
searchDropdown GameObject The search dropdown UI element
selectorBar GameObject The line selector bar UI element

Behavior

The Update() method runs every frame and:

  • Hides the selector bar when the search dropdown is active
  • Shows the selector bar when the search dropdown is inactive

This ensures only one UI element is visible at a time, preventing UI overlap.

Example Usage

UIManager uiManager = GetComponent<UIManager>();

// Assign UI elements via Inspector or code
uiManager.searchDropdown = searchDropdownGameObject;
uiManager.selectorBar = selectorBarGameObject;

// The Update() method automatically manages visibility

File Location: Assets/Scripts/UIManager.cs


Data Models

Building Data

Building information is stored in CSV format.

Location: Assets/Map Info/MITBuildings.csv

Format: CSV file with building data (structure may vary)

Usage: Loaded and parsed at runtime for building information display.


UI Components

AutoComplete System

The application uses the Rotary Heart AutoComplete package.

Package Location: Assets/Rotary Heart/AutoCompletePopup/

Key Classes

AutoCompleteTextField

Static class for editor-time autocomplete text fields.

Namespace: RotaryHeart.Lib.AutoComplete

Documentation: See package documentation in Assets/Rotary Heart/AutoCompletePopup/Documentation.pdf

AutoCompletePrefab

Runtime autocomplete prefab component.

Namespace: RotaryHeart.Lib.AutoComplete

Type: MonoBehaviour

Key Methods:

  • Search functionality
  • Item selection callbacks
  • UI management

Example Usage

using RotaryHeart.Lib.AutoComplete;

// In editor scripts
string result = AutoCompleteTextField.EditorGUILayout.AutoCompleteTextField(
    currentText, 
    searchOptions, 
    allowCustom: true
);

Third-Party Integration

AR Foundation

AR functionality is provided by Unity's AR Foundation.

Key Components:

  • ARPlaneManager: Detects horizontal/vertical planes
  • ARAnchorManager: Manages AR anchors
  • ARRaycastManager: Performs raycasts in AR space

Documentation: Unity AR Foundation Documentation

ArcGIS SDK

3D mapping and visualization.

Integration: See ArcGIS SDK documentation for specific API usage.

Data: 3D models in Assets/3D Map/

Google Maps API

Location search and filtering.

Usage: Integrated for location search functionality.

Configuration: API key should be stored securely (see setup-guide.md)


Scene References

Available Scenes

Scene Purpose Location
Scene00_MainMenu.unity Main menu scene Assets/Scenes/
Test00_Autocomplete.unity Autocomplete testing Assets/Scenes/
Test01_3dMap.unity 3D map testing Assets/Scenes/
WoOz_00_Videogame.unity Demo/prototype scene Assets/Scenes/

Extension Points

Adding New Transit Lines

  1. Create a Line object with appropriate properties
  2. Add to LineSelector.LinesList
  3. Create associated UI button
  4. Assign button to Line.button property

Adding New Stops

  1. Create a Stop object
  2. Add to your stop management system
  3. Associate with appropriate Line

Customizing UI Behavior

Extend UIManager to add custom UI coordination logic:

public class CustomUIManager : UIManager {
    void Update() {
        base.Update(); // Call base implementation
        // Add custom logic
    }
}

Best Practices

  1. Always validate inputs before calling methods
  2. Check for null references when accessing GameObjects
  3. Use Inspector assignment for GameObject references when possible
  4. Follow naming conventions (PascalCase for classes, camelCase for variables)
  5. Document custom extensions to the API

Last Updated: 2024