/// <summary> /// Resets the current struct. /// </summary> public void ResetDeclarationStruct() { nameSpace = string.Empty; accessModifier = AccessModifierPopUp.Public; typeModifier = TypeModifierPopUp.None; type = TypePopUp.Class; scriptName = string.Empty; inheritsFrom = InheritsFromPopUp.MonoBehaviour; inheritsFromCustom = string.Empty; summary = string.Empty; }
/// <summary> /// Similar to Unity's OnValidate. It is called in an OnValidate of a MonoBehaviour. /// </summary> public void OnValidate() { // Elements defined in a namespace may be explicitly declared public or internal. if (accessModifier == AccessModifierPopUp.Private || accessModifier == AccessModifierPopUp.Protected || accessModifier == AccessModifierPopUp.ProtectedInternal || accessModifier == AccessModifierPopUp.PrivateProtected) { accessModifier = AccessModifierPopUp.Public; } if (type == TypePopUp.Class) { if (typeModifier == TypeModifierPopUp.Static) { // Cannot inherit from any class except Object if (inheritsFrom == InheritsFromPopUp.MonoBehaviour || inheritsFrom == InheritsFromPopUp.ScriptableObject || inheritsFrom == InheritsFromPopUp.Editor) { inheritsFrom = InheritsFromPopUp.None; } } } if (type == TypePopUp.Interface) { // Can not be abstract, partial, sealed or static. Set to none. typeModifier = TypeModifierPopUp.None; // Can not inherit MonoBehaviour, ScriptableObject or Editor. Set default to none. if (inheritsFrom == InheritsFromPopUp.MonoBehaviour || inheritsFrom == InheritsFromPopUp.ScriptableObject || inheritsFrom == InheritsFromPopUp.Editor) { inheritsFrom = InheritsFromPopUp.None; } } if (type == TypePopUp.ScriptableObject) { // Can not be static. Set default to none. if (typeModifier == TypeModifierPopUp.Static) { typeModifier = TypeModifierPopUp.None; } // Obviously it has to inherit from ScriptableObject. inheritsFrom = InheritsFromPopUp.ScriptableObject; } if (type == TypePopUp.Struct) { // Can only use sealed or none. Set default to none. if (typeModifier == TypeModifierPopUp.Abstract || typeModifier == TypeModifierPopUp.Sealed || typeModifier == TypeModifierPopUp.Static) { typeModifier = TypeModifierPopUp.None; } // Can not inherit MonoBehaviour, ScriptableObject or Editor. Set default to none. if (inheritsFrom == InheritsFromPopUp.MonoBehaviour || inheritsFrom == InheritsFromPopUp.ScriptableObject || inheritsFrom == InheritsFromPopUp.Editor) { inheritsFrom = InheritsFromPopUp.None; } } if (type == TypePopUp.Enum) { // Can not be abstract, partial, sealed or static. Set to none. typeModifier = TypeModifierPopUp.None; // Can not inherit from anywhere. Set to none. inheritsFrom = InheritsFromPopUp.None; } }