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

Commit 930e206

Browse files
author
serg.morozov
committed
fix: window visualization
1 parent 29d5601 commit 930e206

File tree

12 files changed

+108
-87
lines changed

12 files changed

+108
-87
lines changed

Assets/SODatabase/Resources/SODatabaseSettings.asset

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,5 @@ MonoBehaviour:
4141
- Name:
4242
Entry: 8
4343
Data:
44-
path:
44+
path: Assets/SODatabaseModels/
4545
label: SODatabase

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ private void SelectionChanged(SelectionChangedType obj)
9999
switch (obj)
100100
{
101101
case SelectionChangedType.ItemAdded:
102-
((Holder) MenuTree.Selection.SelectedValue)!.Select();
102+
((Holder) MenuTree.Selection.SelectedValue).Select();
103103
break;
104104
case SelectionChangedType.ItemRemoved:
105105
break;
@@ -110,7 +110,7 @@ private void SelectionChanged(SelectionChangedType obj)
110110
}
111111
}
112112

113-
void AddAllAssetsAtPath(
113+
private void AddAllAssetsAtPath(
114114
OdinMenuTree tree,
115115
string assetFolderPath,
116116
Type type)
@@ -122,8 +122,8 @@ void AddAllAssetsAtPath(
122122
{
123123
var asset = AssetDatabase.LoadAssetAtPath(str1, type);
124124
var path = string.Empty;
125-
var name = string.Empty;
126-
var str2 = string.Empty;
125+
string assetName;
126+
string str2;
127127
if (asset == null)
128128
{
129129
//it's a directory
@@ -132,17 +132,17 @@ void AddAllAssetsAtPath(
132132
if (length == -1)
133133
{
134134
path = string.Empty;
135-
name = str2;
135+
assetName = str2;
136136
}
137137
else
138138
{
139-
path = str2.Substring(0, length);
140-
name = str2.Substring(length + 1);
139+
path = str2[..length];
140+
assetName = str2[(length + 1)..];
141141
}
142142

143-
if (name == string.Empty)
143+
if (assetName == string.Empty)
144144
continue;
145-
tree.AddMenuItemAtPath(odinMenuItemSet, path, new OdinMenuItem(tree, name, new FolderHolder(path, name)));
145+
tree.AddMenuItemAtPath(odinMenuItemSet, path, new OdinMenuItem(tree, assetName, new FolderHolder(path, assetName)));
146146

147147
continue;
148148
}
@@ -154,8 +154,8 @@ void AddAllAssetsAtPath(
154154
path = path.Trim('/') + "/" + str2;
155155

156156
path = path.Trim('/') + "/" + withoutExtension;
157-
SplitMenuPath(path, out path, out name);
158-
var menuItem = new OdinMenuItem(tree, name, new DataNodeHolder(path, name, (DataNode) asset));
157+
SplitMenuPath(path, out path, out assetName);
158+
var menuItem = new OdinMenuItem(tree, assetName, new DataNodeHolder(path, assetName, (DataNode) asset));
159159
tree.AddMenuItemAtPath(odinMenuItemSet, path, menuItem);
160160
AddDragHandles(menuItem);
161161
}
@@ -267,7 +267,7 @@ private static IEnumerable<OdinMenuItem> Flatten(IEnumerable<OdinMenuItem> colle
267267

268268
private void AddDragHandles(OdinMenuItem menuItem)
269269
{
270-
menuItem.OnDrawItem += x => DragAndDropUtilities.DragZone(menuItem.Rect, (menuItem.Value as DataNodeHolder)!.DataNode, false, false);
270+
menuItem.OnDrawItem += _ => DragAndDropUtilities.DragZone(menuItem.Rect, (menuItem.Value as DataNodeHolder)!.DataNode, false, false);
271271
}
272272
}
273273
}

Assets/com.nuclearband.sodatabase/Runtime/Holders/FolderHolder.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,16 @@
33
using UnityEditor;
44
#endif
55
using System.Collections.Generic;
6-
using UnityEngine;
76

87
namespace NuclearBand
98
{
109
public class FolderHolder : Holder
1110
{
12-
[HideInInspector]
1311
public Dictionary<string, DataNode> DataNodes = new();
14-
15-
[HideInInspector]
12+
1613
public Dictionary<string, FolderHolder> FolderHolders = new();
1714

18-
public FolderHolder() : base()
15+
public FolderHolder()
1916
{
2017
}
2118

Assets/com.nuclearband.sodatabase/Runtime/Holders/Holder.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#nullable enable
22
using Newtonsoft.Json;
33
using Sirenix.OdinInspector;
4-
using UnityEngine;
54

65
namespace NuclearBand
76
{
@@ -13,9 +12,7 @@ protected Holder()
1312
}
1413

1514
#if UNITY_EDITOR
16-
[HideInInspector]
1715
public string Path = string.Empty;
18-
[HideInInspector]
1916
public string Name = string.Empty;
2017

2118
[ShowInInspector]
@@ -25,7 +22,7 @@ protected Holder()
2522
[HorizontalGroup("Name")]
2623
protected string TempName = string.Empty;
2724

28-
public Holder(string path, string name)
25+
protected Holder(string path, string name)
2926
{
3027
Path = path;
3128
Name = name;
@@ -38,12 +35,12 @@ public virtual void Select()
3835
}
3936

4037
[HorizontalGroup("Path")]
41-
[ShowIf("@Path != _tempPath")]
38+
[ShowIf("@Path != TempPath")]
4239
[Button]
4340
protected abstract void Move();
4441

4542
[HorizontalGroup("Name")]
46-
[ShowIf("@Name != _tempName")]
43+
[ShowIf("@Name != TempName")]
4744
[Button]
4845
protected abstract void Rename();
4946

Assets/com.nuclearband.sodatabase/Runtime/SODatabase.cs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ namespace NuclearBand
1313
public static class SODatabase
1414
{
1515
public static string SavePath => Application.persistentDataPath + @"/save.txt";
16+
// ReSharper disable once MemberCanBePrivate.Global
1617
public static string SaveBakPath => Application.persistentDataPath + @"/save.bak";
1718

1819
private static FolderHolder _root = null!;
@@ -61,7 +62,7 @@ public static async Task InitAsync(Action<float>? onProgress, Action? onComplete
6162
var loadTasks = new Dictionary<string, Task<DataNode>>();
6263
foreach (var resourceLocation in resourceLocations)
6364
{
64-
var key = resourceLocation.PrimaryKey.Substring(SODatabaseSettings.Path.Length);
65+
var key = resourceLocation.PrimaryKey[SODatabaseSettings.Path.Length..];
6566
if (!resourceLocation.ResourceType.IsSubclassOf(typeof(DataNode)) || loadTasks.ContainsKey(key))
6667
continue;
6768
loadTasks.Add(key, Addressables.LoadAssetAsync<DataNode>(resourceLocation).Task);
@@ -102,19 +103,19 @@ public static T GetModel<T>(string path) where T : DataNode
102103
for (var i = 0; i < pathElements.Length - 1; i++)
103104
curFolder = curFolder.FolderHolders[pathElements[i]];
104105

105-
var dataNodeName = pathElements[pathElements.Length - 1];
106-
return ((T) curFolder.DataNodes[dataNodeName])!;
106+
var dataNodeName = pathElements[^1];
107+
return (T) curFolder.DataNodes[dataNodeName];
107108
}
108109

109110
public static List<T> GetModels<T>(string path, bool includeSubFolders = false) where T : DataNode
110111
{
111112
var pathElements = path.Split('/');
112113
var curFolder = _root;
113114
if (path != string.Empty)
114-
for (var i = 0; i < pathElements.Length; i++)
115+
foreach (var pathElement in pathElements)
115116
{
116-
if (curFolder.FolderHolders.ContainsKey(pathElements[i]))
117-
curFolder = curFolder.FolderHolders[pathElements[i]];
117+
if (curFolder.FolderHolders.ContainsKey(pathElement))
118+
curFolder = curFolder.FolderHolders[pathElement];
118119
else
119120
break;
120121
}
@@ -162,8 +163,8 @@ public static async Task SaveAsync()
162163
};
163164
foreach (var runtimeModelPair in RuntimeModels)
164165
save.RuntimeNodes.Add(runtimeModelPair.Key, JsonConvert.SerializeObject(runtimeModelPair.Value, JsonRuntimeSerializerSettings));
165-
166-
using var fileStream = new StreamWriter(SavePath);
166+
167+
await using var fileStream = new StreamWriter(SavePath);
167168
await fileStream.WriteAsync(JsonConvert.SerializeObject(save));
168169
_saving = false;
169170
}
@@ -173,6 +174,7 @@ public static async void Load()
173174
await LoadAsync();
174175
}
175176

177+
// ReSharper disable once MemberCanBePrivate.Global
176178
public static async Task LoadAsync()
177179
{
178180
if (!File.Exists(SavePath)) {

Assets/com.nuclearband.sodatabase/Runtime/SODatabaseInternal.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ namespace NuclearBand
1010
{
1111
public static class SODatabaseInternal
1212
{
13+
// ReSharper disable once MemberCanBePrivate.Global
1314
public static T GetModelForEdit<T>(string path) where T : DataNode
1415
{
1516
return AssetDatabase.LoadAssetAtPath<T>(SODatabaseSettings.Path + path + ".asset") ??
@@ -24,6 +25,7 @@ public static List<T> GetModelsForEdit<T>(string path) where T : DataNode
2425
return modelGUIDs.Select(model => AssetDatabase.LoadAssetAtPath<T>(AssetDatabase.GUIDToAssetPath(model))).ToList();
2526
}
2627

28+
// ReSharper disable once MemberCanBePrivate.Global
2729
public static void CreateFolder(string path)
2830
{
2931
AssetDatabase.Refresh();
@@ -50,7 +52,7 @@ public static T CreateModel<T>(string path, string name) where T : DataNode
5052
var model = GetModelForEdit<T>(path + "/" + name);
5153
return model;
5254
}
53-
catch
55+
catch
5456
{
5557
// ignored
5658
}

Assets/com.nuclearband.sodatabase/Runtime/SODatabaseSettings.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ public static SODatabaseSettings Instance
5353
[NonSerialized, ShowInInspector]
5454
public string SavePath = string.Empty;
5555

56+
// ReSharper disable once CollectionNeverUpdated.Global
57+
// ReSharper disable once FieldCanBeMadeReadOnly.Global
5658
public Dictionary<Type, Texture> NodeIcons = new();
5759

5860
[Button]

Assets/com.nuclearband.sodatabase/Runtime/SerializationUtilities/SODatabaseSaveFormat.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ namespace NuclearBand
77
public class SODatabaseSaveFormat
88
{
99
public Dictionary<string, string> StaticNodes = new();
10-
public Dictionary<string, string> RuntimeNodes = new();
10+
public readonly Dictionary<string, string> RuntimeNodes = new();
1111
}
1212
}

Packages/manifest.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"dependencies": {
3-
"com.unity.addressables": "1.20.5",
4-
"com.unity.ide.rider": "3.0.16",
5-
"com.unity.ide.visualstudio": "2.0.16",
6-
"com.unity.ide.vscode": "1.2.5",
3+
"com.unity.addressables": "1.21.2",
4+
"com.unity.ai.navigation": "1.1.1",
5+
"com.unity.ide.rider": "3.0.17",
6+
"com.unity.ide.visualstudio": "2.0.17",
77
"com.unity.nuget.newtonsoft-json": "3.0.2",
8-
"com.unity.test-framework": "1.1.33",
8+
"com.unity.test-framework": "1.3.2",
99
"com.unity.textmeshpro": "3.0.6",
10-
"com.unity.timeline": "1.7.2",
10+
"com.unity.timeline": "1.8.0",
1111
"com.unity.ugui": "1.0.0",
1212
"com.unity.modules.ai": "1.0.0",
1313
"com.unity.modules.androidjni": "1.0.0",

Packages/packages-lock.json

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"dependencies": {
33
"com.unity.addressables": {
4-
"version": "1.20.5",
4+
"version": "1.21.2",
55
"depth": 0,
66
"source": "registry",
77
"dependencies": {
8-
"com.unity.scriptablebuildpipeline": "1.20.2",
8+
"com.unity.scriptablebuildpipeline": "1.21.1",
99
"com.unity.modules.assetbundle": "1.0.0",
1010
"com.unity.modules.imageconversion": "1.0.0",
1111
"com.unity.modules.jsonserialize": "1.0.0",
@@ -14,15 +14,24 @@
1414
},
1515
"url": "https://packages.unity.com"
1616
},
17+
"com.unity.ai.navigation": {
18+
"version": "1.1.1",
19+
"depth": 0,
20+
"source": "registry",
21+
"dependencies": {
22+
"com.unity.modules.ai": "1.0.0"
23+
},
24+
"url": "https://packages.unity.com"
25+
},
1726
"com.unity.ext.nunit": {
18-
"version": "1.0.6",
27+
"version": "2.0.3",
1928
"depth": 1,
2029
"source": "registry",
2130
"dependencies": {},
2231
"url": "https://packages.unity.com"
2332
},
2433
"com.unity.ide.rider": {
25-
"version": "3.0.16",
34+
"version": "3.0.17",
2635
"depth": 0,
2736
"source": "registry",
2837
"dependencies": {
@@ -31,21 +40,14 @@
3140
"url": "https://packages.unity.com"
3241
},
3342
"com.unity.ide.visualstudio": {
34-
"version": "2.0.16",
43+
"version": "2.0.17",
3544
"depth": 0,
3645
"source": "registry",
3746
"dependencies": {
3847
"com.unity.test-framework": "1.1.9"
3948
},
4049
"url": "https://packages.unity.com"
4150
},
42-
"com.unity.ide.vscode": {
43-
"version": "1.2.5",
44-
"depth": 0,
45-
"source": "registry",
46-
"dependencies": {},
47-
"url": "https://packages.unity.com"
48-
},
4951
"com.unity.nuget.newtonsoft-json": {
5052
"version": "3.0.2",
5153
"depth": 0,
@@ -54,18 +56,18 @@
5456
"url": "https://packages.unity.com"
5557
},
5658
"com.unity.scriptablebuildpipeline": {
57-
"version": "1.20.2",
59+
"version": "1.21.1",
5860
"depth": 1,
5961
"source": "registry",
6062
"dependencies": {},
6163
"url": "https://packages.unity.com"
6264
},
6365
"com.unity.test-framework": {
64-
"version": "1.1.33",
66+
"version": "1.3.2",
6567
"depth": 0,
6668
"source": "registry",
6769
"dependencies": {
68-
"com.unity.ext.nunit": "1.0.6",
70+
"com.unity.ext.nunit": "2.0.3",
6971
"com.unity.modules.imgui": "1.0.0",
7072
"com.unity.modules.jsonserialize": "1.0.0"
7173
},
@@ -81,7 +83,7 @@
8183
"url": "https://packages.unity.com"
8284
},
8385
"com.unity.timeline": {
84-
"version": "1.7.2",
86+
"version": "1.8.0",
8587
"depth": 0,
8688
"source": "registry",
8789
"dependencies": {
@@ -233,17 +235,6 @@
233235
"version": "1.0.0",
234236
"depth": 0,
235237
"source": "builtin",
236-
"dependencies": {
237-
"com.unity.modules.ui": "1.0.0",
238-
"com.unity.modules.imgui": "1.0.0",
239-
"com.unity.modules.jsonserialize": "1.0.0",
240-
"com.unity.modules.uielementsnative": "1.0.0"
241-
}
242-
},
243-
"com.unity.modules.uielementsnative": {
244-
"version": "1.0.0",
245-
"depth": 1,
246-
"source": "builtin",
247238
"dependencies": {
248239
"com.unity.modules.ui": "1.0.0",
249240
"com.unity.modules.imgui": "1.0.0",

0 commit comments

Comments
 (0)