mirror of
https://github.com/DCFApixels/DragonECS-Unity.git
synced 2025-09-17 09:24:35 +08:00
fix manual save for so
This commit is contained in:
parent
697d731e46
commit
a990d90c07
@ -16,15 +16,23 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
{
|
||||
public static partial class Layout
|
||||
{
|
||||
|
||||
public static void ManuallySerializeButton(IEnumerable<UnityObject> objects)
|
||||
{
|
||||
if (GUILayout.Button(UnityEditorUtility.GetLabel("Manually serialize")))
|
||||
{
|
||||
foreach (var obj in objects)
|
||||
{
|
||||
EditorUtility.SetDirty(obj);
|
||||
}
|
||||
AssetDatabase.SaveAssets();
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
}
|
||||
public static void ManuallySerializeButton(UnityObject obj)
|
||||
{
|
||||
if (GUILayout.Button(UnityEditorUtility.GetLabel("Manually serialize")))
|
||||
{
|
||||
var so = new SerializedObject(obj);
|
||||
EditorUtility.SetDirty(obj);
|
||||
so.UpdateIfRequiredOrScript();
|
||||
so.ApplyModifiedProperties();
|
||||
AssetDatabase.SaveAssets();
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
|
@ -156,14 +156,15 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
{
|
||||
Init();
|
||||
|
||||
if (_componentsProp == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsSO)
|
||||
{
|
||||
EcsGUI.Layout.ManuallySerializeButton(target);
|
||||
EcsGUI.Layout.ManuallySerializeButton(targets);
|
||||
}
|
||||
|
||||
if (IsMultipleTargets)
|
||||
{
|
||||
GUILayout.Label("Multi-object editing not supported.", EditorStyles.helpBox);
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsMultipleTargets == false && SerializationUtility.HasManagedReferencesWithMissingTypes(target))
|
||||
@ -187,7 +188,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
iterator.NextVisible(true);
|
||||
while (iterator.NextVisible(false))
|
||||
{
|
||||
if (iterator.name == _componentsProp.name)
|
||||
if (_componentsProp != null && iterator.name == _componentsProp.name)
|
||||
{
|
||||
using (EcsGUI.Layout.BeginVertical(UnityEditorUtility.GetTransperentBlackBackgrounStyle()))
|
||||
{
|
||||
@ -220,12 +221,14 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
}
|
||||
}
|
||||
|
||||
[CanEditMultipleObjects]
|
||||
[CustomEditor(typeof(ScriptableEntityTemplate), true)]
|
||||
internal class ScriptableEntityTemplateEditor : EntityTemplateEditorBase
|
||||
{
|
||||
//public override bool IsStaticData { get { return true; } }
|
||||
protected override bool IsSO => true;
|
||||
}
|
||||
[CanEditMultipleObjects]
|
||||
[CustomEditor(typeof(MonoEntityTemplate), true)]
|
||||
internal class MonoEntityTemplateEditor : EntityTemplateEditorBase
|
||||
{
|
||||
|
@ -146,7 +146,13 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
{
|
||||
if (IsSO)
|
||||
{
|
||||
EcsGUI.Layout.ManuallySerializeButton(target);
|
||||
EcsGUI.Layout.ManuallySerializeButton(targets);
|
||||
}
|
||||
|
||||
if (IsMultipleTargets)
|
||||
{
|
||||
GUILayout.Label("Multi-object editing not supported.", EditorStyles.helpBox);
|
||||
return;
|
||||
}
|
||||
|
||||
EcsGUI.Changed = GUILayout.Button("Validate");
|
||||
|
Loading…
Reference in New Issue
Block a user