add performance optimization unity project

This commit is contained in:
2025-12-01 18:37:09 +01:00
parent bc4b9f1691
commit 9284c52926
72 changed files with 7525 additions and 0 deletions
@@ -0,0 +1,39 @@
using System;
using Unity.Profiling;
using UnityEngine;
namespace DefaultNamespace
{
public class MassInstantiation : MonoBehaviour
{
[SerializeField] private GameObject prefab;
[SerializeField] private int objectsToSpawn = 1000;
[SerializeField] private bool isInstantiating;
private static readonly ProfilerMarker _profilerMarker = new ProfilerMarker("MassInstantiationMarker");
private void Update()
{
if (isInstantiating) InstantiateObjects();
if (Input.GetKeyDown(KeyCode.Space)) DestroyAllChildren();
}
public void InstantiateObjects()
{
_profilerMarker.Begin();
for (int i = 0; i < objectsToSpawn; i++)
{
Instantiate(prefab, transform);
}
_profilerMarker.End();
}
private void DestroyAllChildren()
{
for (int i = transform.childCount - 1; i >= 0; i--)
{
Destroy(transform.GetChild(i).gameObject);
}
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 92da548a653f45c288a5926a0e6d30d5
timeCreated: 1753798725
@@ -0,0 +1,18 @@
using System;
using UnityEngine;
namespace DefaultNamespace
{
public class StaticBatching : MonoBehaviour
{
[SerializeField] private MassInstantiation massInstantiation;
private void Update()
{
if (Input.GetKeyDown(KeyCode.Return))
{
massInstantiation.InstantiateObjects();
StaticBatchingUtility.Combine(massInstantiation.gameObject);
} }
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 6477810786124c299ea23f3ae0a11972
timeCreated: 1753806194