Skip to content
This repository was archived by the owner on Aug 15, 2024. It is now read-only.

Commit edc5418

Browse files
author
serg.morozov
committed
BREAKING CHANGE: add interfaces
1 parent efc7b5b commit edc5418

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+489
-313
lines changed
Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,38 @@
11
#nullable enable
2-
namespace NuclearBand
2+
using Newtonsoft.Json;
3+
using Sirenix.OdinInspector;
4+
using UnityEngine;
5+
6+
namespace Nuclear.SODatabase
37
{
4-
public class Example1DataNode : DataNode
8+
public interface IExample1DataNode
9+
{
10+
IExample1DataNode2 Q { get; }
11+
}
12+
13+
public class Example1DataNode : DataNode, IExample1DataNode
514
{
615
public const string Path = "Example1Folder/Example1";
716
public string Description = string.Empty;
817
public DataNode DataNode = null!;
18+
19+
[SerializeField]
20+
private IExample1DataNode2 _interface;
21+
22+
public IExample1DataNode2 Q => _interface;
23+
24+
[JsonProperty, ShowInInspector]
25+
private IExample1DataNode2 _interface2;
26+
27+
public override void AfterLoad()
28+
{
29+
base.AfterLoad();
30+
_interface2 = _interface;
31+
}
32+
}
33+
34+
public class Q
35+
{
36+
937
}
1038
}
Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
11
#nullable enable
2+
using UnityEngine;
23

3-
namespace NuclearBand
4+
namespace Nuclear.SODatabase
45
{
5-
public class Example1DataNode2 : DataNode
6+
public interface IExample1DataNode2
7+
{
8+
bool X { get; }
9+
}
10+
11+
public class Example1DataNode2 : DataNode, IExample1DataNode2
612
{
713
public const string Path = "Example1Folder";
814
[ResetOnPlay]
915
public string Description2 = string.Empty;
16+
17+
[SerializeField]
18+
private bool _x;
19+
20+
bool IExample1DataNode2.X => _x;
1021
}
1122
}
Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,32 @@
11
#nullable enable
22
using UnityEngine;
33

4-
namespace NuclearBand
4+
namespace Nuclear.SODatabase
55
{
66
public class SOD_Example1 : MonoBehaviour
77
{
88
private void Start()
99
{
10-
SODatabase.Init(null, () =>
10+
SODatabaseStatic.Init(null, () =>
1111
{
12-
var model = SODatabase.GetModel<Example1DataNode>(Example1DataNode.Path);
12+
var model = SODatabaseStatic.GetModel<Example1DataNode>(Example1DataNode.Path);
1313
Debug.Log(model.Description);
1414

15-
var models = SODatabase.GetModels<Example1DataNode2>(Example1DataNode2.Path);
15+
var models = SODatabaseStatic.GetModels<Example1DataNode2>(Example1DataNode2.Path);
1616
foreach (var model1 in models)
1717
Debug.Log(model1.Description2);
18+
19+
SODatabaseStatic.Load();
20+
1821
});
22+
23+
24+
}
25+
26+
private void OnApplicationQuit()
27+
{
28+
SODatabaseStatic.Save();
1929
}
2030
}
2131
}
32+

Assets/SODatabase/Resources/SODatabaseSettings.asset

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,5 @@ MonoBehaviour:
4141
- Name:
4242
Entry: 8
4343
Data:
44-
path: Assets/SODatabaseModels/
45-
label: SODatabase
44+
_path: Assets/SODatabaseModels/
45+
_label: SODatabase

Assets/SODatabaseModels/Example1Folder/DataNode2.asset

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,6 @@ MonoBehaviour:
2121
PrefabModificationsReferencedUnityObjects: []
2222
PrefabModifications: []
2323
SerializationNodes: []
24-
fullPath: Example1Folder
24+
_fullPath: Example1Folder
2525
Description2: 2
26+
_x: 0

Assets/SODatabaseModels/Example1Folder/Example1.asset

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,16 @@ MonoBehaviour:
1515
serializationData:
1616
SerializedFormat: 2
1717
SerializedBytes:
18-
ReferencedUnityObjects: []
18+
ReferencedUnityObjects:
19+
- {fileID: 11400000, guid: 7dd3cfdc035f56b44954578039989c7a, type: 2}
1920
SerializedBytesString:
2021
Prefab: {fileID: 0}
2122
PrefabModificationsReferencedUnityObjects: []
2223
PrefabModifications: []
23-
SerializationNodes: []
24-
fullPath: Example1Folder
24+
SerializationNodes:
25+
- Name: _interface
26+
Entry: 10
27+
Data: 0
28+
_fullPath: Example1Folder
2529
Description: 1
2630
DataNode: {fileID: 11400000, guid: 7dd3cfdc035f56b44954578039989c7a, type: 2}

Assets/com.nuclearband.sodatabase/Editor/DataNodeCreator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
using UnityEditor;
99
using UnityEngine;
1010

11-
namespace NuclearBand.Editor
11+
namespace Nuclear.SODatabase.Editor
1212
{
1313
public static class DataNodeCreator
1414
{

Assets/com.nuclearband.sodatabase/Editor/ScriptableObjectDatabaseEditorWindow.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
using UnityEditor;
1313
using UnityEngine;
1414

15-
namespace NuclearBand.Editor
15+
namespace Nuclear.SODatabase.Editor
1616
{
1717
public class ScriptableObjectDatabaseEditorWindow : OdinMenuEditorWindow
1818
{
@@ -32,8 +32,8 @@ private static void ClearSave()
3232
{
3333
AssetDatabase.Refresh();
3434

35-
File.Delete(SODatabase.SavePath);
36-
var models = SODatabaseInternal.GetModelsForEdit<DataNode>("");
35+
File.Delete(SODatabaseSaver.SavePath);
36+
var models = SODatabaseUtilities.GetModelsForEdit<DataNode>("");
3737
foreach (var model in models)
3838
{
3939
var typeInfo = model.GetType().GetTypeInfo();

Assets/com.nuclearband.sodatabase/Editor/com.nuclearband.sodatabase.Editor.asmdef

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
2-
"name": "com.nuclearband.sodatabase.Editor",
2+
"name": "SODatabase.Editor",
3+
"rootNamespace": "",
34
"references": [
45
"GUID:9e24947de15b9834991c9d8411ea37cf",
56
"GUID:84651a3751eca9349aac36a66bba901b",

Assets/com.nuclearband.sodatabase/Runtime/Attributes.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)