Question by 
               Colin_Brilliant_Labs · 5 days ago · 
                c#unity 2dunityeditorclass  
              
 
              How to override constructor when creating a new element in a list from the inspector.
I have a class that contains a list of another class and an enum.
 public class CutsceneDialog
 {
     public List<MoveCharacterInCutscene> characterMovements = new List<MoveCharacterInCutscene>();
     [Header("Relative - Move relative to current position")]
     public PositionType positionType = PositionType.Relative;
 
 }
 
               The issue is that the MoveCharacterInCutscene class needs to know what the value for positionType is.
  public class MoveCharacterPositions
     {
 
         //We need our constructor to get the positionType
         MoveCharacterPositions(PositionType positionType)
         {
             this.positionType = positionType;
             Debug.Log("got position type: " + positionType);
         }
 
         [Header("Insantly warp the player to their positions, rather than move them over time.")]
         public bool instantWarp = false;
         
         public Vector2 absolutePosition = Vector2.zero;
         //Only display our relative position Vector2 if position is relative
         [ConditionalField(true, "IsPositionRelative")]
         public Vector2 relativePosition = Vector2.zero;
 
         //Checks if our position is relative
         public bool IsPositionRelative()
         {
             return positionType == PositionType.Relative ? true : false;
         }
         public PositionType positionType;
 
     }
 
               Is there a way that I can override the contructor method when created a new element in the list from the inspector? Or if there are any other ways to do this, please let me know :)
               Comment
              
 
               
              Your answer
 
             Follow this Question
Related Questions
Value doesn't change in game when updated. 2 Answers
Override constructor of list of classes when creating a new element from the inspector 0 Answers
Break the loop when there are no more questions 0 Answers
Double tap to reduce score by 2 points 0 Answers
How to make platform to rotate player ? 0 Answers