From a18f7905aefaab3d2312628d0a791575a85a4769 Mon Sep 17 00:00:00 2001 From: Metious <71298690+Metious@users.noreply.github.com> Date: Tue, 29 Aug 2023 08:38:20 +0330 Subject: [PATCH 1/2] Added OnPrefabProcessor method to PrefabTemplates --- Nautilus/Assets/CustomPrefab.cs | 6 +++++- Nautilus/Assets/PrefabTemplates/PrefabTemplate.cs | 10 ++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Nautilus/Assets/CustomPrefab.cs b/Nautilus/Assets/CustomPrefab.cs index 0e4a3e4a..98f0fe17 100644 --- a/Nautilus/Assets/CustomPrefab.cs +++ b/Nautilus/Assets/CustomPrefab.cs @@ -259,7 +259,11 @@ public void AddOnUnregister(Action onUnregisterCallback) /// Sets a prefab template as the game object constructor of this custom prefab. /// /// The prefab template object to set. - public void SetGameObject(PrefabTemplate prefabTemplate) => Prefab = prefabTemplate.GetPrefabAsync; + public void SetGameObject(PrefabTemplate prefabTemplate) + { + Prefab = prefabTemplate.GetPrefabAsync; + SetPrefabPostProcessor(prefabTemplate.OnPrefabPostProcessor); + } /// /// Sets a game object as the prefab of this custom prefab. diff --git a/Nautilus/Assets/PrefabTemplates/PrefabTemplate.cs b/Nautilus/Assets/PrefabTemplates/PrefabTemplate.cs index 7f0186b8..15cf1a12 100644 --- a/Nautilus/Assets/PrefabTemplates/PrefabTemplate.cs +++ b/Nautilus/Assets/PrefabTemplates/PrefabTemplate.cs @@ -29,4 +29,14 @@ public PrefabTemplate(PrefabInfo info) /// If the provided task result already has a game object set to it, it will try to set the necessary components first. Otherwise; sets a default implementation of this entity type. /// A coroutine operation. Must be used with either yield return, or . public abstract IEnumerator GetPrefabAsync(TaskResult gameObject); + + /// + /// Use this method to make changes to the prefab after the Nautilus' prefab processing is completed. Can be used to override or add more features to a prefab once it's settled. + /// + /// The prefab to process. + /// A coroutine operation. + public virtual IEnumerator OnPrefabPostProcessor(GameObject prefab) + { + yield break; + } } \ No newline at end of file From 620a36a45606fecd0a3b3d58c48efcfa67f8e8e3 Mon Sep 17 00:00:00 2001 From: Metious <71298690+Metious@users.noreply.github.com> Date: Tue, 29 Aug 2023 08:39:21 +0330 Subject: [PATCH 2/2] Singular prefab processor bug Fixed a bug where you could only register one prefab processor --- Nautilus/Assets/CustomPrefab.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Nautilus/Assets/CustomPrefab.cs b/Nautilus/Assets/CustomPrefab.cs index 98f0fe17..569c2017 100644 --- a/Nautilus/Assets/CustomPrefab.cs +++ b/Nautilus/Assets/CustomPrefab.cs @@ -286,13 +286,13 @@ public void SetGameObject(GameObject prefab) /// Sets a post processor for the . This is an asynchronous version. /// /// The post processor to set. - public void SetPrefabPostProcessor(Func postProcessorAsync) => OnPrefabPostProcess = obj => postProcessorAsync(obj); + public void SetPrefabPostProcessor(Func postProcessorAsync) => OnPrefabPostProcess += obj => postProcessorAsync(obj); /// /// Sets a post processor for the . This is a synchronous version. /// /// The post processor to set. - public void SetPrefabPostProcessor(Action postProcessor) => OnPrefabPostProcess = obj => SyncPostProcessor(obj, postProcessor); + public void SetPrefabPostProcessor(Action postProcessor) => OnPrefabPostProcess += obj => SyncPostProcessor(obj, postProcessor); /// /// Registers this custom prefab into the game.