Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- [CreateAssetMenu]
- public class LocalShipDB : ScriptableObject, ISerializationCallbackReceiver
- {
- [SerializeField]
- public Dictionary<string, GameObject> SpawnableShips = new Dictionary<string, GameObject>();
- [SerializeField]
- public GameObject[] Ships;
- void loadShips()
- {
- foreach (GameObject Ship in Ships)
- {
- ShipData ShipInfo = Ship.GetComponent<ShipData>();
- if (!SpawnableShips.ContainsKey(ShipInfo.ShipID.ToString()))
- {
- SpawnableShips.Add(ShipInfo.ShipID.ToString(), Ship);
- }
- }
- }
- public GameObject GetShip(int ItemID)
- {
- GameObject Ship = SpawnableShips[ItemID.ToString()];
- return Ship;
- }
- public void InitData()
- {
- loadShips();
- }
- public void OnBeforeSerialize()
- {
- }
- public void OnAfterDeserialize()
- {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement