mirror of
https://github.com/DCFApixels/DragonECS-Unity.git
synced 2025-09-18 10:04:36 +08:00
add Manually serialize button for so
This commit is contained in:
parent
7f11e90aa5
commit
98190ae382
@ -16,6 +16,20 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
{
|
||||
public static partial class Layout
|
||||
{
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
public static void ScriptAssetButton(MonoScript script, params GUILayoutOption[] options)
|
||||
{
|
||||
EcsGUI.ScriptAssetButton(GUILayoutUtility.GetRect(UnityEditorUtility.GetLabelTemp(), EditorStyles.miniButton, options), script);
|
||||
|
@ -758,6 +758,18 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
#endregion
|
||||
|
||||
#region Other Elements
|
||||
public static void ManuallySerializeButton(Rect position, UnityEngine.Object obj)
|
||||
{
|
||||
if (GUI.Button(position, UnityEditorUtility.GetLabel("Manually serialize")))
|
||||
{
|
||||
var so = new SerializedObject(obj);
|
||||
EditorUtility.SetDirty(obj);
|
||||
so.UpdateIfRequiredOrScript();
|
||||
so.ApplyModifiedProperties();
|
||||
AssetDatabase.SaveAssets();
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
}
|
||||
public static bool AddComponentButton(Rect position, out Rect dropDownRect)
|
||||
{
|
||||
dropDownRect = RectUtility.AddPadding(position, 20f, 20f, 1f, 1f); ;
|
||||
|
@ -16,6 +16,8 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
private SerializedProperty _componentsProp;
|
||||
private ReorderableList _reorderableComponentsList;
|
||||
|
||||
protected abstract bool IsSO { get; }
|
||||
|
||||
//public virtual bool IsStaticData { get { return false; } }
|
||||
|
||||
#region Init
|
||||
@ -161,6 +163,11 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsSO)
|
||||
{
|
||||
EcsGUI.Layout.ManuallySerializeButton(target);
|
||||
}
|
||||
|
||||
if (IsMultipleTargets == false && SerializationUtility.HasManagedReferencesWithMissingTypes(target))
|
||||
{
|
||||
using (EcsGUI.Layout.BeginHorizontal(EditorStyles.helpBox))
|
||||
@ -206,11 +213,13 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
internal class ScriptableEntityTemplateEditor : EntityTemplateEditorBase
|
||||
{
|
||||
//public override bool IsStaticData { get { return true; } }
|
||||
protected override bool IsSO => true;
|
||||
}
|
||||
[CustomEditor(typeof(MonoEntityTemplate), true)]
|
||||
internal class MonoEntityTemplateEditor : EntityTemplateEditorBase
|
||||
{
|
||||
//public override bool IsStaticData { get { return false; } }
|
||||
protected override bool IsSO => false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -8,8 +8,7 @@ using UnityEngine;
|
||||
|
||||
namespace DCFApixels.DragonECS.Unity.Editors
|
||||
{
|
||||
[CustomEditor(typeof(ScriptablePipelineTemplate))]
|
||||
internal class PipelineTemplateEditorBase : ExtendedEditor<IPipelineTemplate>
|
||||
internal abstract class PipelineTemplateEditorBase : ExtendedEditor<IPipelineTemplate>
|
||||
{
|
||||
private SerializedProperty _parametersProp;
|
||||
private SerializedProperty _layersProp;
|
||||
@ -23,6 +22,8 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
get => _reorderableLayersList != null && _reorderableRecordsList != null;
|
||||
}
|
||||
|
||||
protected abstract bool IsSO { get; }
|
||||
|
||||
protected override void OnStaticInit() { }
|
||||
protected override void OnInit()
|
||||
{
|
||||
@ -143,6 +144,11 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
|
||||
protected override void DrawCustom()
|
||||
{
|
||||
if (IsSO)
|
||||
{
|
||||
EcsGUI.Layout.ManuallySerializeButton(target);
|
||||
}
|
||||
|
||||
EcsGUI.Changed = GUILayout.Button("Validate");
|
||||
|
||||
DrawLayoutNameList(_layersProp);
|
||||
@ -199,8 +205,14 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
}
|
||||
|
||||
[CustomEditor(typeof(ScriptablePipelineTemplate), true)]
|
||||
internal class ScriptablePipelineTemplateEditor : PipelineTemplateEditorBase { }
|
||||
internal class ScriptablePipelineTemplateEditor : PipelineTemplateEditorBase
|
||||
{
|
||||
protected override bool IsSO => true;
|
||||
}
|
||||
[CustomEditor(typeof(MonoPipelineTemplate), true)]
|
||||
internal class MonoPipelineTemplateEditor : PipelineTemplateEditorBase { }
|
||||
internal class MonoPipelineTemplateEditor : PipelineTemplateEditorBase
|
||||
{
|
||||
protected override bool IsSO => false;
|
||||
}
|
||||
}
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user