in Scripts/Editor/Windows/PropertyDrawers/WitPropertyDrawer.cs [104:182]
protected virtual void LayoutField(int index, SerializedProperty property, FieldInfo subfield, WitPropertyEditType editType)
{
// Begin layout
GUILayout.BeginHorizontal();
// Get label content
string labelText = GetLocalizedText(property, subfield.Name);
GUIContent labelContent = new GUIContent(labelText);
// Determine if can edit
bool canEdit = editType == WitPropertyEditType.FreeEdit || (editType == WitPropertyEditType.LockEdit && editIndex == index);
bool couldEdit = GUI.enabled;
GUI.enabled = canEdit;
// Cannot edit, just show field
SerializedProperty subfieldProperty = property.FindPropertyRelative(subfield.Name);
if (!canEdit && subfieldProperty.type == "string")
{
// Get value text
string valText = subfieldProperty.stringValue;
if (string.IsNullOrEmpty(valText))
{
valText = GetDefaultFieldValue(property, subfield);
}
// Layout key
WitEditorUI.LayoutKeyLabel(labelText, valText);
}
// Can edit, allow edit
else
{
GUILayout.BeginVertical();
LayoutPropertyField(subfield, subfieldProperty, labelContent, canEdit);
GUILayout.EndVertical();
}
// Reset
GUI.enabled = couldEdit;
// Lock Settings
if (editType == WitPropertyEditType.LockEdit)
{
// Is Editing
if (editIndex == index)
{
// Clear Edit
if (WitEditorUI.LayoutIconButton(WitStyles.ResetIcon))
{
editIndex = -1;
string clearVal = "";
if (subfieldProperty.type != "string")
{
clearVal = GetDefaultFieldValue(property, subfield);
}
SetFieldStringValue(subfieldProperty, clearVal);
GUI.FocusControl(null);
}
// Accept Edit
if (WitEditorUI.LayoutIconButton(WitStyles.AcceptIcon))
{
editIndex = -1;
GUI.FocusControl(null);
}
}
// Not Editing
else
{
// Begin Editing
if (WitEditorUI.LayoutIconButton(WitStyles.EditIcon))
{
editIndex = index;
GUI.FocusControl(null);
}
}
}
// End layout
GUILayout.EndHorizontal();
}