Game Programming 2 Week 13-14 (2024) PDF

Document Details

HumorousObsidian2070

Uploaded by HumorousObsidian2070

Pamantasan ng Cabuyao

Renzo Evangelista

Tags

unity game programming software development course material

Summary

This document is course material for a Game Programming 2 course, covering the history of Unity and its application in various industries. It outlines numerous learning outcomes and resources and details Unity's timeline from 2004 to the present day. It offers an overview for users getting started with Unity.

Full Transcript

PAMANTASAN NG CABUYAO | Game Programming 2 1 CSEG3 Material No. 13-14 Game Programming 2 RENZO EVANGELISTA CSEG3 Instructor PAMANTASAN...

PAMANTASAN NG CABUYAO | Game Programming 2 1 CSEG3 Material No. 13-14 Game Programming 2 RENZO EVANGELISTA CSEG3 Instructor PAMANTASAN NG CABUYAO | Game Programming 2 2 History of Unity & Toolbar or tool equipment on Unity and Unity Import and Export 13-14 LEARNING OUTCOMES Here’s what I will teach you in this course material: Outline Unity’s history and its impact on industries. Navigate Unity’s toolbar and use essential tools. Manipulate objects using move, rotate, and scale tools. Organize GameObjects in the Hierarchy for workflow efficiency. Import assets from external sources into Unity projects. Export projects across platforms, understanding platform-specific requirements. Debug using the Console to maintain project stability. Adjust animation and lighting settings to enhance scene visuals. RESOURCES NEEDED For this lesson, you would need the following resources: Basic Structure of Computers Google Form Google Meet PAMANTASAN NG CABUYAO | Game Programming 2 3 Unity Unity is a widely popular game engine known for its versatility, enabling developers to create 2D and 3D games as well as experiences in augmented reality (AR) and virtual reality (VR). Since its inception, Unity has transformed from a small project into an industry-standard tool, not only for games but also for applications across various fields. Let’s explore how it developed: 2004: Unity Technologies was founded in Copenhagen, Denmark, by David Helgason, Nicholas Francis, and Joachim Ante. The founders aimed to democratize game development by making powerful tools accessible to smaller studios and independent developers. 2005: The launch of Unity 1.0 brought an intuitive game engine primarily for Mac OS users. The founders focused on making it easy to use and affordable, offering developers a suite of tools without needing extensive coding knowledge. Unity 1.0 introduced features like integrated physics, shaders, and 3D assets, distinguishing it from other engines of the time. 2007: Unity expanded its compatibility to Windows and Web platforms. This update allowed more developers to access the engine, and it quickly became a go-to choice for indie game developers seeking a reliable, cost- effective tool. The accessibility led to the growth of a dedicated community of Unity users who shared resources and tips, furthering Unity's popularity. 2010s: During this decade, Unity gained a reputation for being incredibly versatile and affordable. Its cross-platform capabilities meant that developers could create a game once and publish it across multiple platforms, such as iOS, Android, PlayStation, and more. Unity's popularity surged, and its Asset Store was launched, giving developers access to a vast library of assets, tools, and plugins that enhanced project development. Unity's influence also extended beyond games, being adopted in fields such as automotive, film, architecture, and education, thanks to its real-time rendering capabilities. Today: Unity is one of the most widely used game engines globally, with millions of users. It is essential in both indie and major game studios, used to develop high-quality mobile and console games. Unity’s functionality now includes support for complex animations, VR and AR integrations, and machine learning. Its impact has expanded across industries like automotive, where it’s used for virtual prototyping and simulations, and film, where it aids in pre-visualizations and cinematics. The Unity community continues to grow, contributing to its ever-expanding Asset Store and sharing knowledge through tutorials, forums, and conferences. PAMANTASAN NG CABUYAO | Game Programming 2 4 Unity toolbar The Unity toolbar is an essential part of the Unity Editor, containing a variety of functions that help streamline project creation and management. By accessing the toolbar, users can navigate, configure, and customize nearly every aspect of their project. Below is an in-depth look at the primary toolbar sections and their key functions: 1. File Menu The File menu is where users can manage their project files. Here, you can: Create a New Project: Start a new project from scratch, selecting settings like platform and template. Open Existing Projects: Quickly open previous projects saved on your machine or network. Save and Save As: Save changes to the current project or create a copy with a new name. Build Settings: Configure export settings to prepare the project for different platforms, including Android, iOS, Windows, and WebGL. Exit Unity: Close the editor and save the current session. PAMANTASAN NG CABUYAO | Game Programming 2 5 2. Edit Menu The Edit menu provides access to standard editing tools as well as project and editor settings: Undo/Redo: Undo or redo the most recent actions, allowing easy corrections without redoing work. Cut, Copy, Paste, and Duplicate: Manage assets and GameObjects within the project by copying, pasting, and duplicating. Project Settings: Access essential project configurations, including Quality, Audio, Physics, and Input settings. Preferences: Adjust Unity’s editor settings, such as theme, layout, and behavior, to personalize your workflow. PAMANTASAN NG CABUYAO | Game Programming 2 6 3. Assets Menu The Assets menu is dedicated to managing assets in the project, such as 3D models, textures, audio, and scripts: Import New Asset: Import various file formats (e.g., FBX, PNG, WAV) directly into the project. Create New Assets: Create new assets directly within Unity, including materials, animations, and scripts. Package Manager: Access the Package Manager to install, update, or remove packages from the Unity Asset Store, such as TextMesh Pro or Post- Processing Stack. Export Package: Export selected assets as a.unitypackage file for reuse in other projects or for sharing. Refresh: Reload and re-import assets, helpful when making external changes to files. PAMANTASAN NG CABUYAO | Game Programming 2 7 4. GameObject Menu The GameObject menu allows you to add and organize objects in the scene. It’s central to building the hierarchy of elements in a Unity project: Create New Objects: Add essential GameObjects like cameras, lights, and basic 3D shapes (cubes, spheres, planes). Create Empty: Add an empty GameObject to serve as a parent or holder for organizing objects in the scene. UI Elements: Quickly add UI elements such as buttons, text fields, and sliders to create in-game interfaces. 3D and 2D Objects: Select from basic geometric shapes, sprites, and other objects to populate the scene. PAMANTASAN NG CABUYAO | Game Programming 2 8 5. Component Menu The Component menu is vital for adding functionality to GameObjects by attaching components: Physics Components: Attach physical behaviors like Rigidbody, Collider, or Physics Materials, allowing for realistic motion and collision effects. Rendering Components: Modify how objects are displayed in the scene, using Mesh Renderer, Sprite Renderer, or Particle System components. Audio Components: Add Audio Source and Audio Listener components to incorporate sound effects and background music. Scripts: Attach custom C# scripts to GameObjects, allowing you to control behaviors and interactions programmatically. Navigation: Add navigation-related components like NavMesh and NavMeshAgent to create AI pathfinding for characters. PAMANTASAN NG CABUYAO | Game Programming 2 9 6. Window Menu The Window menu opens various panels and views essential for developing projects in Unity: Scene View and Game View: Access different views to design the environment and preview the gameplay. Animation and Animator: Open tools for animating objects, such as character movements or UI effects. Asset Store: Quickly access the Unity Asset Store for purchasing or downloading assets directly into your project. Package Manager: A dedicated window for managing and updating Unity packages. Console: Displays error messages, warnings, and debug information to help with troubleshooting. Layout Customization: Customize and save editor layouts for different workflows, such as Animation, Coding, or Lighting. PAMANTASAN NG CABUYAO | Game Programming 2 10 7. Help Menu The Help menu provides resources to assist you in learning and troubleshooting: Unity Documentation: Access Unity’s extensive online documentation for detailed explanations of all features and components. Unity Forum and Answers: Connect with the Unity community for support, insights, and solutions to common issues. Issue Tracker: View known issues with Unity and report any bugs you encounter. Check for Updates: Ensure your Unity version is up to date for access to the latest features and improvements. PAMANTASAN NG CABUYAO | Game Programming 2 11 Unity editor The Unity editor includes a variety of tools and windows that make it easier to build and manage 3D, 2D, and virtual reality environments. These tools, accessible from the toolbar and different interface panels, help developers place objects, organize project assets, set object properties, and troubleshoot code. Let’s look at these essential components in detail: 1. Scene View The Scene View is the primary workspace in Unity, where users build their environment by placing and manipulating objects within a 3D or 2D space. It serves as a real-time editor where developers can add GameObjects (like characters, terrain, and props), adjust lighting, and apply visual effects. Navigation: Users can pan, zoom, and rotate around the scene, allowing for precise positioning of objects. Gizmos: Visual tools within the Scene View that show location, scale, and orientation of objects, making it easier to understand object relationships in 3D space. Lighting and Effects: Developers can add and adjust lights, shadows, and other visual effects directly within the Scene View. PAMANTASAN NG CABUYAO | Game Programming 2 12 2. Game View The Game View is a preview window that shows how the scene will look from the perspective of the player. This view is particularly useful for testing gameplay and checking visual elements. Aspect Ratios and Resolutions: Allows developers to test how their game will appear across different screen sizes and resolutions. Play Mode: Developers can test gameplay mechanics and interactions by entering Play Mode, which temporarily simulates the game's behavior. Pause and Step: These options in the toolbar allow developers to pause the game during Play Mode or move forward frame by frame, helpful for debugging animations or scripts. PAMANTASAN NG CABUYAO | Game Programming 2 13 3. Inspector The Inspector window displays all properties and settings of the currently selected GameObject or asset. Each component attached to the object (e.g., Transform, Collider, Renderer) is shown here with adjustable settings. Editing Properties: Developers can adjust position, rotation, scale, materials, colors, and more within the Inspector. Component Management: Add or remove components to change an object’s functionality (e.g., add a Rigidbody for physics or a Collider for interaction). Scripts: The Inspector allows easy access to scripts attached to GameObjects, letting developers adjust public variables directly from the editor. PAMANTASAN NG CABUYAO | Game Programming 2 14 4. Hierarchy The Hierarchy window shows a list of all GameObjects in the current scene, displayed in a tree structure. This window helps organize and group objects logically, making complex scenes easier to manage. Parent-Child Relationships: By creating a parent-child structure, users can move or scale multiple objects as a single unit, which is helpful for animations or organizing components. Naming and Grouping: Naming objects clearly and grouping them in the hierarchy improves readability and efficiency. Search and Filtering: With a search bar and filters, users can quickly locate specific objects, even in large scenes. PAMANTASAN NG CABUYAO | Game Programming 2 15 5. Project Window The Project Window is the main asset manager in Unity. It organizes all files used within a project, including models, textures, audio files, and scripts. Folder Structure: Users can create and manage folders to keep assets organized by type or function. Asset Importing: Imported assets (e.g., 3D models, textures, audio) appear in this window, allowing easy access to files. Preview Pane: Displays a small preview of the selected asset, helping developers confirm the content without opening it fully. PAMANTASAN NG CABUYAO | Game Programming 2 16 6. Transform Tools The Transform Tools consist of Move, Rotate, Scale, and Rect tools that are essential for modifying the position, orientation, and size of GameObjects within the Scene View. Move Tool: Allows for the precise positioning of objects along the X, Y, and Z axes. Rotate Tool: Adjusts the object’s orientation by rotating it around the selected axis. Scale Tool: Modifies an object’s size along each axis individually or uniformly. Rect Tool: Primarily for 2D objects, it helps scale and position UI elements or sprites with greater accuracy. Shortcut Keys: Transform tools can be quickly accessed using shortcut keys, improving workflow speed. 7. Console The Console window displays messages, warnings, and error logs generated by the Unity editor or runtime scripts. It’s essential for troubleshooting and debugging. Error Messages: Highlight issues in the project, often pinpointing where a script or asset may need correction. Warnings: Indicate potential issues that may not break functionality but could impact performance or usability. Custom Messages: Developers can create custom log messages (using Debug.Log) within scripts to track events or variables, assisting in more specific debugging. PAMANTASAN NG CABUYAO | Game Programming 2 17 8. Additional Toolbar Features In addition to these primary tools, Unity’s toolbar offers various options for adjusting view and workflow settings. Play, Pause, and Step Controls: Located in the center of the toolbar, these options control the playback of the game in the editor, allowing developers to test functionality and inspect frame-by-frame interactions. Layer and Layout Options: Unity lets users toggle layers on and off to focus on specific elements of the scene. Layout options allow customization of the workspace, letting users save layouts for different tasks (e.g., animation, code editing, or design). Search Bar: Quickly locate assets or GameObjects by typing keywords, which is especially useful for large projects. PAMANTASAN NG CABUYAO | Game Programming 2 18 Unity’s importing and exporting Unity’s importing and exporting functionalities allow developers to bring in external assets (such as 3D models, images, audio, and scripts) and export finished projects across multiple platforms. These capabilities make Unity a powerful, versatile tool for content creation, providing a streamlined process for integrating a variety of media types and deploying projects to multiple devices. 1. Importing Assets into Unity Importing assets is a crucial first step in building any Unity project. Assets include everything from 3D models, textures, audio files, and scripts, all of which can be created externally and then integrated into Unity for use within a scene. Unity provides several methods to import assets: Unity Asset Store The Unity Asset Store is a rich repository of pre-made assets and tools, both free and paid, that developers can incorporate into their projects. It includes: 3D Models and Animations: Assets like characters, props, vehicles, and animated rigs that are ready to use in-game. Textures and Materials: High-quality textures and materials that add realism and style to scenes. Scripts and Plugins: Pre-built scripts and plugins that can streamline common tasks (like camera controls or AI behavior). Audio: Background music, sound effects, and ambient audio resources. Using the Asset Store, developers can search for and directly download assets into their projects, saving time on creating these from scratch. The Asset Store also frequently updates with community contributions, ensuring a vast selection. Unity Asset Store link: https://assetstore.unity.com/ Drag-and-Drop Importing Unity supports drag-and-drop functionality, allowing users to import assets quickly: Supported Formats: Commonly supported files include 3D models (.fbx,.obj), images (.png,.jpg), audio (.mp3,.wav), and video (.mp4). Import Process: Simply drag these files from your system’s file explorer into Unity’s Project Window to add them to your project. Unity will automatically recognize and format these files to be used within the editor. Automatic Import Settings: Upon import, Unity generates settings for each file, such as texture resolution, audio quality, and mesh properties, which can be customized as needed. PAMANTASAN NG CABUYAO | Game Programming 2 19 A. Importing Unity Packages Unity packages (files with a.unitypackage extension) are collections of pre- configured assets, components, or even entire scenes, often created to be easily shared or reused: Built-in Packages: Unity comes with several built-in packages, such as Post- Processing, TextMesh Pro, and 2D Animation, which can be installed and used in projects. Custom Packages: Developers can also create custom.unitypackage files containing assets and settings for reuse in other projects or for sharing with other team members. Importing Process: To import a package, use Assets > Import Package from the top menu, select the.unitypackage file, and choose which assets to include. PAMANTASAN NG CABUYAO | Game Programming 2 20 Step 1: Go Assets Menu Step 2: Click Import Package, then click Custom Package PAMANTASAN NG CABUYAO | Game Programming 2 21 Step 3: Search for or browse the Unity package file on your device, then click Open button. Asset Import Settings After importing an asset, Unity provides Asset Import Settings that let developers configure the imported asset for optimal performance and appearance in the game: Model Import Settings: Adjust the mesh scale, set up colliders, enable animations, and choose material settings. Texture Settings: Configure texture type (2D, Sprite, UI), compression quality, and resolution. Audio Settings: Set sample rate, mono or stereo configuration, and enable looping if needed. PAMANTASAN NG CABUYAO | Game Programming 2 22 B. Exporting Assets into Unity Exporting assets in Unity involves packaging your assets (such as textures, models, scripts, and other resources) into a Unity package file (.unitypackage). Here's how you can do it: Steps to Export Assets in Unity: 1. Open your Unity Project: o Launch Unity and open the project containing the assets you want to export. 2. Select the Assets: o In the Project window, find and select the assets you want to export. You can select multiple assets by holding down Ctrl (Windows) or Cmd (Mac) while clicking on each asset. 3. Right-Click the Selected Assets: o Once the assets are selected, right-click on one of them to open the context menu. 4. Choose "Export Package...": o From the context menu, select Export Package.... This will open the Export Package window. 5. Configure the Export Settings: o In the Export Package window, you can choose whether to include dependencies (related assets, scripts, materials, etc.) by checking or unchecking the corresponding boxes. o If you want to export everything related to the selected assets, make sure the Include Dependencies box is checked. 6. Export the Package: o After configuring the export settings, click the Export... button. o Choose a location on your device to save the.unitypackage file and give it a name. 7. Complete the Export: o Unity will now export your selected assets into a.unitypackage file, which you can share or import into another Unity project. PAMANTASAN NG CABUYAO | Game Programming 2 23 Note: Before doing the step-by-step process of exporting assets, always save the file. Step 1: Go Assets Menu Step 2: Click Export Package PAMANTASAN NG CABUYAO | Game Programming 2 24 Step 3: Select the assets to export, then click the export button. Step 4: Enter the file name, select 'Unity Package' as the file type, and then click the 'Save' button. PAMANTASAN NG CABUYAO | Game Programming 2 25 2. Exporting in Unity Exporting allows Unity developers to deploy their finished projects to different platforms, such as PC, mobile devices, consoles, and the web. Unity’s cross- platform compatibility enables developers to build once and deploy on multiple devices, with specific settings for each platform. Build Settings Unity’s Build Settings window (accessible via File > Build Settings) is where developers configure export options: Platform Selection: Choose from supported platforms like Windows, macOS, iOS, Android, WebGL, PlayStation, Xbox, and more. Switch Platform: When a platform is selected, Unity will optimize the project settings for that platform, which may include adjusting shaders, compression, and code compatibility. Scenes in Build: The developer selects which scenes to include in the final build, allowing for multiple levels or environments. Platform-Specific Settings Each platform has unique settings that can be configured within the Build Settings: PC and Console Settings: Developers can set screen resolution, quality settings, input configurations, and choose to allow fullscreen mode. Mobile Settings (iOS/Android): Includes options for screen orientation, resolution scaling, touch inputs, and platform-specific features like Android permissions or iOS app icons. WebGL Settings: Provides settings for WebGL compression, loading optimizations, and web performance enhancements. Exporting the Project Once build settings are configured, developers can proceed with the export: Build Process: Unity compiles the project into an executable format for the chosen platform. The build process may take time depending on the project size and complexity. Testing and Optimization: It’s common to test builds on actual devices (e.g., mobile phones, consoles) to ensure compatibility and performance. Distributing the Build: After export, the build can be distributed through various channels like app stores (Google Play, Apple App Store), digital distribution platforms (Steam, Epic Games), or directly as a downloadable file. PAMANTASAN NG CABUYAO | Game Programming 2 26 Step 1: Go File Menu, then click Build Settings Step 2: Select or deselect the scene to be exported on the device, then click the Build button. PAMANTASAN NG CABUYAO | Game Programming 2 27 Step 3: Select a folder, then click 'Select Folder' to start exporting the game. PAMANTASAN NG CABUYAO | Game Programming 2 28 3. Exporting and Importing Entire Projects Beyond individual assets, Unity also supports the import and export of entire projects. This is useful when collaborating across teams or moving a project to another device. Exporting Projects Project Folder Transfer: The simplest way to transfer a project is to copy the entire project folder, which contains all assets, scenes, scripts, and settings. Version Control: For collaborative projects, Unity integrates with Git and other version control systems (e.g., Perforce, Plastic SCM), allowing team members to track changes, commit updates, and revert files as needed. Unity Collaborate: Unity Collaborate, part of Unity Teams, is a built-in version control option for teams that allows developers to share projects and synchronize changes. Importing Projects Open Existing Project: Use File > Open Project to load an existing project, whether it’s stored locally or on a cloud service. Import from Version Control: Projects stored on platforms like GitHub, GitLab, or Unity Collaborate can be pulled and synced into Unity, allowing team members to work on the same project. Package Import: For projects shared as.unitypackage files, use Assets > Import Package > Custom Package to add all the necessary files and assets from the package into the new project. PAMANTASAN NG CABUYAO | Game Programming 2 29 Additional Unity to android studio Step 1: Export the game on unity Step 2: Import on Android studio A. Go File Menu, then click the open B. Search for or browse the unity package folder, then click ok button. Note: Android logo the folder, if not there be a error on the export on unity. PAMANTASAN NG CABUYAO | Game Programming 2 30 Step 3: Click Build menu After import on android studio the file of unitypackage, go build menu. Step 4: Click the generate signed bundle /apk PAMANTASAN NG CABUYAO | Game Programming 2 31 Step 5: Select the android app bundle, then click next button PAMANTASAN NG CABUYAO | Game Programming 2 32 Step 6: Enter the key store path, key store password, key alias, key password Select the remember password, then unselect the export encrypted key for enrolling published apps in google play app signing. Then click the next button. Key Store Password: 123456 Key Password: 123456 Key Alias: key0 PAMANTASAN NG CABUYAO | Game Programming 2 33 Step 7: Select the release, then click the create. Output: filename.aab PAMANTASAN NG CABUYAO | Game Programming 2 34 --------------------------------------------------------------------------------------------------------------------- Android Studio to Command prompt Code: java -jar bundletool-all-1.17.2.jar build-apks --bundle="launcher- release.aab" --output=myapp.apks --mode=universal Step 1: Go the folder of export of android studio. Note: Same folder of bundletool and launcher-release.aab Step 2: Click the left mouse, then open in terminal PAMANTASAN NG CABUYAO | Game Programming 2 35 Step 3: Type the code of java -jar bundletool-all-1.17.2.jar build-apks -- bundle="launcher-release.aab" --output=myapp.apks --mode=universal. Then enter wait appear the INFO: The APKs will be signed with the debug keystore found at 'C:\Users\Renzo\.android\debug.keystore'. Then input the keystore of: 123456 Step 4: Automatic appear the myapp.apks PAMANTASAN NG CABUYAO | Game Programming 2 36 Step 5: Convert or rename the myapp.apks to myapp.zip Step 6: Extract the myapp Step 7: Open the folder of myapp Output filename.apk PAMANTASAN NG CABUYAO | Game Programming 2 37 Youtube Link tutorial(aab to apk) https://www.youtube.com/watch?v=IRosxRo7R8o Bundle tool link https://github.com/google/bundletool/releases Document StackOverflow aab to apk https://stackoverflow.com/questions/53040047/generate-an-apk-file-from-an- aab-file-android-app-bundle

Use Quizgecko on...
Browser
Browser