I really like building instances of classes using the Inspector through a prefab. The benefits are numerous, and the code behind instantiation is clean. However, the only way (that I know of) to create an instance of the class is by creating a new GameObject when the class inherits from MonoBehaviour. Is there another way I can save instances of modified scripts edited through the inspector without inheriting from MonoBehaviour? Or, is there an easier way to create a copy of the referenced class as a new object while MonoBehaviour is inherited without creating a GameObject? I know that Unity doesn’t like it when you declare a new Class():MonoBehavior, so creating a deep copy would also be another near impossibility.
public class AbilityMovement : MonoBehaviour
{
public string Name;
internal Quaternion FacingDirection;
public AnimationCurve DirectionX;
public AnimationCurve DirectionY;
public AnimationCurve DirectionZ;
internal Vector3 DirectionalMovement;
public float Force;
internal float VerticalSpeed;
public float Lifetime;
internal float RemainingLifetime;
public class AbilityInstance
{
public AbilityMovement Ability;
public AbilityInstance(AbilityMovement ability, Quaternion facingVectorDirection)
{
Ability = Instantiate<AbilityMovement>(ability);
}
}
}