导入odin

This commit is contained in:
2026-01-01 23:09:08 +08:00
parent 9ceffccd39
commit 04dd4a23b2
814 changed files with 120820 additions and 87 deletions

View File

@@ -0,0 +1,17 @@
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace Obvious.Soap
{
/// <summary>
/// Interface for objects that can be reset to their initial value.
/// </summary>
public interface IReset
{
void ResetValue();
#if UNITY_EDITOR
void OnPlayModeStateChanged(PlayModeStateChange playModeStateChange);
#endif
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a2f1a089b4a201e4fa8fb2d1d643b06b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,50 @@
#if UNITY_EDITOR
using UnityEditor;
#endif
using UnityEngine;
namespace Obvious.Soap
{
public abstract class ResettableScriptableObject : ScriptableObject
{
protected string _cachedJson;
#if UNITY_EDITOR
protected virtual void OnEnable()
{
EditorApplication.playModeStateChanged += OnPlayModeStateChanged;
}
protected virtual void OnDisable()
{
EditorApplication.playModeStateChanged -= OnPlayModeStateChanged;
}
protected virtual void OnPlayModeStateChanged(PlayModeStateChange playModeStateChange)
{
if (playModeStateChange == PlayModeStateChange.ExitingEditMode)
{
CacheState();
}
else if (playModeStateChange == PlayModeStateChange.EnteredEditMode)
{
ResetValue();
}
}
protected virtual void CacheState()
{
_cachedJson = EditorJsonUtility.ToJson(this, prettyPrint: true);
}
[ContextMenu("Reset Value")]
public virtual void ResetValue()
{
if (!string.IsNullOrEmpty(_cachedJson))
{
EditorJsonUtility.FromJsonOverwrite(_cachedJson, this);
}
}
#endif
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: cc0665cf937e17746aab28f77136a40c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: