🎚️
Lever System - Doc
  • Lever System - Introduction
  • ⭐Getting Started
    • Quick Setup
    • Detailed Setup
  • ❓Support
    • FAQ
    • Power Up Event
    • Adding Audioclips
    • Where are inputs?
    • System Namespace
    • Note about custom inspector
    • System Controller References
  • 🌀Development
    • Patch Notes - V1.3
    • Roadmap
  • 📧Contacts
    • Contact Me
    • My Other Assets
Powered by GitBook
On this page
  1. Support

Note about custom inspector

PreviousSystem NamespaceNextSystem Controller References

Last updated 2 years ago

NOTE: If you're confused any way, just send me an email and I'll be happy to help!

  • 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

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.

  • At the top of the editor script we create a serialized property to hold the field we'll use like this:

SerializedProperty _objectType;
  • We then go to the "OnEnable" method and find the appropriate field reference

_objectType = serializedObject.FindProperty(nameof(_objectType));
  • With the "OnInspectorGUI" method we then apply the property by using:

EditorGUILayout.PropertyField(_objectType);
  • See the full code below:

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();
        }
❓