Added Pacore

This commit is contained in:
2026-03-30 10:32:44 +01:00
parent 62f6553986
commit b3202a4636
55 changed files with 1142 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
using PashaBibko.Pacore.Attributes;
using System.Collections.ObjectModel;
using UnityEngine;
using System;
using Object = UnityEngine.Object;
namespace PashaBibko.Pacore
{
public static class CreateInstanceOnStartLoader
{
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
private static void CreateAllInstances()
{
/* Fetches all the types with the CreateInstanceOnStart attribute */
ReadOnlyCollection<Type> types =
ClassAttributeCache.GetAttributesOf<CreateInstanceOnStartAttribute>();
/* Creates a holder for all the other game objects to not clutter inspector */
GameObject holder = new("ScriptSpawnedInstances");
Object.DontDestroyOnLoad(holder); // Stops all the game objects from being destroyed
Transform parent = holder.transform;
/* Creates all the game objects for the selected types */
foreach (Type type in types)
{
GameObject go = new(type.Name, type);
go.transform.SetParent(parent);
}
}
}
}