> For the complete documentation index, see [llms.txt](https://kinematicsoup.gitbook.io/scene-fusion/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kinematicsoup.gitbook.io/scene-fusion/api-reference/ks.scenefusion.client.unity.editor/ks.scenefusion.client.unity.editor.sfpropertyutils.md).

# Class sfPropertyUtils

Namespace: [KS.SceneFusion.Client.Unity.Editor](/scene-fusion/api-reference/ks.scenefusion.client.unity.editor.md)\
Assembly: KSUnity-Source.dll

Utility class for converting between sfProperties and common types.

```csharp
public class sfPropertyUtils
```

#### Inheritance

object ← [sfPropertyUtils](/scene-fusion/api-reference/ks.scenefusion.client.unity.editor/ks.scenefusion.client.unity.editor.sfpropertyutils.md)

## Methods

### ApplyProperties(SerializedObject, bool) <a href="#ks_scenefusion_client_unity_editor_sfpropertyutils_applyproperties_unityeditor_serializedobject_syst" id="ks_scenefusion_client_unity_editor_sfpropertyutils_applyproperties_unityeditor_serializedobject_syst"></a>

Applies serialized property changes without registering an undo operation, and marks the target object dirty if there were any changes.

```csharp
public static bool ApplyProperties(SerializedObject so, bool rebuildInspectors = false)
```

#### Parameters

`so` SerializedObject

serialized object to apply properties to.

`rebuildInspectors` bool

if true and properties changed, rebuilds inspectors, which is slower but necessary for it to display properly if components were added or deleted.

#### Returns

bool

true if there were any changes applied.

### FromAnimationCurve(AnimationCurve) <a href="#ks_scenefusion_client_unity_editor_sfpropertyutils_fromanimationcurve_unityengine_animationcurve" id="ks_scenefusion_client_unity_editor_sfpropertyutils_fromanimationcurve_unityengine_animationcurve"></a>

Converts an AnimationCurve to an sfValueProperty.

```csharp
public static sfValueProperty FromAnimationCurve(AnimationCurve value)
```

#### Parameters

`value` AnimationCurve

value to convert.

#### Returns

[sfValueProperty](/scene-fusion/api-reference/ks.scenefusion/ks.scenefusion.sfvalueproperty.md)

the AnimationCurve as a property.

### FromGradient(Gradient) <a href="#ks_scenefusion_client_unity_editor_sfpropertyutils_fromgradient_unityengine_gradient" id="ks_scenefusion_client_unity_editor_sfpropertyutils_fromgradient_unityengine_gradient"></a>

Converts a Gradient to an sfValueProperty.

```csharp
public static sfValueProperty FromGradient(Gradient value)
```

#### Parameters

`value` Gradient

value to convert.

#### Returns

[sfValueProperty](/scene-fusion/api-reference/ks.scenefusion/ks.scenefusion.sfvalueproperty.md)

the Gradient as a property.

### FromReference(Object, SerializedProperty) <a href="#ks_scenefusion_client_unity_editor_sfpropertyutils_fromreference_unityengine_object_unityeditor_seri" id="ks_scenefusion_client_unity_editor_sfpropertyutils_fromreference_unityengine_object_unityeditor_seri"></a>

Converts a uobject reference to an sfReferenceProperty or sfNullProperty. Syncs the uobject if it can be synced, otherwise if it is an asset, creates an asset path sfObject for it if one does not already exist.

```csharp
public static sfBaseProperty FromReference(Object uobj, SerializedProperty sprop = null)
```

#### Parameters

`uobj` Object

uobj to convert.

`sprop` SerializedProperty

sprop referencing the uobject. If the uobject is a stand-in for an asset that is available, updates the reference on this property to the correct asset.

#### Returns

[sfBaseProperty](/scene-fusion/api-reference/ks.scenefusion/ks.scenefusion.sfbaseproperty.md)

### GetAssetInfo(sfDictionaryProperty, Type) <a href="#ks_scenefusion_client_unity_editor_sfpropertyutils_getassetinfo_ks_scenefusion_sfdictionaryproperty" id="ks_scenefusion_client_unity_editor_sfpropertyutils_getassetinfo_ks_scenefusion_sfdictionaryproperty"></a>

Gets an [sfAssetInfo](/scene-fusion/api-reference/ks.scenefusion.client.unity.editor/ks.scenefusion.client.unity.editor.sfassetinfo.md) from path, class, and index fields in a dictionary property.

```csharp
public static sfAssetInfo GetAssetInfo(sfDictionaryProperty dict, Type type = null)
```

#### Parameters

`dict` [sfDictionaryProperty](/scene-fusion/api-reference/ks.scenefusion/ks.scenefusion.sfdictionaryproperty.md)

Dictionary property with path, (optionally) class, and (optionally) index fields.

`type` Type

If provided, the asset info will use this type for the class name instead of looking for a class field in the dictionary.

#### Returns

[sfAssetInfo](/scene-fusion/api-reference/ks.scenefusion.client.unity.editor/ks.scenefusion.client.unity.editor.sfassetinfo.md)

Asset info

### GetGradient(SerializedProperty) <a href="#ks_scenefusion_client_unity_editor_sfpropertyutils_getgradient_unityeditor_serializedproperty" id="ks_scenefusion_client_unity_editor_sfpropertyutils_getgradient_unityeditor_serializedproperty"></a>

Gets a gradient value from a serialized property.

```csharp
public static Gradient GetGradient(SerializedProperty sprop)
```

#### Parameters

`sprop` SerializedProperty

sprop to get gradient from.

#### Returns

Gradient

value from the property.

### IsCustomProperty(sfBaseProperty) <a href="#ks_scenefusion_client_unity_editor_sfpropertyutils_iscustomproperty_ks_scenefusion_sfbaseproperty" id="ks_scenefusion_client_unity_editor_sfpropertyutils_iscustomproperty_ks_scenefusion_sfbaseproperty"></a>

Checks if a property is one of our custom properties. Checks the names of the property and its ancestors to see if any begin with '#'.

```csharp
public static bool IsCustomProperty(sfBaseProperty prop)
```

#### Parameters

`prop` [sfBaseProperty](/scene-fusion/api-reference/ks.scenefusion/ks.scenefusion.sfbaseproperty.md)

prop to check.

#### Returns

bool

true if the property or one of its ancestor names begins with '#'.

### ReplaceReferences(sfObject, sfObject) <a href="#ks_scenefusion_client_unity_editor_sfpropertyutils_replacereferences_ks_scenefusion_client_sfobject" id="ks_scenefusion_client_unity_editor_sfpropertyutils_replacereferences_ks_scenefusion_client_sfobject"></a>

Replaces all sfReferenceProperties referencing oldObj with newObj.

```csharp
public static void ReplaceReferences(sfObject oldObj, sfObject newObj)
```

#### Parameters

`oldObj` [sfObject](/scene-fusion/api-reference/ks.scenefusion.client/ks.scenefusion.client.sfobject.md)

`newObj` [sfObject](/scene-fusion/api-reference/ks.scenefusion.client/ks.scenefusion.client.sfobject.md)

### SetAssetInfoProperties(sfDictionaryProperty, sfAssetInfo, bool) <a href="#ks_scenefusion_client_unity_editor_sfpropertyutils_setassetinfoproperties_ks_scenefusion_sfdictionar" id="ks_scenefusion_client_unity_editor_sfpropertyutils_setassetinfoproperties_ks_scenefusion_sfdictionar"></a>

Sets path and optionally class fields from an asset info in a dictionary property. If the asset info is for a subasset, also sets the index field.

```csharp
public static void SetAssetInfoProperties(sfDictionaryProperty dict, sfAssetInfo info, bool includeClassName = true)
```

#### Parameters

`dict` [sfDictionaryProperty](/scene-fusion/api-reference/ks.scenefusion/ks.scenefusion.sfdictionaryproperty.md)

Dictionary property to set fields in.

`info` [sfAssetInfo](/scene-fusion/api-reference/ks.scenefusion.client.unity.editor/ks.scenefusion.client.unity.editor.sfassetinfo.md)

Asset info to get field values from.

`includeClassName` bool

If true, sets the class field to [ClassName](/scene-fusion/api-reference/ks.scenefusion.client.unity.editor/ks.scenefusion.client.unity.editor.sfassetinfo.md#ks_scenefusion_client_unity_editor_sfassetinfo_classname).

### SetGradient(SerializedProperty, Gradient) <a href="#ks_scenefusion_client_unity_editor_sfpropertyutils_setgradient_unityeditor_serializedproperty_unitye" id="ks_scenefusion_client_unity_editor_sfpropertyutils_setgradient_unityeditor_serializedproperty_unitye"></a>

Sets a gradient value on a serialized property.

```csharp
public static void SetGradient(SerializedProperty sprop, Gradient value)
```

#### Parameters

`sprop` SerializedProperty

sprop to set gradient on.

`value` Gradient

### ToAnimationCurve(sfBaseProperty) <a href="#ks_scenefusion_client_unity_editor_sfpropertyutils_toanimationcurve_ks_scenefusion_sfbaseproperty" id="ks_scenefusion_client_unity_editor_sfpropertyutils_toanimationcurve_ks_scenefusion_sfbaseproperty"></a>

Converts an sfProperty to an AnimationCurve.

```csharp
public static AnimationCurve ToAnimationCurve(sfBaseProperty property)
```

#### Parameters

`property` [sfBaseProperty](/scene-fusion/api-reference/ks.scenefusion/ks.scenefusion.sfbaseproperty.md)

property to convert.

#### Returns

AnimationCurve

value of the property. Null if the property could not be converted to an AnimationCurve.

### ToGradient(sfBaseProperty) <a href="#ks_scenefusion_client_unity_editor_sfpropertyutils_togradient_ks_scenefusion_sfbaseproperty" id="ks_scenefusion_client_unity_editor_sfpropertyutils_togradient_ks_scenefusion_sfbaseproperty"></a>

Converts an sfProperty to a Gradient.

```csharp
public static Gradient ToGradient(sfBaseProperty property)
```

#### Parameters

`property` [sfBaseProperty](/scene-fusion/api-reference/ks.scenefusion/ks.scenefusion.sfbaseproperty.md)

property to convert.

#### Returns

Gradient

value of the property. Null if the property could not be converted to an Gradient.

### ToReference\<T>(sfBaseProperty, T) <a href="#ks_scenefusion_client_unity_editor_sfpropertyutils_toreference__1_ks_scenefusion_sfbaseproperty___0" id="ks_scenefusion_client_unity_editor_sfpropertyutils_toreference__1_ks_scenefusion_sfbaseproperty___0"></a>

Converts a property to a T reference. T must be a UObject.

```csharp
public static T ToReference<T>(sfBaseProperty prop, T current = null) where T : Object
```

#### Parameters

`prop` [sfBaseProperty](/scene-fusion/api-reference/ks.scenefusion/ks.scenefusion.sfbaseproperty.md)

prop to convert.

`current` T

current reference value. This is returned if the property cannot be converted.

#### Returns

T

#### Type Parameters

`T`
