From 856d4232805939575780530442e5054d8dacff51 Mon Sep 17 00:00:00 2001 From: Noah Pilarski Date: Tue, 23 Jul 2024 15:47:07 -0400 Subject: [PATCH] Rearrange and update --- .../Character => Components}/SpeakerPortraitAnimator.cs | 2 +- .../Character/AdvancedSpeakerData.cs | 6 +++--- Winch/Serialization/Character/SpeakerDataConverter.cs | 1 + Winch/Util/CharacterUtil.cs | 1 + Winch/Util/WinchExtensions.cs | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-) rename Winch/{Serialization/Character => Components}/SpeakerPortraitAnimator.cs (97%) rename Winch/{Serialization => Data}/Character/AdvancedSpeakerData.cs (88%) diff --git a/Winch/Serialization/Character/SpeakerPortraitAnimator.cs b/Winch/Components/SpeakerPortraitAnimator.cs similarity index 97% rename from Winch/Serialization/Character/SpeakerPortraitAnimator.cs rename to Winch/Components/SpeakerPortraitAnimator.cs index 999cccba..53ef5111 100644 --- a/Winch/Serialization/Character/SpeakerPortraitAnimator.cs +++ b/Winch/Components/SpeakerPortraitAnimator.cs @@ -1,7 +1,7 @@ using UnityEngine; using UnityEngine.UI; -namespace Winch.Serialization.Character +namespace Winch.Components { public class SpeakerPortraitAnimator : MonoBehaviour { diff --git a/Winch/Serialization/Character/AdvancedSpeakerData.cs b/Winch/Data/Character/AdvancedSpeakerData.cs similarity index 88% rename from Winch/Serialization/Character/AdvancedSpeakerData.cs rename to Winch/Data/Character/AdvancedSpeakerData.cs index 23fda560..afefa4ef 100644 --- a/Winch/Serialization/Character/AdvancedSpeakerData.cs +++ b/Winch/Data/Character/AdvancedSpeakerData.cs @@ -1,9 +1,10 @@ using System; using UnityEngine; using UnityEngine.UI; +using Winch.Components; using Winch.Util; -namespace Winch.Serialization.Character +namespace Winch.Data.Character { public class AdvancedSpeakerData : SpeakerData { @@ -15,7 +16,7 @@ public class AdvancedSpeakerData : SpeakerData public void AddPortraitPrefab() { - portraitPrefab = new GameObject($"{id} PortraitPrefab", typeof(RectTransform), typeof(Canvas), typeof(GraphicRaycaster), typeof(SpeakerPortraitAnimator)); + portraitPrefab = new GameObject($"{id} PortraitPrefab", typeof(RectTransform), typeof(Canvas), typeof(GraphicRaycaster), typeof(SpeakerPortraitAnimator)).Prefabitize(); portraitPrefab.layer = Layer.UI; var imageObj = new GameObject(id, typeof(RectTransform), typeof(CanvasRenderer), typeof(Image)); imageObj.transform.SetParent(portraitPrefab.transform, false); @@ -25,7 +26,6 @@ public void AddPortraitPrefab() image.sprite = portraitSprite; image.preserveAspect = true; image.raycastTarget = false; - portraitPrefab.DontDestroyOnLoad(); } } } diff --git a/Winch/Serialization/Character/SpeakerDataConverter.cs b/Winch/Serialization/Character/SpeakerDataConverter.cs index d88455ad..37e3b0e5 100644 --- a/Winch/Serialization/Character/SpeakerDataConverter.cs +++ b/Winch/Serialization/Character/SpeakerDataConverter.cs @@ -4,6 +4,7 @@ using UnityEngine.Localization; using UnityEngine.UI; using Winch.Core; +using Winch.Data.Character; using Winch.Util; namespace Winch.Serialization.Character; diff --git a/Winch/Util/CharacterUtil.cs b/Winch/Util/CharacterUtil.cs index c59b145e..69cdcde2 100644 --- a/Winch/Util/CharacterUtil.cs +++ b/Winch/Util/CharacterUtil.cs @@ -9,6 +9,7 @@ using UnityEngine.Analytics; using UnityEngine.Localization; using Winch.Core; +using Winch.Data.Character; using Winch.Serialization; using Winch.Serialization.Character; diff --git a/Winch/Util/WinchExtensions.cs b/Winch/Util/WinchExtensions.cs index 9b88e2e5..f95e26d2 100644 --- a/Winch/Util/WinchExtensions.cs +++ b/Winch/Util/WinchExtensions.cs @@ -553,7 +553,7 @@ internal static Transform PrefabParent /// public static GameObject Prefabitize(this GameObject obj) { - obj.transform.SetParent(PrefabParent, false); + obj.DontDestroyOnLoad().transform.SetParent(PrefabParent, false); return obj; }