unity 3D etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
unity 3D etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster

Asset Management and Modularity in Unity

 


Hello there! I took a break from writing about Unity and game development for a while, but now that I’m back, I can share what I’ve learned with you. For me, developing games with Unity is a creative and exciting process, but it is also very important to manage projects in an organized and efficient way. In this article, we will discuss asset management and modularity in Unity in detail. Let’s get started!

1. What is Asset and Why is it Important?

An Asset is any kind of item you add to your game in Unity. This includes various components such as graphics, sounds, animations, materials and scripts. Assets are the basic building blocks that make up your game.

Why is it important?

-Game Quality: Well-managed assets directly affect the quality and performance of your game.

-Development Process: An organized asset management accelerates the development process and increases efficiency.

-Teamwork: If you are working with a team, proper asset management makes it easier for team members to access the same resources.

2. Tips for Asset Management

Organize Folder Structure

In Unity projects, you need a good folder structure to keep your assets organized. You can create a structure like the one below:

  • Assets/: The main asset folder of your project.
  • Models/: 3D models and prefabs.
  • Textures/: 2D textures and sprites.
  • Materials/: Materials and shaders.
  • Sounds/: Sound effects and music files.
  • Animations/: Animation clips and animation controllers.
  • Scripts/: C# scripts and code files.
  • Prefabs/: Prefabs and reusable assets.

This structure makes it easier to find your assets and keeps your project organized.

Care About Naming Conventions

It is important to use a consistent and understandable naming structure when naming your Assets. Good naming should have the following characteristics:

  • Descriptive: Use descriptive names that indicate what the Asset is. For example, Player_Character_Model or Enemy_Alien_Texture.
  • Consistent: Apply the same naming standards across the entire project. This makes it easier to find and understand your assets.
  • Keep it simple: Names should be short and concise, but also clearly describe the content of the asset.

Clean Unnecessary Assets

Having unused or old assets in the project can lead to project clutter and increased load times. Periodically review the project and take the following steps:

  • Asset Removal: Remove unused assets from your project files.
  • Cleaning Tools: You can use tools from the Unity Asset Store or third-party tools to help you clean up.

3. What is Modularity and Why is it Important?

Modularity means breaking down the various components of your game into independent and reusable parts. This allows you to develop each component separately and use them in different places.

Why is it important?

  • Reusability: You can use the same component in multiple places.
  • Easy Maintenance: Changes to one component allow you to easily check their impact on the whole project.
  • Fast Development: Modular structures speed up adding new features and updating existing ones.

4. How to achieve modularity?

Use of Prefab

Prefabs allow you to create templates of an asset (or group of assets). For example, you can create a character prefab and use that prefab multiple times on stage.

  • Creating a prefab: Place an object on the stage and then drag it to the Assets folder to create a prefab.
  • Edit a prefab: When you edit a prefab, it automatically updates all instances in scenes.

ScriptableObjects

ScriptableObjects simplify data management and allow you to reuse that data in different places. For example, you can store a character’s health, speed and other properties with a ScriptableObject.

  • Creating a ScriptableObject: Create a new C# script in Assets and derive it from the ScriptableObjects class.
  • Data Storage: You can use ScriptableObjects to store in-game data (for example, character properties) and use this data in different places.

Modular Scene Design

Modularity in scene design means breaking scenes into small pieces. This allows you to design and organize each part of your scene individually.

  • Modular Parts: Break large scenes into small parts. For example, in a city scene, design buildings, roads and other elements separately.
  • Using Prefabs: Create modular parts as prefabs so you can use them in different scenes.

I hope you found this article useful! If you appreciate the information provided, you have the option to support me by Buying Me A Coffee! Your gesture would be greatly appreciated!


Asset management and modularity in Unity make your projects more organized, efficient and scalable. Good asset management improves the performance of projects and speeds up the development process. Modularity makes it easier to develop game components independently and make changes to projects.

The tips shared in this article can help you manage your Unity projects more efficiently.

Good work and good luck!

Selin.

Unity’de Asset Yönetimi ve Modülerlik

 

Merhaba! Unity ile ilgili yazılarıma ve oyun geliştirmeye bir süre ara vermiştim, şimdi yeniden başladığıma göre öğrendiklerimi sizinle paylaşabilirim. Benim için Unity ile oyun geliştirmek, yaratıcı ve heyecan verici bir süreç, ancak projelerin düzenli ve verimli yönetilmesi de çok önemli. Bu yazıda, Unity’de asset yönetimi ve modülerlik konularını detaylı bir şekilde ele alacağız. Hadi başlayalım!

1. Asset Nedir ve Neden Önemlidir?

Asset, Unity’de oyununuza eklediğiniz her türlü öğedir. Bu, grafikler, sesler, animasyonlar, materyaller ve scriptler gibi çeşitli bileşenleri içerir. Asset’ler, oyununuzu oluşturan temel yapı taşlarıdır.

Neden önemlidir?

-Oyun Kalitesi: İyi yönetilen asset’ler, oyununuzun kalitesini ve performansını doğrudan etkiler.

-Geliştirme Süreci: Düzenli bir asset yönetimi, geliştirme sürecini hızlandırır ve verimliliği artırır.

-Takım Çalışması: Eğer bir ekiple çalışıyorsanız, düzgün bir asset yönetimi, ekip üyelerinin aynı kaynaklara erişimini kolaylaştırır.

2. Asset Yönetimi İçin İpuçları

Klasör Yapısını Düzenleyin

Unity projelerinde, asset’lerinizi düzenli bir şekilde saklamak için iyi bir klasör yapısına ihtiyacınız vardır. Aşağıdaki gibi bir yapı oluşturabilirsiniz:

  • Assets/: Projenizin ana asset klasörü.
  • Models/: 3D modeller ve prefab’lar.
  • Textures/: 2D dokular ve sprite’lar.
  • Materials/: Malzemeler ve shaderlar.
  • Sounds/: Ses efektleri ve müzik dosyaları.
  • Animations/: Animasyon klipleri ve animasyon kontrolcüler.
  • Scripts/: C# scriptleri ve kod dosyaları.
  • Prefabs/: Prefab’lar ve yeniden kullanılabilir varlıklar.

Bu yapı, asset’lerinizi bulmayı kolaylaştırır ve projenizin düzenini korur.

İsimlendirme Kurallarına Uyun

Asset’lerinizi adlandırırken tutarlı ve anlaşılır bir isimlendirme yapısı kullanmak önemlidir. İyi bir isimlendirme şu özelliklere sahip olmalıdır:

  • Açıklayıcı olsun: Asset’in ne olduğunu belirten açıklayıcı isimler kullanın. Örneğin, Player_Character_Model veya Enemy_Alien_Texture.
  • Tutarlı olsun: Tüm projede aynı isimlendirme standartlarını uygulayın. Bu, asset’lerinizi bulmayı ve anlamayı kolaylaştırır.
  • Sade olsun: İsimler kısa ve öz olmalı, fakat aynı zamanda asset’in içeriğini net bir şekilde tanımlamalıdır.

Gereksiz Asset’leri Temizleyin

Kullanılmayan veya eski asset’lerin projede bulunması, projenin karmaşasına ve yükleme sürelerinin artmasına neden olabilir. Düzenli aralıklarla projeyi gözden geçirin ve aşağıdaki adımları uygulayın:

  • Asset Kaldırma: Kullanılmayan asset’leri proje dosyalarınızdan kaldırın.
  • Temizlik Araçları: Unity Asset Store’dan veya üçüncü taraf araçlardan temizlik yapmanıza yardımcı olacak araçlar kullanabilirsiniz.

3. Modülerlik Nedir ve Neden Önemlidir?

Modülerlik, oyununuzun çeşitli bileşenlerini bağımsız ve yeniden kullanılabilir parçalara ayırmak anlamına gelir. Bu, her bir bileşeni ayrı ayrı geliştirebilmenizi ve bu bileşenleri farklı yerlerde kullanabilmenizi sağlar.

Neden önemlidir?

  • Yeniden Kullanılabilirlik: Aynı bileşeni birden fazla yerde kullanabilirsiniz.
  • Kolay Bakım: Bir bileşende yapılan değişiklikler, tüm proje üzerindeki etkilerini kolayca kontrol edebilmenizi sağlar.
  • Hızlı Geliştirme: Modüler yapılar, yeni özellikler eklemeyi ve mevcut özellikleri güncellemeyi hızlandırır.

4. Modülerlik Nasıl Sağlanır?

Prefab Kullanımı

Prefab’lar, bir varlığın (veya varlık grubunun) şablonlarını oluşturmanıza olanak tanır. Örneğin, bir karakter prefab’ı oluşturup, sahnede bu prefab’ı birden fazla kez kullanabilirsiniz.

  • Prefab Oluşturma: Bir nesneyi sahneye yerleştirin ve ardından bu nesneyi Assets klasörüne sürükleyerek bir prefab oluşturun.
  • Prefab Düzenleme: Prefab’ı düzenlediğinizde, sahnelerdeki tüm örnekleri otomatik olarak günceller.

ScriptableObjects

ScriptableObject’lar, veri yönetimini kolaylaştırır ve bu veriyi farklı yerlerde yeniden kullanmanıza olanak tanır. Örneğin, bir karakterin sağlık, hız ve diğer özelliklerini ScriptableObject ile saklayabilirsiniz.

  • ScriptableObject OluşturmaAssets içinde yeni bir C# script oluşturun ve bu script’i ScriptableObjectsınıfından türetin.
  • Veri Saklama: ScriptableObject’ları kullanarak oyun içi verileri (örneğin, karakter özellikleri) saklayabilir ve bu verileri farklı yerlerde kullanabilirsiniz.

Modular Scene Design

Sahne tasarımında modülerlik, sahneleri küçük parçalara ayırmak anlamına gelir. Bu, sahnenizin her parçasını ayrı ayrı tasarlayıp düzenlemenizi sağlar.

  • Modüler Parçalar: Büyük sahneleri küçük parçalara ayırın. Örneğin, bir şehir sahnesinde binaları, yolları ve diğer öğeleri ayrı ayrı tasarlayın.
  • Prefab’lar Kullanımı: Modüler parçaları prefab olarak oluşturun, böylece bu parçaları farklı sahnelerde kullanabilirsiniz.

Unity’de asset yönetimi ve modülerlik, projelerinizi daha düzenli, verimli ve ölçeklenebilir hale getirir. İyi bir asset yönetimi, projelerdeki performansı artırır ve geliştirme sürecini hızlandırır. Modüler yapı ise, oyun bileşenlerini bağımsız olarak geliştirmenizi ve projelerde değişiklik yapmayı kolaylaştırır.

Bu yazıda paylaşılan ipuçları, Unity projelerinizi daha verimli yönetmenize yardımcı olabilir.

İyi çalışmalar ve bol şans!

Selin.

Performance Optimisation in Unity: Tips for Smoother and More Efficient Games

 

Unity and Performance Optimization

Hello everyone,

In this article, I will talk about performance, which is sometimes overlooked by most developers, including me, in the early stages of the game development process, but is very important. I said very important because performance is a critical factor that directly affects the player experience. In order to offer a smoother and more enjoyable experience to the players and to make our game more demanded and played, we need to develop by paying attention to details such as high frame rates (FPS) and low latency. Unity is a very powerful game engine in this sense, and when used correctly, it helps us develop high-performance games. Since I have experienced that it is so important, I have researched what we can do for performance optimisation with Unity, what are the most effective techniques and tips. Let’s get started.

1. Using Profiler

Unity Profiler is a tool for analysing game performance. Profiler monitors CPU and GPU usage, memory allocation, and other performance metrics. Thanks to this tool, we have the chance to identify the source of performance problems and find solutions for them.

How to use it?

  • First of all, we use Window => Analysis => Profiler to open the Profiler window. With this, we aim to see performance data.
  • Then we run Profiler while playing our game and wait for it to collect data in real time. By analysing the performance in different scenes, we get a feedback from the game.
  • At this point, we analyse the data we collect. For this, we can examine different tabs such as CPU, GPU, Rendering, Memory in the Profiler window and identify performance degrading points here.

2. Optimising Graphics Settings

LOD (Level of Detail) Usage

LOD allows distant objects to be rendered with less detailed models. This improves performance, especially in large scenes, by de-detailing some of the objects in the game.

  • Creating LOD Groups: In a game, we can create different levels of detail to let Unity know which objects should be rendered in more detail and which ones don’t need all the detail. We do this mostly for objects and manage it with the LOD Group component. Thus, especially in large scenes, objects that are not in sight are rendered with less detailed models and performance is increased.
  • Culling: We can improve performance by setting a game plan so that we do not need to render objects outside the camera field of view. We can increase performance by using Occlusion Culling.

Batching Techniques

  • Static Batching: Used for static (motionless) objects. It renders many objects with a single draw call.
  • Dynamic Batching: Used for dynamic (moving) objects. Reduces the number of draw calls by combining small and similar objects.

3. Physics and Collision Optimisation

Rigidbody and Collider Settings

  • Adding Rigidbody component unnecessarily may cause performance degradation. Instead, it is sufficient to add it only to objects that interact physically.
  • Another point about game performance is to use simpler Collider types if possible. Examples of simple Collider types are Box and Sphere. Using Mesh Colliders instead of more standardised ones like these can negatively affect performance.

Physics Simulation

  • Physics simulation is important to make the game realistic. However, physics calculations are often resource intensive, which affects game performance. The first thing we can do to prevent this is to set the Fixed Timestep value. The physics simulation is updated at certain time intervals, not every frame. This interval is called Fixed Timestep and we can set it in Edit => Project Settings => Time. This value is set to 0.02 (50 FPS) by default. We can adjust this value according to our game and performance requirements. A higher value means fewer physics updates, which can improve performance, but may reduce the accuracy of the physics simulation.
  • Another topic is what can be done with Physics Layers. Physics layers control which objects collide with each other. We can use these layers to prevent unnecessary collision checks. First we create new layers in Edit => Project Settings => Tags and Layers. Then we assign objects to the appropriate layers from the Inspector panel. Finally, in Edit => Project Settings => Physics, we determine which layers will collide with each other. For example, there may be collisions between player and bullet layers, but not between background objects and bullets. In this case, the unnecessary collision does not need to run in the background. And certainly not to degrade performance.

4. Memory Management

Object Pooling

  • This method allows us to create a certain number of objects in advance for frequently created and destroyed objects and reuse them. Especially since continuous creation and destruction of new objects can negatively affect performance, we can reduce this cost and prevent performance degradation with object pooling. Let’s also mention a few points to be considered while doing this. It is important to determine the initial size of the pool according to the needs of our game. A pool that is too small may cause continuous creation of new objects; a pool that is too large means unnecessary memory usage. Then what we do will not have the desired effect on performance. We should also keep a good track of the state of the objects. Objects must be made suitable for reuse. For example, bullets should return to the pool when they reach the target or after a certain period of time. Finally, when returning objects to the pool, we must remember to deactivate them. This prevents the objects from performing unnecessary calculations.
  • We also need to avoid creating new objects by caching objects that are used repeatedly.

Memory Usage Monitoring

  • With Unity Profiler we can monitor memory usage and identify unnecessary memory allocations.
  • We also need to minimise GC (Garbage Collection) operations. If we can prevent unnecessary memory allocation and reduce the activation of GC, this also contributes positively to performance.

5. Code Optimisation

Efficient Code Writing

  • LINQ (Language Integrated Query) makes it easier to make queries on data, but the performance cost is high. For this reason, it may be more advantageous to use classic loops and conditions instead of LINQ in parts where we expect high performance.
  • In C#, memory management is performed by Garbage Collector (GC). Memory is allocated when new objects are created and cleared by GC when these objects are not in use. However, unnecessary memory allocations and consequent attempts to delete unnecessary created objects can negatively affect performance.

Asynchronous Operations

  • Async and Await: Performing long-running operations such as network operations or disc read/write asynchronously ensures that the main game loop runs uninterrupted.

As a result, performance optimisation in Unity is of great importance as it makes our games run smoother and more efficiently. In this article, I have tried to explain techniques and tips that will help us improve our performance. I hope that by applying these tips, we can offer a better gaming experience to our players.

Good coding to all of us.

Thanks for reading.

Selin.