Closed MJRamon closed 6 months ago
Custom solution works fine:
public class ReadOnlyAttribute : PropertyAttribute { }
[CustomPropertyDrawer(typeof(ReadOnlyAttribute))]
public class ReadOnlyDrawer : PropertyDrawer {
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) {
return EditorGUI.GetPropertyHeight(property, label, true);
}
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) {
var previousGUIState = GUI.enabled;
GUI.enabled = false;
EditorGUI.PropertyField(position, property, label, true);
GUI.enabled = previousGUIState;
}
}
Hi, cloud you please provide a reproducible script/project? I at this point can not reproducible this issue:
public class Issue2 : MonoBehaviour
{
public bool enableVisualDebug;
[SepTitle("Separate Here", EColor.Black)]
[ReadOnly, SerializeField] private float _currentForwardSpeedInUnits;
[ReadOnly, SerializeField] private float _currentSpeedInUnits;
[ReadOnly, SerializeField] private float _currentSpeedInKmph;
[ReadOnly, SerializeField] private float _maxSpeedKmph;
public int throttle;
public int currentGear;
}
IU Toolkit:
IMGUI (Oh there is a bug in IMGUI 😔 but not related to this issue):
Unity: 2022.2.0f1
P.S. The readonly
and showIf/hideIf
indeed need some re-work that I'll do recent days. This is most likely because the EditorGUI.EndDisabledGroup();
failed to execute in pair with EditorGUI.StartDisabledGroup();
in SaintsField. So if you can give more detail it'll be appreciated.
Closed due to can't reproduce + lack of activity.
Please comment on this issue or open another issue if you still face this(or similar) problem.
Label and value fields are messed up when using SaintsField's ReadOnly attribute:
Not using ReadOnly attribute: