Skip to content

Commit

Permalink
Minor refactor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
arimger committed Aug 26, 2024
1 parent 184c24d commit 637292e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ internal class CopySerializeReferenceOperation : IContextMenuOperation
{
internal static CopySerializedRererenceCache Cache { get; private set; }

[InitializeOnLoadMethod]
private static void Initialize()
{
Cache = null;
}

public bool IsVisible(SerializedProperty property)
{
#if UNITY_2021_3_OR_NEWER
Expand Down Expand Up @@ -38,11 +44,5 @@ public void Perform(SerializedProperty property)
}

public GUIContent Label => new GUIContent("Copy Serialize Reference");

[InitializeOnLoadMethod]
private static void Initialize()
{
Cache = null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ namespace Toolbox.Editor.ContextMenu.Operations
{
internal class DuplicateSerializeReferenceArrayElementOperation : IContextMenuOperation
{
public GUIContent Label => new GUIContent("Duplicate Serialize Reference Array Element");

public bool IsVisible(SerializedProperty property)
{
#if UNITY_2021_3_OR_NEWER
Expand All @@ -24,6 +22,7 @@ public bool IsEnabled(SerializedProperty property)

public void Perform(SerializedProperty property)
{
#if UNITY_2021_3_OR_NEWER
var sourceProperty = property.Copy();
sourceProperty.serializedObject.Update();
var sourceValue = sourceProperty.managedReferenceValue;
Expand All @@ -41,6 +40,9 @@ public void Perform(SerializedProperty property)
}

sourceProperty.serializedObject.ApplyModifiedProperties();
#endif
}

public GUIContent Label => new GUIContent("Duplicate Serialize Reference Array Element");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public bool IsEnabled(SerializedProperty property)

public void Perform(SerializedProperty property)
{
#if UNITY_2019_3_OR_NEWER
var targetProperty = property.Copy();
try
{
Expand All @@ -47,6 +48,7 @@ public void Perform(SerializedProperty property)
}
catch (Exception)
{ }
#endif
}

public GUIContent Label => new GUIContent("Paste Serialize Reference");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ private void CreateTypeProperty(SerializedProperty property, Type parentType, Re
{
using (var so = new SerializedObject(target))
{
SerializedProperty sp = so.FindProperty(property.propertyPath);
var sp = so.FindProperty(property.propertyPath);
UpdateTypeProperty(sp, type, attribute);
}
}
Expand Down

0 comments on commit 637292e

Please sign in to comment.