# managedReferenceId

> Id associated with a managed reference.

## Definition

* **Type:** Property
* **Namespace:** [UnityEditor](/engine/6000.0/script-reference/unityeditor.md)
* **Assembly:** UnityEditor

```csharp
public long managedReferenceId { get; set; }
```

### Remarks

Available when [SerializedProperty.propertyType](/engine/6000.0/script-reference/unityeditor/serializedproperty/propertytype.md) is [SerializedPropertyType.ManagedReference](/engine/6000.0/script-reference/unityeditor/serializedpropertytype/managedreference.md).  If the reference is null then the Id is RefIdNull.

Additional Resources: [SerializeReference](/engine/6000.0/script-reference/unityengine/serializereference.md), [SerializedProperty.managedReferenceValue](/engine/6000.0/script-reference/unityeditor/serializedproperty/managedreferencevalue.md), [ManagedReferenceUtility.GetManagedReferenceIdForObject](/engine/6000.0/script-reference/unityengine/serialization/managedreferenceutility/getmanagedreferenceidforobject.md).

### Examples

```csharp
using System;
using UnityEditor;
using UnityEngine;

public class SerializedPropertyManagedReferenceIdExample : ScriptableObject
{
    [Serializable]
    public class Item
    {
        public int m_data = 1;
    }

    [SerializeReference]
    public Item m_Item;

    [SerializeReference]
    public Item m_Item2;

    [MenuItem("Example/SerializedProperty ManagedReferenceId Example")]
    static void TestMethod1()
    {
        var scriptableObject = ScriptableObject.CreateInstance<SerializedPropertyManagedReferenceIdExample>();
        scriptableObject.m_Item = new Item();

        using (var serializedObject = new SerializedObject(scriptableObject))
        {
            var itemProperty = serializedObject.FindProperty("m_Item");
            var item2Property = serializedObject.FindProperty("m_Item2");

            // Set m_Item2 to point to the same object as m_Item
            // Note: managedReferenceValue could also be used here, for the same result
            item2Property.managedReferenceId = itemProperty.managedReferenceId;

            serializedObject.ApplyModifiedProperties();
        }

        // Check the results back on the live object

        //Will print "Value of m_Item2.m_data: 1"
        Debug.Log("Value of m_Item2.m_data: " + scriptableObject.m_Item2.m_data);

        // Prove that both fields point to the same object
        scriptableObject.m_Item.m_data = 2;

        //Will print "Value of m_Item2.m_data: 2"
        Debug.Log("Value of m_Item2.m_data: " + scriptableObject.m_Item2.m_data);
    }
}
```
