Skip to content

Commit 637292e

Browse files
committed
Minor refactor changes
1 parent 184c24d commit 637292e

4 files changed

Lines changed: 13 additions & 9 deletions

File tree

Assets/Editor Toolbox/Editor/ContextMenu/Operations/SerializeReference/CopySerializeReferenceOperation.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ internal class CopySerializeReferenceOperation : IContextMenuOperation
77
{
88
internal static CopySerializedRererenceCache Cache { get; private set; }
99

10+
[InitializeOnLoadMethod]
11+
private static void Initialize()
12+
{
13+
Cache = null;
14+
}
15+
1016
public bool IsVisible(SerializedProperty property)
1117
{
1218
#if UNITY_2021_3_OR_NEWER
@@ -38,11 +44,5 @@ public void Perform(SerializedProperty property)
3844
}
3945

4046
public GUIContent Label => new GUIContent("Copy Serialize Reference");
41-
42-
[InitializeOnLoadMethod]
43-
private static void Initialize()
44-
{
45-
Cache = null;
46-
}
4747
}
4848
}

Assets/Editor Toolbox/Editor/ContextMenu/Operations/SerializeReference/DuplicateSerializeReferenceArrayElementOperation.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ namespace Toolbox.Editor.ContextMenu.Operations
55
{
66
internal class DuplicateSerializeReferenceArrayElementOperation : IContextMenuOperation
77
{
8-
public GUIContent Label => new GUIContent("Duplicate Serialize Reference Array Element");
9-
108
public bool IsVisible(SerializedProperty property)
119
{
1210
#if UNITY_2021_3_OR_NEWER
@@ -24,6 +22,7 @@ public bool IsEnabled(SerializedProperty property)
2422

2523
public void Perform(SerializedProperty property)
2624
{
25+
#if UNITY_2021_3_OR_NEWER
2726
var sourceProperty = property.Copy();
2827
sourceProperty.serializedObject.Update();
2928
var sourceValue = sourceProperty.managedReferenceValue;
@@ -41,6 +40,9 @@ public void Perform(SerializedProperty property)
4140
}
4241

4342
sourceProperty.serializedObject.ApplyModifiedProperties();
43+
#endif
4444
}
45+
46+
public GUIContent Label => new GUIContent("Duplicate Serialize Reference Array Element");
4547
}
4648
}

Assets/Editor Toolbox/Editor/ContextMenu/Operations/SerializeReference/PasteSerializeReferenceOperation.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public bool IsEnabled(SerializedProperty property)
3838

3939
public void Perform(SerializedProperty property)
4040
{
41+
#if UNITY_2019_3_OR_NEWER
4142
var targetProperty = property.Copy();
4243
try
4344
{
@@ -47,6 +48,7 @@ public void Perform(SerializedProperty property)
4748
}
4849
catch (Exception)
4950
{ }
51+
#endif
5052
}
5153

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

Assets/Editor Toolbox/Editor/Drawers/Toolbox/PropertySelf/ReferencePickerAttributeDrawer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ private void CreateTypeProperty(SerializedProperty property, Type parentType, Re
5858
{
5959
using (var so = new SerializedObject(target))
6060
{
61-
SerializedProperty sp = so.FindProperty(property.propertyPath);
61+
var sp = so.FindProperty(property.propertyPath);
6262
UpdateTypeProperty(sp, type, attribute);
6363
}
6464
}

0 commit comments

Comments
 (0)