From 1e1bb03060ab0bb336671844712c3e8701379c19 Mon Sep 17 00:00:00 2001 From: Rezapu Obed <obed.ubaidillah@gmail.com> Date: Sat, 11 May 2024 10:15:47 +0700 Subject: [PATCH] fix: fixed build error on shoplist --- Assets/Prefab/Shop/Shop.prefab | 16 ++++++++++++++++ Assets/Scripts/Shop/ShopList.cs | 22 +++++++++++++++++++--- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/Assets/Prefab/Shop/Shop.prefab b/Assets/Prefab/Shop/Shop.prefab index 667adbd..0444ea2 100644 --- a/Assets/Prefab/Shop/Shop.prefab +++ b/Assets/Prefab/Shop/Shop.prefab @@ -87,6 +87,7 @@ GameObject: - component: {fileID: 5729566714713886296} - component: {fileID: 1875122337861680507} - component: {fileID: 676001394856436309} + - component: {fileID: 7230201345750339060} - component: {fileID: 6307582884057386524} - component: {fileID: 6269096860075909776} m_Layer: 0 @@ -184,6 +185,21 @@ MonoBehaviour: m_BlockingMask: serializedVersion: 2 m_Bits: 4294967295 +--- !u!114 &7230201345750339060 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2894649308036582996} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b45b6bfd85577b94caa8bcfd63b5d014, type: 3} + m_Name: + m_EditorClassIdentifier: + petPrefabs: + - {fileID: 6811995390952167430, guid: c9b6775b96055074ab1b94ab08b9aaad, type: 3} + - {fileID: 5083320523706151295, guid: 4d6ff295d58fec848b061d23687d82fc, type: 3} --- !u!114 &6307582884057386524 MonoBehaviour: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Shop/ShopList.cs b/Assets/Scripts/Shop/ShopList.cs index 77ea33f..b2c9fa2 100644 --- a/Assets/Scripts/Shop/ShopList.cs +++ b/Assets/Scripts/Shop/ShopList.cs @@ -3,8 +3,24 @@ using System.Collections.Generic; using UnityEditor; using UnityEngine; -public class ShopList +public class ShopList: MonoBehaviour { + public GameObject[] petPrefabs; + public static ShopList Instance { get; private set; } + + private void Awake() + { + if (Instance == null) + { + Instance = this; + DontDestroyOnLoad(gameObject); + } + else + { + Destroy(gameObject); + } + } + public enum ShopItem { PetHeal, @@ -42,9 +58,9 @@ public class ShopList switch (item) { case ShopItem.PetHeal: - return AssetDatabase.LoadAssetAtPath<GameObject>("Assets/Prefab/Pet/PetHeal.prefab"); + return ShopList.Instance.petPrefabs[0]; case ShopItem.PetAttack: - return AssetDatabase.LoadAssetAtPath<GameObject>("Assets/Prefab/Pet/PetAttack.prefab"); + return ShopList.Instance.petPrefabs[1]; default: return null; } -- GitLab