there are five times when I would use indentation.
When writing code in a scope
public void Func()
{
//some code here
}
When I’m calling a function with several parameters I would sometimes write them multiline if it would make them read better. similar with the common convention of writing inline arrays into a function
Debug.LogFormat(
"The GameObject '{0}' did not have the component '{1}' thus {2} could not target it.",
target.name,
componentType.name,
gameObject.name);
When I’m doing object chaining calls I’ll typcally put each chained call on an indented line. A habit I picked up from writing in jQuery. I typically do this with Linq.
Ternary Operators. To me it just looks clean indenting them like so and became habit back when I wrote in AVISynth where Ternarys were literally the only control structure you had for making a decision. It didn’t support “if statments” or any loop strutcures, just ternarys and recursive calls.
Color fgc_default = GUI.contentColor;
Color fgc_Invalid = new Color(1.0f,0.5f,0.5f);
bool fieldValid = !string.IsNullOrEmpty(serializedProperty.stringValue);
GUI.contentColor = (fieldValid)
?fgc_default
:fgc_Invalid;
EditorGUILayout.PropertyField(serializedProperty);
GUI.contentColor = fgc_default;
5)Grouping Functions, typically those in EditorGUILayout. I usually indent the code inbetween the begin and end as it helps me keep a cognitive track on where the code will be drawn it also helps me spot any semantic typos with thelayout
EditorGUILayout.BeginHorizontal();
EditorGUILayout.BeginVertical();
//Column A Code
EditorGUILayout.EndVertical();
EditorGUILayout.BeginVertical();
//Column B Code
EditorGUILayout.EndVertical();
EditorGUILayout.BeginVertical();
//Column C Code
EditorGUI.BeginDisabledGroup(booleanValue);
// Disabled Group Code
EditorGUI.EndDisabledGroup();
EditorGUILayout.EndVertical();
EditorGUILayout.EndHorizontal();
As per grouping a set of functions together, I’m with BoredMormon. Regions are better suited for this.it gives a distinct area where the awesome functions are and it something that easily collapsible by the IDE