Skip to content

Commit b9d7524

Browse files
committed
Dedicated class to serialize directory assets
1 parent 2fbad52 commit b9d7524

2 files changed

Lines changed: 52 additions & 0 deletions

File tree

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
using System;
2+
#if UNITY_EDITOR
3+
using UnityEditor;
4+
#endif
5+
6+
namespace UnityEngine
7+
{
8+
[Serializable]
9+
public class SerializedDirectory : ISerializationCallbackReceiver
10+
{
11+
#if UNITY_EDITOR
12+
[SerializeField]
13+
private DefaultAsset directoryAsset;
14+
#endif
15+
[SerializeField, Disable]
16+
private string path;
17+
18+
void ISerializationCallbackReceiver.OnAfterDeserialize()
19+
{ }
20+
21+
void ISerializationCallbackReceiver.OnBeforeSerialize()
22+
{
23+
#if UNITY_EDITOR
24+
path = directoryAsset ? AssetDatabase.GetAssetPath(directoryAsset) : null;
25+
#endif
26+
}
27+
28+
#if UNITY_EDITOR
29+
public DefaultAsset DirectoryAsset
30+
{
31+
get => directoryAsset;
32+
set => directoryAsset = value;
33+
}
34+
#endif
35+
public string Path
36+
{
37+
get => path;
38+
set => path = value;
39+
}
40+
}
41+
}

Assets/Editor Toolbox/Scripts/Serialization/SerializedDirectory.cs.meta

Lines changed: 11 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)