https://github.com/tharindu714/unity-mobile-game-components-basic
Provide a solid foundation for mobile game development in Unity
https://github.com/tharindu714/unity-mobile-game-components-basic
csharp game-development mobile unity
Last synced: 4 months ago
JSON representation
Provide a solid foundation for mobile game development in Unity
- Host: GitHub
- URL: https://github.com/tharindu714/unity-mobile-game-components-basic
- Owner: Tharindu714
- Created: 2025-05-04T17:39:37.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-05-04T18:24:32.000Z (about 1 year ago)
- Last Synced: 2025-05-07T18:13:24.435Z (about 1 year ago)
- Topics: csharp, game-development, mobile, unity
- Language: C#
- Homepage:
- Size: 55.6 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Unity Mobile Game Components Basic Project ๐ฎ
> **Objective:** Provide a solid foundation for mobile game development in Unity, showcasing a modular Main Menu system, scene management, UI components, and project configuration.
---
## ๐ Project Structure
```
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
```
---
## ๐ ๏ธ Prerequisites & Setup
1. **Unity**: Version 2020.3 LTS or newer.
2. **Mobile Build Support**: Install Android and/or iOS modules via Unity Hub.
3. **IDE**: Visual Studio or Rider with Unity integration.
**Clone & Open**:
```bash
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**.
---
## ๐ฌ Scenes & Navigation Flow
1. **MainMenu.unity**: Entry scene, contains:
* **Canvas** with Buttons: `Start`, `Options`, `Quit`.
* **MainMenuManager** script attached to an empty GameObject for handling button callbacks.
2. **GameScene.unity**: Placeholder for gameplay.
* Load scene with a **SceneLoader** script.
3. **Options.unity** (optional): Audio and control settings UI.
**Scene Management Script** (`SceneLoader.cs`):
```csharp
public class SceneLoader : MonoBehaviour {
public void LoadScene(string sceneName) {
SceneManager.LoadScene(sceneName);
}
}
```
* **Usage**: Hook each buttonโs **OnClick()** event to `LoadScene("GameScene")` or `LoadScene("MainMenu")`.
---
## ๐ค Core Scripts
### 1. MainMenuManager.cs
Manages menu button logic:
```csharp
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.
### 2. UIManager.cs
Centralizes UI transitions and notifications:
```csharp
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.
---
## ๐จ Prefabs & UI Artifacts
* **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.
---
## โ๏ธ Project & Build Configuration
1. **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.
2. **Input Settings** (`InputManager.asset`):
* Define **Virtual Axes** for `Horizontal`, `Vertical`, and touch controls.
3. **Build Settings**:
* **Platform**: Switch to **Android** or **iOS**.
* **Scenes In Build**: Ensure `MainMenu` and `GameScene` are checked.
4. **Package Management**:
* Check `Packages/manifest.json` for required packages: `com.unity.textmeshpro`, `com.unity.inputsystem`.
---
## ๐ฑ Build & Run on Device
1. **Switch Platform** in **File โถ Build Settings**.
2. **Connect** Android device via USB (enable USB debugging) or pair iOS device.
3. **Player Settings โถ Other Settings**: Set **Bundle Identifier** and **Minimum API Level**.
4. **Build And Run**: Choose a location, Unity compiles and installs the APK/IPA.
---
## ๐ธ Screenshots
ย
---
## ๐ Logging & Diagnostics
* **Runtime Logs**: Stored under `Logs/`, review `output.log` for errors on device.
* **Debugging**: Use `Debug.Log()`, `Debug.Warning()`, and `Debug.Error()` in scripts.
---
## ๐ Next Steps & Enhancements
* **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!