public static void ConditionSelector(this Mission mission, string label, ref bool fold, ref MissionCondition cond, ref MissionCondition.ConditionType type)
        {
            bool foldChanged = false;

            EditorGUILayout.BeginHorizontal();

            EditorGUI.BeginChangeCheck();

            fold = EditorGUILayout.Foldout(fold, new GUIContent(label));

            if (EditorGUI.EndChangeCheck())
            {
                foldChanged = true;
            }

            EditorGUI.BeginChangeCheck();
            type = (MissionCondition.ConditionType)EditorGUILayout.EnumPopup(type);
            if (EditorGUI.EndChangeCheck())
            {
                if (cond != null)
                {
                    if (AssetDatabase.GetAssetPath(cond) == AssetDatabase.GetAssetPath(mission))
                    {
                        GameObject.DestroyImmediate(cond, true);
                    }
                    cond = null;
                    fold = false;
                }

                switch (type)
                {
                case MissionCondition.ConditionType.TeamsDead:
                    cond = TeamsDeadCondition.CreateInstance <TeamsDeadCondition>();
                    break;

                case MissionCondition.ConditionType.UnitsDead:
                    cond = UnitsDeadCondition.CreateInstance <UnitsDeadCondition>();
                    break;

                case MissionCondition.ConditionType.UnitsDeadAmount:
                    cond = UnitsAliveCondition.CreateInstance <UnitsAliveCondition>();
                    break;

                case MissionCondition.ConditionType.PointReached:
                    cond = PointReachedCondition.CreateInstance <PointReachedCondition>();
                    break;

                case MissionCondition.ConditionType.Custom:
                    break;

                case MissionCondition.ConditionType.TurnsPassed:
                    cond = TurnsPassedCondition.CreateInstance <TurnsPassedCondition>();
                    break;

                default:
                    break;
                }
                if (cond)
                {
                    fold = true;
                    cond.conditionType = type;
                    cond.name          = cond.GetType().ToString();
                    //Hide the file
                    cond.hideFlags = HideFlags.HideInHierarchy;
                    //Attatch file to the Mission ScriptableObject
                    AssetDatabase.AddObjectToAsset(cond, mission);
                    AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(cond));
                }
                AssetDatabase.SaveAssets();
            }
            EditorGUILayout.EndHorizontal();
            MissionCondition condition = cond;

            if (fold)
            {
                if (cond != null)
                {
                    if (MissionConditionEditor.cachedEditors.ContainsKey(cond) && MissionConditionEditor.cachedEditors[cond] != null)
                    {
                        MissionConditionEditor.cachedEditors[cond].OnInspectorGUI();
                    }
                    else
                    {
                        //Create editor for the condition
                        Editor ConditionEditor = Editor.CreateEditor(condition);

                        //See if the Inpector can be casted to MissionConditionEditor
                        if (ConditionEditor as MissionConditionEditor != null)
                        {
                            //Initialize custom condition editor
                            ((MissionConditionEditor)ConditionEditor).Init(mission);
                        }
                        //Draw the editor
                        ConditionEditor.OnInspectorGUI();
                    }
                }
                else
                {
                    EditorGUI.indentLevel++;
                    cond = EditorGUILayout.ObjectField("Custom Condition", cond, typeof(MissionCondition), false) as MissionCondition;
                    EditorGUI.indentLevel--;
                }
            }

            if (foldChanged && cond != null && MissionConditionEditor.cachedEditors.ContainsKey(cond) && MissionConditionEditor.cachedEditors[cond] != null)
            {
                if (MissionConditionEditor.cachedEditors[cond] as MissionConditionEditor != null)
                {
                    if (fold)
                    {
                        MissionConditionEditor.cachedEditors[cond].Show();
                    }
                    else
                    {
                        MissionConditionEditor.cachedEditors[cond].Hide();
                    }
                }
            }
        }
 public override void OnInspectorGUI()
 {
     MissionCondition t = target as MissionCondition;
 }