General Workflow

Component Configuration Standard defines the basic format of configuration-type components and allows to create personal configuration components with minimal efforts. General layout of configuration component looks as follows:

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/983419f6-d288-4506-a416-83ffe74b569d/Untitled.png

Active Mode field shows configuration active mode that is being set/ read by other components. Then goes the list of configuration modes, and each one of them holds the unique name and arbitrary settings.

Standard consists of two components: ComponentBaseConfiguration and ComponentBaseConfigurationEditor.

Component Base Configuration

ComponentBaseConfiguration is a parent class for all configuration components. It holds the definition of Active Mode parameter and Generic-class ConfigurationBase that all configuration mode classes are being inherited from.

Component Base Configuration Editor

ComponentBaseConfigurationEditor is responsible for drawing (serialization) of configuration components in the Unity editor. All Editor components of configuration components are being inherited from it.

Creation of a Private Configuration Component

In order to create private configuration component it is necessary to create a class that is being inherited from ComponentBaseConfiguration, and a class that is being inherited from ComponentBaseConfigurationEditor. In the example shown below, classes are called ComponentExampleConfiguration and ComponentExampleConfigurationEditor accordingly.

ComponentExampleConfiguration.cs

using System.Collections.Generic;
using UnityEngine;

public class ComponentExampleConfiguration : ComponentBaseConfiguration
{ 
	[SerializeField, HideInInspector] protected List<Entry> Configurations; 
	public Vector3 this[string key] { 
		get { return Configurations.Find(x => x.key == key).value; } 
	} 
	[System.Serializable] public class Entry : ConfigurationBase<Vector3> { }
}

Any descendant of ComponentBaseConfiguration has to hold the list of entries named Configurations, which, in turn, has to be marked with a [SerializeField] attribute. Besides, it is also necessary to declare the entry class Entry, which has to be inherited from Generic-class ConfigurationBase, and marked with [System.Serializable] attribute.

ComponentExampleConfigurationEditor.cs

using UnityEditor;
[CustomEditor(typeof(ComponentExampleConfiguration))]
public class ComponentExampleConfigurationEditor : ComponentBaseConfigurationEditor
{
}

All that has to be done in this component, is to be inherited from ComponentBaseConfigurationEditor and set the type of private configuration component in [CustomEditor] attribute.

Limitations