# Note about custom inspector

{% hint style="warning" %}
NOTE: If you're confused any way, just send me an email and I'll be happy to help!
{% endhint %}

* If you take a look in the "Scripts > Editor" folder you will find the custom inspector script for both the "LeverItem" and the "LeverSystemController" scripts. You can edit these if you want variables from the appropriate scripts to appear in the inspectorn

![](https://3938358402-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjZd3MS9LFbeyIQGU6AmI%2Fuploads%2FdVr2TuzmcbLN216qcxkB%2FScripts_Editor.JPG?alt=media\&token=a219ca3f-4296-4a3d-9168-72dfe9255682)

## Example Editor Script:

As you can see below, we can set the "EditorGUILayout.PropertyField" to add a new reference to a field or variable in the inspector.&#x20;

* At the top of the editor script we create a serialized property to hold the field we'll use like this:&#x20;

```csharp
SerializedProperty _objectType;
```

* We then go to the "OnEnable" method and find the appropriate field reference

```csharp
_objectType = serializedObject.FindProperty(nameof(_objectType));
```

* With the "OnInspectorGUI" method we then apply the property by using:&#x20;

```csharp
EditorGUILayout.PropertyField(_objectType);
```

* See the full code below:

```csharp
public override void OnInspectorGUI()
        {
            GUI.enabled = false;
            EditorGUILayout.ObjectField("Script:", MonoScript.FromMonoBehaviour((LeverItem)target), typeof(LeverItem), false);
            GUI.enabled = true;

            EditorGUILayout.Space(5);

            LeverItem _leverItem = (LeverItem)target;

            EditorGUILayout.PropertyField(_objectType);

            EditorGUILayout.Space(5);

            if (_leverItem._objectType == LeverItem.ObjectType.Lever)
            {
                EditorGUILayout.PropertyField(leverNumber);
                EditorGUILayout.Space(5);
            }

            EditorGUILayout.PropertyField(animationName);

            EditorGUILayout.Space(10);

            EditorGUILayout.LabelField("Controller Reference", EditorStyles.toolbarTextField);
            EditorGUILayout.PropertyField(_leverSystemController);

            serializedObject.ApplyModifiedProperties();
        }
```
