Skip to content

Commit ad8836f

Browse files
committed
Make PropertyUtility public
1 parent 1bdb3cf commit ad8836f

1 file changed

Lines changed: 17 additions & 18 deletions

File tree

Assets/Editor Toolbox/Editor/Utilities/PropertyUtility.cs

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using System.Collections;
33
using System.Linq;
44
using System.Reflection;
5-
using System.Runtime.CompilerServices;
65

76
using UnityEditor;
87
using Object = UnityEngine.Object;
@@ -14,15 +13,15 @@ public static partial class PropertyUtility
1413
/// <summary>
1514
/// Indicates if the property has all changes applied and can be safely used for reflection-based features.
1615
/// </summary>
17-
internal static bool HasModifedProperties(this SerializedProperty property)
16+
public static bool HasModifedProperties(this SerializedProperty property)
1817
{
1918
return property.serializedObject.hasModifiedProperties;
2019
}
2120

2221
/// <summary>
2322
/// Creates and returns unique (hash based) key for this property.
2423
/// </summary>
25-
internal static string GetPropertyHashKey(this SerializedProperty property)
24+
public static string GetPropertyHashKey(this SerializedProperty property)
2625
{
2726
var hash = property.serializedObject.GetHashCode();
2827
#if UNITY_2019_2_OR_NEWER
@@ -37,7 +36,7 @@ internal static string GetPropertyHashKey(this SerializedProperty property)
3736
/// <summary>
3837
/// Creates and returns unique (type based) key for this property.
3938
/// </summary>
40-
internal static string GetPropertyTypeKey(this SerializedProperty property)
39+
public static string GetPropertyTypeKey(this SerializedProperty property)
4140
{
4241
var type = property.serializedObject.targetObject.GetType();
4342
#if UNITY_2019_2_OR_NEWER
@@ -52,31 +51,31 @@ internal static string GetPropertyTypeKey(this SerializedProperty property)
5251
/// <summary>
5352
/// Returns <see cref="object"/> which truly declares this property.
5453
/// </summary>
55-
internal static object GetDeclaringObject(this SerializedProperty property)
54+
public static object GetDeclaringObject(this SerializedProperty property)
5655
{
5756
return GetDeclaringObject(property, property.serializedObject.targetObject);
5857
}
5958

6059
/// <summary>
6160
/// Returns <see cref="object"/> which truly declares this property.
6261
/// </summary>
63-
internal static object GetDeclaringObject(this SerializedProperty property, bool ignoreArrays)
62+
public static object GetDeclaringObject(this SerializedProperty property, bool ignoreArrays)
6463
{
6564
return GetDeclaringObject(property, property.serializedObject.targetObject, ignoreArrays);
6665
}
6766

6867
/// <summary>
6968
/// Returns <see cref="object"/> which truly declares this property.
7069
/// </summary>
71-
internal static object GetDeclaringObject(this SerializedProperty property, Object target)
70+
public static object GetDeclaringObject(this SerializedProperty property, Object target)
7271
{
7372
return GetDeclaringObject(property, target, true);
7473
}
7574

7675
/// <summary>
7776
/// Returns <see cref="object"/> which truly declares this property.
7877
/// </summary>
79-
internal static object GetDeclaringObject(this SerializedProperty property, Object target, bool ignoreArrays)
78+
public static object GetDeclaringObject(this SerializedProperty property, Object target, bool ignoreArrays)
8079
{
8180
EnsureReflectionSafeness(property);
8281

@@ -101,7 +100,7 @@ internal static object GetDeclaringObject(this SerializedProperty property, Obje
101100
return validReference;
102101
}
103102

104-
internal static object GetTreePathReference(string treeField, object treeParent)
103+
public static object GetTreePathReference(string treeField, object treeParent)
105104
{
106105
if (IsSerializableArrayElement(treeField, out var index))
107106
{
@@ -123,7 +122,7 @@ internal static object GetTreePathReference(string treeField, object treeParent)
123122
/// Returns proper <see cref="FieldInfo"/> value for this property, even if the property is an array element.
124123
/// </summary>
125124
/// <param name="fieldInfo">FieldInfo associated to provided property.</param>
126-
internal static object GetProperValue(this SerializedProperty property, FieldInfo fieldInfo)
125+
public static object GetProperValue(this SerializedProperty property, FieldInfo fieldInfo)
127126
{
128127
return GetProperValue(property, fieldInfo, property.GetDeclaringObject());
129128
}
@@ -133,7 +132,7 @@ internal static object GetProperValue(this SerializedProperty property, FieldInf
133132
/// </summary>
134133
/// <param name="property"></param>
135134
/// <param name="fieldInfo">FieldInfo associated to provided property.</param>
136-
internal static object GetProperValue(this SerializedProperty property, FieldInfo fieldInfo, object declaringObject)
135+
public static object GetProperValue(this SerializedProperty property, FieldInfo fieldInfo, object declaringObject)
137136
{
138137
if (fieldInfo == null)
139138
{
@@ -161,7 +160,7 @@ internal static object GetProperValue(this SerializedProperty property, FieldInf
161160
/// </summary>
162161
/// <param name="property"></param>
163162
/// <param name="fieldInfo">FieldInfo associated to provided property.</param>
164-
internal static void SetProperValue(this SerializedProperty property, FieldInfo fieldInfo, object value)
163+
public static void SetProperValue(this SerializedProperty property, FieldInfo fieldInfo, object value)
165164
{
166165
SetProperValue(property, fieldInfo, value, true);
167166
}
@@ -173,7 +172,7 @@ internal static void SetProperValue(this SerializedProperty property, FieldInfo
173172
/// </summary>
174173
/// <param name="property"></param>
175174
/// <param name="fieldInfo">FieldInfo associated to provided property.</param>
176-
internal static void SetProperValue(this SerializedProperty property, FieldInfo fieldInfo, object value, bool callOnValidate)
175+
public static void SetProperValue(this SerializedProperty property, FieldInfo fieldInfo, object value, bool callOnValidate)
177176
{
178177
if (fieldInfo == null)
179178
{
@@ -211,7 +210,7 @@ internal static void SetProperValue(this SerializedProperty property, FieldInfo
211210
/// Returns proper <see cref="Type"/> for this property, even if the property is an array element.
212211
/// </summary>
213212
/// <param name="fieldInfo">FieldInfo associated to provided property.</param>
214-
internal static Type GetProperType(this SerializedProperty property, FieldInfo fieldInfo)
213+
public static Type GetProperType(this SerializedProperty property, FieldInfo fieldInfo)
215214
{
216215
if (fieldInfo == null)
217216
{
@@ -233,7 +232,7 @@ internal static Type GetProperType(this SerializedProperty property, FieldInfo f
233232
}
234233
}
235234

236-
internal static Type GetScriptTypeFromProperty(SerializedProperty property)
235+
public static Type GetScriptTypeFromProperty(SerializedProperty property)
237236
{
238237
var scriptProperty = property.serializedObject.FindProperty(Defaults.scriptPropertyName);
239238
if (scriptProperty == null)
@@ -251,17 +250,17 @@ internal static Type GetScriptTypeFromProperty(SerializedProperty property)
251250
}
252251

253252

254-
internal static FieldInfo GetFieldInfo(this SerializedProperty property)
253+
public static FieldInfo GetFieldInfo(this SerializedProperty property)
255254
{
256255
return GetFieldInfo(property, out _);
257256
}
258257

259-
internal static FieldInfo GetFieldInfo(this SerializedProperty property, out Type propertyType)
258+
public static FieldInfo GetFieldInfo(this SerializedProperty property, out Type propertyType)
260259
{
261260
return GetFieldInfoFromProperty(property, out propertyType);
262261
}
263262

264-
internal static FieldInfo GetFieldInfo(this SerializedProperty property, out Type propertyType, Object target)
263+
public static FieldInfo GetFieldInfo(this SerializedProperty property, out Type propertyType, Object target)
265264
{
266265
return GetFieldInfoFromProperty(property, out propertyType, target.GetType());
267266
}

0 commit comments

Comments
 (0)