No GUI error on my NoiseSettings variable

For some reason my NoiseSettings variables stopped showing up on the inspector, i get the message: No GUI found instead.
They were showing up before, i made some changes on the code, but as far as i know, nothing that should have changed that.

using UnityEngine;
using Unity.Cinemachine;
using Unity.Netcode;
using Events;
using System;

namespace Player
{
    public class PlayerVisual : NetworkBehaviour
    {
        //[SerializeField] private CinemachineImpulseSource _fallImpulse;
        //[SerializeField] private CinemachineImpulseSource _jumpImpulse

        [SerializeField] private float _sidewaysMaxTilt;
        [SerializeField] private float _forwardMaxTilt;
        [SerializeField] private float _smoothTime = .1f;
        private float _currentDutchVelocity;

        private CinemachineCamera _virtualCamera;        
        private CinemachineBasicMultiChannelPerlin _multiChannelPerlin;
        private CinemachinePanTilt _panTilt;

        [SerializeField] private NoiseSettings _idleNoiseSettings;
        [SerializeField] private NoiseSettings _walkNoiseSettings;
        [SerializeField] private NoiseSettings _runNoiseSettings;
        [SerializeField] private NoiseSettings _crouchNoiseSettings;
        [SerializeField] private NoiseSettings _proneNoiseSettings;

        [Rpc(SendTo.Owner)]
        public void SetCameraClientRpc(NetworkObjectReference cameraNetObjRef)
        {
            if (cameraNetObjRef.TryGet(out NetworkObject cameraNetObj))
            {
                CinemachineCamera camera = cameraNetObj.GetComponent<CinemachineCamera>();
                _virtualCamera = camera;                

                _multiChannelPerlin = _virtualCamera.GetComponent<CinemachineBasicMultiChannelPerlin>();
                _panTilt = _virtualCamera.GetComponent<CinemachinePanTilt>();
            }
        }
        public void TiltCamera(Vector2FloatStruct eventData)
        {
            float sidewaysLeanSpeed = Mathf.Abs(eventData.Input.x * eventData.Acceleration);
            float forwardsLeanSpeed = Mathf.Abs(eventData.Input.y * eventData.Acceleration);
            Debug.Log("tilt camera being called");

            float targetSidewaysTilt = (eventData.Input.x > 0) ? -_sidewaysMaxTilt : _sidewaysMaxTilt;
            float targetForwardTilt = (eventData.Input.y > 0) ? _forwardMaxTilt : -_forwardMaxTilt;

            _virtualCamera.Lens.Dutch = Mathf.SmoothDamp
                (
                    _virtualCamera.Lens.Dutch,
                    targetSidewaysTilt,
                    ref _currentDutchVelocity,
                    _smoothTime / sidewaysLeanSpeed // Adjust smooth time based on lean speed
                );

            _panTilt.TiltAxis.Value = Mathf.SmoothDamp
                (
                    _panTilt.TiltAxis.Value,
                    targetForwardTilt,
                    ref _currentDutchVelocity,
                    _smoothTime / forwardsLeanSpeed // Adjust smooth time based on lean speed
                );

        }

        public void SetNoiseSetting(Enum state)
        {
            Debug.Log("Set nosie setting being called");
            switch (state)
            {
                case PlayerStateMachine.EPlayerStates.Idle:
                    _multiChannelPerlin.NoiseProfile = _idleNoiseSettings;
                    Debug.Log("noise profile: " + _multiChannelPerlin.NoiseProfile);
                    break;
                case PlayerStateMachine.EPlayerStates.Walk:
                    _multiChannelPerlin.NoiseProfile = _walkNoiseSettings;
                    Debug.Log("noise profile: " + _multiChannelPerlin.NoiseProfile);
                    break;
                case PlayerStateMachine.EPlayerStates.Run:
                    _multiChannelPerlin.NoiseProfile = _runNoiseSettings;
                    Debug.Log("noise profile: " + _multiChannelPerlin.NoiseProfile);
                    break;
                case PlayerStateMachine.EPlayerStates.Crouch:
                    _multiChannelPerlin.NoiseProfile = _crouchNoiseSettings;
                    Debug.Log("noise profile: " + _multiChannelPerlin.NoiseProfile);
                    break;
                case PlayerStateMachine.EPlayerStates.Prone:
                    _multiChannelPerlin.NoiseProfile = _proneNoiseSettings;
                    Debug.Log("noise profile: " + _multiChannelPerlin.NoiseProfile);
                    break;                
            }
        }
    }
}

You very likely have the inspector in Debug mode. Switch it back to Normal.

That doesn’t seem to be it :confused:

Could these scripts have anything to do with it?

using UnityEngine;
using UnityEditor;
using System;

namespace EditorNamespace
{      
    [CustomPropertyDrawer(typeof(ScriptableObject), true)]
    public class GenericScriptableObjectPropertyDrawer : PropertyDrawer
    {
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            EditorGUI.BeginProperty(position, label, property);

            // Reserve space for the object field
            Rect objectFieldRect = new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight);

            // Draw the object field
            EditorGUI.ObjectField(objectFieldRect, property, label);

            // Check if the field has the Expandable attribute
            bool isExpandable = Attribute.IsDefined(fieldInfo, typeof(ExpandableAttribute));

            if (property.objectReferenceValue != null && isExpandable)
            {
                // Draw the foldout
                property.isExpanded = EditorGUI.Foldout(
                    new Rect(position.x, position.y + EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing,
                            position.width, EditorGUIUtility.singleLineHeight),
                    property.isExpanded, "Edit " + property.objectReferenceValue.name
                );

                if (property.isExpanded)
                {
                    EditorGUI.indentLevel++;
                    SerializedObject serializedObject = new SerializedObject(property.objectReferenceValue);
                    SerializedProperty iterator = serializedObject.GetIterator();
                    iterator.NextVisible(true);
                    float yPos = objectFieldRect.y + EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing * 2;

                    while (iterator.NextVisible(false))
                    {
                        Rect propertyRect = new Rect(position.x, yPos, position.width, EditorGUIUtility.singleLineHeight);
                        EditorGUI.PropertyField(propertyRect, iterator, true);
                        yPos += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
                    }

                    serializedObject.ApplyModifiedProperties();
                    EditorGUI.indentLevel--;
                }
            }

            EditorGUI.EndProperty();
        }

        public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            float height = EditorGUIUtility.singleLineHeight;
            bool isExpandable = Attribute.IsDefined(fieldInfo, typeof(ExpandableAttribute));

            if (property.objectReferenceValue != null && property.isExpanded && isExpandable)
            {
                SerializedObject serializedObject = new SerializedObject(property.objectReferenceValue);
                SerializedProperty iterator = serializedObject.GetIterator();
                iterator.NextVisible(true);

                while (iterator.NextVisible(false))
                {
                    height += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
                }

                // Add spacing for the foldout label
                height += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
            }

            return height;
        }
    }
}
namespace EditorNamespace
{
    public class ExpandableAttribute : PropertyAttribute { }
}

Ah yes, that’s it. You need to add a UIToolkit implementation to your PropertyDrawer. CM3 is phasing out the use of IMGUI and many of its PropertyDrawer classes don’t have IMGUI implementations.

UITooklt is backwards-compatible with IMGUI in the sense that a UIToolkit container can show IMGUI elements, but it doesn’t work the other way: you can’t show UIToolkit elements from IMGUI containers.

What’s happening is that your IMGUI PropertyDrawer or inspector is trying to use PropertyDrawers that have only UIToolkit implementations.

To verify this, try removing the custom PropertyDrawer.

Did you meant removing it from the GenericScriptableObjectPropertyDrawer class i made?
If so, i commented out that line and it didn’t work.
Then, i removed both classes from my project and restarted unity, also didn’t work

Yes, that’s what I meant. I’m suggesting that you display your object using a default inspector.

Can you send me the class whose inspector is wrong? Perhaps I’m not understanding the issue. Also: what versions of Unity and Cinemachine are you using?

I already sent you the class that is having the issue, it’s my PlayerVisual class. However, i believe the issue is related to the NoiseSettings itself, since when I add it to any other class, the same message appears.

I probably complicated things my sending my Editor classes, it’s just that i’m new to creating custom inspectors so i was thinking it might be related.

I’m using Unity 6000.0.32f1, and Cinemachine 3.1.2.

I tried uninstalling Cinemachine and installing it again, but that didn’t fix the issue.

Another thing that might be related is the fact that it’s my first time using Assembly Definitions, maybe i messed something up.
The Assembly the PlayerVisual class is on does have a reference to the Cinemachine assembly, However, i noticed that the Cinemachine Assembly is missing a reference to the GUI.

I already sent you the class that is having the issue

Indeed you did. My bad for not noticing.

When I take the relevant part of your script and create a behaviour for it, the default inspector is fine. I suspect that you have some custom inspector somewhere that’s picking it up and trying to use IMGUI on it.

public class Testy : MonoBehaviour
{
    [SerializeField] private float _sidewaysMaxTilt;
    [SerializeField] private float _forwardMaxTilt;
    [SerializeField] private float _smoothTime = .1f;
    private float _currentDutchVelocity;

    private CinemachineCamera _virtualCamera;        
    private CinemachineBasicMultiChannelPerlin _multiChannelPerlin;
    private CinemachinePanTilt _panTilt;

    [SerializeField] private NoiseSettings _idleNoiseSettings;
    [SerializeField] private NoiseSettings _walkNoiseSettings;
    [SerializeField] private NoiseSettings _runNoiseSettings;
    [SerializeField] private NoiseSettings _crouchNoiseSettings;
    [SerializeField] private NoiseSettings _proneNoiseSettings;
}

The only custom inspectors I had were the ones i sent you earlier, and i deleted them from the project.

I suspect that you have some custom inspector somewhere

Maybe an inspector for NetworkBehaviour that also handles subclasses? Try making a custom inspector for PlayerVisual that just draws all the properties with UIToolkit.

1 Like

That solved the issue, Thank you!!

Do you have any idea why this happend thought? Could it be something related to the Assemblies like i said above?

I don’t know. It’s hard to say.

1 Like