Lesson 2: Unity Mobile Project Setup

Welcome back, mobile game developer! In this lesson, you'll transform your game concept into a properly configured Unity project that's optimized for mobile devices. By the end of this lesson, you'll have a solid foundation that's ready for touch controls, mobile-specific optimizations, and puzzle game mechanics.

What You'll Learn

  • Configure Unity for mobile development
  • Set up proper project structure for puzzle games
  • Implement mobile-specific settings and optimizations
  • Create responsive touch controls foundation
  • Establish mobile UI framework

Prerequisites

  • Unity 2022.3 LTS or newer installed
  • Basic understanding of Unity interface
  • Completed Lesson 1: Mobile Game Concept & Market Research

Step 1: Create New Unity Project

Let's start by creating a new Unity project specifically optimized for mobile puzzle games:

  1. Open Unity Hub and click "New Project"
  2. Select Template: Choose "2D Core" template (perfect for puzzle games)
  3. Project Name: MobilePuzzleGame (or your preferred name)
  4. Location: Choose a dedicated folder for your project
  5. Unity Version: Use Unity 2022.3 LTS or newer for stability

Pro Tip: Always use LTS (Long Term Support) versions for production projects. They're more stable and receive longer support.

Step 2: Configure Mobile Build Settings

Before we start developing, let's configure Unity for mobile deployment:

  1. Open Build Settings: File → Build Settings
  2. Switch Platform: Select "Android" or "iOS" (choose your target platform)
  3. Player Settings: Click "Player Settings" button
  4. Configure Company Name: Set to your studio name
  5. Product Name: Set to your game name
  6. Version: Start with "0.1.0" for development

Android-Specific Settings

If targeting Android:

  • Minimum API Level: Set to Android 7.0 (API level 24) for broad compatibility
  • Target API Level: Use latest stable version
  • Scripting Backend: IL2CPP for better performance
  • Architecture: ARM64 for modern devices

iOS-Specific Settings

If targeting iOS:

  • Target iOS Version: iOS 12.0 or newer
  • Architecture: ARM64
  • Scripting Backend: IL2CPP

Step 3: Mobile-Optimized Project Structure

Create a clean, organized folder structure in your Project window:

Assets/
├── Scripts/
│   ├── Core/
│   ├── UI/
│   ├── Puzzle/
│   └── Mobile/
├── Art/
│   ├── Sprites/
│   ├── UI/
│   └── Backgrounds/
├── Audio/
│   ├── Music/
│   ├── SFX/
│   └── Voice/
├── Prefabs/
│   ├── Puzzle/
│   ├── UI/
│   └── Mobile/
├── Scenes/
│   ├── MainMenu/
│   ├── Gameplay/
│   └── Settings/
└── Resources/
    ├── Mobile/
    └── Config/

Mini-Task: Create this folder structure in your Unity project. Right-click in the Project window and create folders as needed.

Step 4: Mobile-Specific Settings Configuration

Configure Unity settings for optimal mobile performance:

Quality Settings

  1. Open Quality Settings: Edit → Project Settings → Quality
  2. Mobile Quality: Select "Simple" or "Fast" quality level
  3. Texture Quality: Set to "Half Res" for better performance
  4. Anti Aliasing: Disable or use "2x Multi Sampling"
  5. Soft Particles: Disable for better performance

Player Settings Optimization

  1. Open Player Settings: Edit → Project Settings → Player
  2. Resolution and Presentation:
    • Default Screen Width: 1080
    • Default Screen Height: 1920
    • Default Screen Orientation: Portrait (for puzzle games)
  3. Publishing Settings:
    • Company Name: Your studio name
    • Product Name: Your game name
    • Version: 0.1.0

Graphics Settings

  1. Open Graphics Settings: Edit → Project Settings → Graphics
  2. Scriptable Render Pipeline: Use Built-in Render Pipeline for simplicity
  3. Shader Stripping: Enable for smaller build sizes

Step 5: Touch Input System Setup

Set up the foundation for touch controls:

  1. Create Input Manager: Create empty GameObject named "InputManager"
  2. Add Input Script: Create new C# script called MobileInputManager.cs
using UnityEngine;

public class MobileInputManager : MonoBehaviour
{
    public static MobileInputManager Instance { get; private set; }

    [Header("Touch Settings")]
    public float touchSensitivity = 1.0f;
    public float tapThreshold = 0.2f;

    private void Awake()
    {
        if (Instance == null)
        {
            Instance = this;
            DontDestroyOnLoad(gameObject);
        }
        else
        {
            Destroy(gameObject);
        }
    }

    private void Update()
    {
        HandleTouchInput();
    }

    private void HandleTouchInput()
    {
        if (Input.touchCount > 0)
        {
            Touch touch = Input.GetTouch(0);

            switch (touch.phase)
            {
                case TouchPhase.Began:
                    OnTouchStart(touch.position);
                    break;
                case TouchPhase.Moved:
                    OnTouchMove(touch.position, touch.deltaPosition);
                    break;
                case TouchPhase.Ended:
                    OnTouchEnd(touch.position);
                    break;
            }
        }
    }

    private void OnTouchStart(Vector2 position)
    {
        // Handle touch start
        Debug.Log($"Touch started at: {position}");
    }

    private void OnTouchMove(Vector2 position, Vector2 deltaPosition)
    {
        // Handle touch movement
    }

    private void OnTouchEnd(Vector2 position)
    {
        // Handle touch end
        Debug.Log($"Touch ended at: {position}");
    }
}
  1. Attach Script: Add the script to the InputManager GameObject

Step 6: Mobile UI Canvas Setup

Create a responsive UI system for mobile devices:

  1. Create UI Canvas: Right-click in Hierarchy → UI → Canvas

  2. Canvas Settings:

    • Render Mode: Screen Space - Overlay
    • UI Scale Mode: Scale With Screen Size
    • Reference Resolution: 1080 x 1920 (portrait)
    • Screen Match Mode: Match Width Or Height
    • Match: 0.5 (balanced scaling)
  3. Add Canvas Scaler: The Canvas Scaler component should be automatically added

  4. Create UI Panels: Add child GameObjects for different UI sections:

    • MainMenuPanel
    • GameplayPanel
    • SettingsPanel
    • PausePanel

Step 7: Mobile-Specific Optimizations

Implement mobile performance optimizations:

Frame Rate Control

using UnityEngine;

public class MobilePerformanceManager : MonoBehaviour
{
    [Header("Performance Settings")]
    public int targetFrameRate = 60;
    public bool enableVSync = true;

    private void Start()
    {
        // Set target frame rate
        Application.targetFrameRate = targetFrameRate;

        // Enable VSync for smoother gameplay
        QualitySettings.vSyncCount = enableVSync ? 1 : 0;

        // Optimize for mobile
        OptimizeForMobile();
    }

    private void OptimizeForMobile()
    {
        // Disable unnecessary features
        QualitySettings.shadowDistance = 50f;
        QualitySettings.shadowResolution = ShadowResolution.Low;
        QualitySettings.shadowCascades = 1;

        // Optimize rendering
        QualitySettings.particleRaycastBudget = 256;
        QualitySettings.maxQueuedFrames = 2;
    }
}

Memory Management

using UnityEngine;

public class MobileMemoryManager : MonoBehaviour
{
    private void Start()
    {
        // Set memory limits
        Application.targetFrameRate = 60;

        // Enable garbage collection optimization
        System.GC.Collect();
    }

    private void OnApplicationPause(bool pauseStatus)
    {
        if (pauseStatus)
        {
            // Pause game and free memory
            Time.timeScale = 0f;
            System.GC.Collect();
        }
        else
        {
            // Resume game
            Time.timeScale = 1f;
        }
    }
}

Step 8: Create Basic Scene Structure

Set up your first game scene:

  1. Create New Scene: File → New Scene → 2D

  2. Save Scene: Save as "Gameplay" in Scenes folder

  3. Add Essential Objects:

    • Main Camera (configured for mobile)
    • InputManager (with MobileInputManager script)
    • PerformanceManager (with MobilePerformanceManager script)
    • UI Canvas (with mobile-optimized settings)
  4. Camera Configuration:

    • Size: 5 (adjust based on your game's needs)
    • Position: (0, 0, -10)
    • Clear Flags: Solid Color
    • Background: Choose a pleasant color for your puzzle game

Step 9: Mobile Testing Setup

Prepare for mobile testing:

  1. Build Settings: Add your scene to Build Settings
  2. Development Build: Enable "Development Build" for debugging
  3. Script Debugging: Enable "Script Debugging" for breakpoints
  4. Connect Device: Connect your Android/iOS device via USB
  5. Build and Run: Test on actual device for accurate performance

Mini-Challenge: Create Mobile Interface

Your challenge is to create a basic mobile interface for your puzzle game:

  1. Create Main Menu: Design a simple main menu with:

    • Game title
    • Play button
    • Settings button
    • Exit button
  2. Implement Touch Controls: Make buttons respond to touch input

  3. Test on Device: Build and test on your mobile device

  4. Optimize Performance: Ensure smooth 60 FPS gameplay

Troubleshooting Common Issues

Issue: Game runs slowly on mobile

Solution:

  • Reduce texture quality in Quality Settings
  • Disable unnecessary visual effects
  • Lower target frame rate to 30 FPS if needed
  • Use object pooling for frequently created/destroyed objects

Issue: Touch input not responsive

Solution:

  • Check Input Manager settings
  • Ensure UI elements have proper colliders
  • Verify touch sensitivity settings
  • Test on actual device (not just editor)

Issue: UI elements too small/large on different devices

Solution:

  • Use Canvas Scaler with Scale With Screen Size
  • Set proper reference resolution
  • Test on multiple device sizes
  • Use relative positioning instead of absolute

Pro Tips for Mobile Development

  1. Always Test on Device: The Unity editor doesn't accurately represent mobile performance
  2. Optimize Early: Don't wait until the end to optimize - it's much harder then
  3. Use Profiler: Unity's Profiler is essential for finding performance bottlenecks
  4. Consider Battery Life: Avoid unnecessary calculations and rendering
  5. Handle Interruptions: Implement proper pause/resume functionality

What's Next?

Congratulations! You've successfully set up a mobile-optimized Unity project. In the next lesson, you'll dive into creating the art pipeline and designing mobile-optimized assets for your puzzle game.

Next Lesson Preview: "Lesson 3: Mobile Art Pipeline" - You'll learn how to create scalable, mobile-optimized art assets and establish an efficient art workflow.

Key Takeaways

  • Mobile development requires specific Unity configurations
  • Touch input systems need careful implementation
  • Performance optimization is crucial from the start
  • Testing on actual devices is essential
  • Proper project structure saves time later

Community & Support

  • Share Your Setup: Post screenshots of your project structure in our Discord community
  • Get Feedback: Ask for feedback on your mobile interface design
  • Join Mobile Dev Channel: Connect with other mobile game developers
  • Ask Questions: Use the #mobile-development channel for technical help

Remember, mobile game development is a marathon, not a sprint. Take your time to set up a solid foundation, and you'll save hours of debugging later!


Ready to create beautiful mobile art assets? Let's move on to Lesson 3: Mobile Art Pipeline!