What is the efficient way of showing variables depend on enum in custom inspector?

I want the inspector to show different variable depends on the enum you choose. I know i need to use custom inspector but there are some general variables i want to show that don’t depend on the enum and always showing. How can i achieve it and what the general and efficient way of showing custom variable?

You can do this with some conditional control flow in a custom inspector:

public enum Group { One, Two }

public class Client : MonoBehaviour {
	public Group Group;
	public bool GroupOneData;
	public float GroupTwoData;
	public string IndependentData;

[CustomEditor (typeof (Client))]
public class ClientEditor : Editor {
	void OnInspectorGUI () {
		Client client = (Client)target;
		// Display dropdown
		client.Group = (Group)EditorGUILayout.EnumPopup ("Group", client.Group);

		// Display conditional for one	
		if (client.Group == Group.One) {
			client.GroupOneData = EditorGUILayout.Toggle ("Bool", client.GroupOneData);

		// Display conditional for two
		if (client.Group == Group.Two) {
			client.GroupTwoData = EditorGUILayout.FloatField("Float", client.GroupTwoData);

		// Display always
		client.IndependentData = EditorGUILayout.TextField ("String", client.IndependentData);

When One is selected for Group, the “Bool” toggle will appear. When Two is selected for Group, the “Float” field will appear. The “String” text field will appear regardless of which option is selected. If, in the future, you add an additional Three option to the group enum, neight the “Bool” nor “Float” fields will appear if it is selected. “String” will appear no matter what.

When you have an enum with some variables in it, for your class use :

public enum bla {blie, yay, boo};

public class blu : MonoBehaviour