I would like to customize the menu depending on the context in which there are several variables.
This is my code :
using System;
using UnityEditor;
using TypeInput = SplinePathMesh.TypeInput;
using UnityEngine;
[CustomEditor(typeof(SplinePathMesh))]
public class SplinePathMeshEditor : Editor {
SerializedObject m_Object;
SerializedProperty m_Property;
void OnEnable() {
m_Object = new SerializedObject(target);
m_Property = m_Object.GetIterator();
}
public override void OnInspectorGUI() {
SplinePathMesh path = (SplinePathMesh)target;
EditorGUILayout.BeginVertical();
while (m_Property.NextVisible(true)) {
if (path.typeInput == TypeInput.Transform && m_Property.name == "pathVector3") {
m_Property.NextVisible(false);
}
if (path.typeInput == TypeInput.Vector3 && m_Property.name == "pathTransform") {
m_Property.NextVisible(false);
}
//if (m_Property.propertyType != SerializedPropertyType.ObjectReference) {
EditorGUILayout.PropertyField(m_Property);
//}
}
m_Property.Reset();
EditorGUILayout.EndVertical();
// Apply the property, handle undo
m_Object.ApplyModifiedProperties();
//DrawDefaultInspector();
}
}
This function works; But when i click for assign a object i recive this error :
ArgumentException: Getting control 4's position in a group with only 4 controls when doing ExecuteCommand Aborting ArgumentException: Getting control 4's position in a group with only 4 controls when doing repaint Aborting