Objective: Provide a solid foundation for mobile game development in Unity, showcasing a modular Main Menu system, scene management, UI components, and project configuration.
unity-Mobile-game-Components-Basic/
├── **Assets/** # Unity assets: Scenes, Scripts, Prefabs, UI, Audio
│ ├── **Scenes/** # .unity scene files (MainMenu, Level1, etc.)
│ ├── **Scripts/** # C# scripts controlling game flow and UI
│ ├── **Prefabs/** # Reusable GameObjects (buttons, panels)
│ ├── **UI/** # Canvas, Button, Text, and other UI assets
│ └── **Audio/** # Background music and SFX clips
│
├── **Logs/** # Runtime log files (Editor & device)
├── **Packages/** # Package manifest (manifest.json)
├── **ProjectSettings/** # Unity project settings (Input, Tags, Graphics)
├── **UserSettings/** # Personal editor preferences (EditorUserSettings.asset)
├── **obj/Debug/** # Local build artifacts
├── Assembly-CSharp.csproj # C# project definition
├── Assembly-CSharp-Editor.csproj
├── all-files.txt # Listing of all files (utility)
├── ignore.conf # Custom ignore rules
└── mobile-Main-menu game.sln # Visual Studio solution for IDE support
- Unity: Version 2020.3 LTS or newer.
- Mobile Build Support: Install Android and/or iOS modules via Unity Hub.
- IDE: Visual Studio or Rider with Unity integration.
Clone & Open:
git clone https://github.com/Tharindu714/unity-Mobile-game-Components-Basic.git
cd unity-Mobile-game-Components-Basic
- Open
mobile-Main-menu game.sln
in your IDE (optional). - Launch Unity Hub, click Add, select the project folder, and Open.
-
MainMenu.unity: Entry scene, contains:
- Canvas with Buttons:
Start
,Options
,Quit
. - MainMenuManager script attached to an empty GameObject for handling button callbacks.
- Canvas with Buttons:
-
GameScene.unity: Placeholder for gameplay.
- Load scene with a SceneLoader script.
-
Options.unity (optional): Audio and control settings UI.
Scene Management Script (SceneLoader.cs
):
public class SceneLoader : MonoBehaviour {
public void LoadScene(string sceneName) {
SceneManager.LoadScene(sceneName);
}
}
- Usage: Hook each button’s OnClick() event to
LoadScene("GameScene")
orLoadScene("MainMenu")
.
Manages menu button logic:
public class MainMenuManager : MonoBehaviour {
public void OnStartGame() => SceneManager.LoadScene("GameScene");
public void OnOptions() => SceneManager.LoadScene("Options");
public void OnQuitGame() {
#if UNITY_EDITOR
UnityEditor.EditorApplication.isPlaying = false;
#else
Application.Quit();
#endif
}
}
- Attach to an empty GameObject in
MainMenu.unity
. - Assign UI Buttons to corresponding public methods.
Centralizes UI transitions and notifications:
public class UIManager : MonoBehaviour {
public GameObject panel;
public void TogglePanel() {
panel.SetActive(!panel.activeSelf);
}
}
- Use Case: Show/hide settings panels, help overlays, or pause menus.
- Button_Prefab: Standardized Unity UI Button with default font, size, and colors.
- Panel_Prefab: Background panel with
Image
component for grouping UI elements. - Text_Prefab: Default
TextMeshPro
text styling for titles and labels.
Tip: Keep UI elements as prefabs for consistent look & feel across scenes.
-
Player Settings (
ProjectSettings/ProjectSettings.asset
):- Company Name: e.g.,
Delta Codex
- Product Name:
MobileGameComponentsBasic
- Default Orientation: Portrait
- API Compatibility Level: .NET 4.x for modern C# features.
- Company Name: e.g.,
-
Input Settings (
InputManager.asset
):- Define Virtual Axes for
Horizontal
,Vertical
, and touch controls.
- Define Virtual Axes for
-
Build Settings:
- Platform: Switch to Android or iOS.
- Scenes In Build: Ensure
MainMenu
andGameScene
are checked.
-
Package Management:
- Check
Packages/manifest.json
for required packages:com.unity.textmeshpro
,com.unity.inputsystem
.
- Check
- Switch Platform in File ▶ Build Settings.
- Connect Android device via USB (enable USB debugging) or pair iOS device.
- Player Settings ▶ Other Settings: Set Bundle Identifier and Minimum API Level.
- Build And Run: Choose a location, Unity compiles and installs the APK/IPA.
- Runtime Logs: Stored under
Logs/
, reviewoutput.log
for errors on device. - Debugging: Use
Debug.Log()
,Debug.Warning()
, andDebug.Error()
in scripts.
- Gameplay Mechanics: Implement player controllers, enemy AI, and level progression.
- Settings Menu: Add volume sliders and control remapping.
- Analytics: Integrate Unity Analytics or Firebase for user metrics.
- Asset Optimization: Use Addressables for dynamic asset loading.
- Input System: Migrate to Unity’s New Input System for advanced touch gestures.
This README gives you a clear roadmap to explore each part of the Unity mobile template. Tweak, extend, and build upon it to launch your own mobile game. Happy developing!