mirror of
https://github.com/DCFApixels/DragonECS-Unity.git
synced 2025-09-17 17:34:34 +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 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)
|
public static void ManuallySerializeButton(UnityObject obj)
|
||||||
{
|
{
|
||||||
if (GUILayout.Button(UnityEditorUtility.GetLabel("Manually serialize")))
|
if (GUILayout.Button(UnityEditorUtility.GetLabel("Manually serialize")))
|
||||||
{
|
{
|
||||||
var so = new SerializedObject(obj);
|
|
||||||
EditorUtility.SetDirty(obj);
|
EditorUtility.SetDirty(obj);
|
||||||
so.UpdateIfRequiredOrScript();
|
|
||||||
so.ApplyModifiedProperties();
|
|
||||||
AssetDatabase.SaveAssets();
|
AssetDatabase.SaveAssets();
|
||||||
AssetDatabase.Refresh();
|
AssetDatabase.Refresh();
|
||||||
}
|
}
|
||||||
|
@ -156,14 +156,15 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
|
|
||||||
if (_componentsProp == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IsSO)
|
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))
|
if (IsMultipleTargets == false && SerializationUtility.HasManagedReferencesWithMissingTypes(target))
|
||||||
@ -187,7 +188,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
iterator.NextVisible(true);
|
iterator.NextVisible(true);
|
||||||
while (iterator.NextVisible(false))
|
while (iterator.NextVisible(false))
|
||||||
{
|
{
|
||||||
if (iterator.name == _componentsProp.name)
|
if (_componentsProp != null && iterator.name == _componentsProp.name)
|
||||||
{
|
{
|
||||||
using (EcsGUI.Layout.BeginVertical(UnityEditorUtility.GetTransperentBlackBackgrounStyle()))
|
using (EcsGUI.Layout.BeginVertical(UnityEditorUtility.GetTransperentBlackBackgrounStyle()))
|
||||||
{
|
{
|
||||||
@ -220,12 +221,14 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[CanEditMultipleObjects]
|
||||||
[CustomEditor(typeof(ScriptableEntityTemplate), true)]
|
[CustomEditor(typeof(ScriptableEntityTemplate), true)]
|
||||||
internal class ScriptableEntityTemplateEditor : EntityTemplateEditorBase
|
internal class ScriptableEntityTemplateEditor : EntityTemplateEditorBase
|
||||||
{
|
{
|
||||||
//public override bool IsStaticData { get { return true; } }
|
//public override bool IsStaticData { get { return true; } }
|
||||||
protected override bool IsSO => true;
|
protected override bool IsSO => true;
|
||||||
}
|
}
|
||||||
|
[CanEditMultipleObjects]
|
||||||
[CustomEditor(typeof(MonoEntityTemplate), true)]
|
[CustomEditor(typeof(MonoEntityTemplate), true)]
|
||||||
internal class MonoEntityTemplateEditor : EntityTemplateEditorBase
|
internal class MonoEntityTemplateEditor : EntityTemplateEditorBase
|
||||||
{
|
{
|
||||||
|
@ -146,7 +146,13 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
{
|
{
|
||||||
if (IsSO)
|
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");
|
EcsGUI.Changed = GUILayout.Button("Validate");
|
||||||
|
Loading…
Reference in New Issue
Block a user