//--- --- //--- Load Data --- public static void LoadScriptableObject(SaveableScriptableObjectData _objectData) { ScriptableObject so = null; ScriptableObjectsGuidMap guidMap = ScriptableObjectsGuidMapSingleton.Instance.scriptableObjectsGuidMap; if (guidMap.TryResolveGuid(_objectData.guid)) { so = guidMap.ResolveGuid(_objectData.guid); } if (so != null) { so.name = _objectData.scriptableObjectName; _objectData.data.PopulateObject(so); } else if (Type.GetType(_objectData.scriptableObjectType) == null) { Debug.LogError($"You are trying to load a ScriptableObjects of type {_objectData.scriptableObjectType} which no longer exists in this project. Has this class been renamed or deleted?"); } else { so = ScriptableObject.CreateInstance(_objectData.scriptableObjectType); ScriptableObjectsGuidMapSingleton.Instance.scriptableObjectsGuidMap.RegisterNewSoCreatedAtRuntime(so, _objectData.guid); so.name = _objectData.scriptableObjectName; _objectData.data.PopulateObject(so); } //else //{ // Debug.LogError("Can't load ScriptableObject with guid: " + _objectData.guid); //} }
private static SaveableScriptableObjectData GetSoSaveableData(ScriptableObject _so) { var guid = ScriptableObjectsGuidMapSingleton.Instance.scriptableObjectsGuidMap.ResolveReference(_so); SaveableScriptableObjectData soData = new SaveableScriptableObjectData { guid = guid, scriptableObjectName = _so.name, scriptableObjectType = _so.GetType().FullName, data = new SaveableData(_so, guid.ToString()) }; return(soData); }