DataSo 변경

This commit is contained in:
NTG_DESKTOP 2025-08-12 03:27:18 +09:00
parent a8ee601eb1
commit a3e6818810
2 changed files with 44 additions and 9 deletions

View File

@ -71,5 +71,28 @@ PrefabInstance:
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_AddedComponents:
- targetCorrespondingSourceObject: {fileID: 4438924429928472453, guid: 1d634c3376e4a4684bc984ced9134847, type: 3}
insertIndex: -1
addedObject: {fileID: 2285326470091144097}
m_SourcePrefab: {fileID: 100100000, guid: 1d634c3376e4a4684bc984ced9134847, type: 3}
--- !u!1 &580268897300907643 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 4438924429928472453, guid: 1d634c3376e4a4684bc984ced9134847, type: 3}
m_PrefabInstance: {fileID: 3861763275173960190}
m_PrefabAsset: {fileID: 0}
--- !u!114 &2285326470091144097
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 580268897300907643}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 201f9e6d7ca7404baa9945950292a392, type: 3}
m_Name:
m_EditorClassIdentifier:
_interactionType: 1
_holdTime: 1
_interactionMessageKey: Test

View File

@ -1,34 +1,46 @@
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.Serialization;
namespace DDD
{
public class DataSo<T> : ScriptableObject where T : IId
{
[SerializeField]
protected List<T> Datas = new();
[FormerlySerializedAs("Datas")] [SerializeField] protected List<T> _datas = new();
public T GetDataById(string id) => Datas.FirstOrDefault(x => x.Id == id);
private void OnEnable()
{
Initialize();
}
public bool ContainsData(string id) => Datas.Any(x => x.Id == id);
private void OnValidate()
{
Initialize();
}
protected virtual void Initialize() { }
public T GetDataById(string id) => _datas.FirstOrDefault(x => x.Id == id);
public bool ContainsData(string id) => _datas.Any(x => x.Id == id);
public bool TryGetDataById(string id, out T data)
{
data = Datas.FirstOrDefault(x => x.Id == id);
data = _datas.FirstOrDefault(x => x.Id == id);
return data != null;
}
public void SetDataList(List<T> newList)
{
Datas = newList;
_datas = newList;
}
public List<T> GetDataList()
{
return Datas;
return _datas;
}
public int GetDataCount() => Datas.Count;
public int GetDataCount() => _datas.Count;
}
}