Search Unity

Bug Variable Type cannot be abstract base class

Discussion in 'Visual Scripting' started by OBiwer, Jan 5, 2023.

  1. OBiwer

    OBiwer

    Joined:
    Aug 2, 2022
    Posts:
    61
    I've an abstract base class "BasicMinigame" - all my Minigames inherit from it.

    I'd like to add a Variable to my objects "Variables"-Component, but I only see the non-abstract child classes. I also see "List of Basic Minigame", but not Minigame itself.

    I also tried to add [Serializable, Inspectable] to the base class but it does not help. So my conclusion is: It must be an oversight, because for Unity it's no problem to serialize a field to an abstract base class. It's an artificial limitation of VS.

    __________

    Edit:
    Just to give a bit more details:

    com.unity.visualscripting: 1.7.8
    Unity 2022.2.1f1

    • Nodes are regenerated (already multiple times), this can't be an issue since the child classes are found.

    ________

    Edit 2:

    I created a bug report. It's now tracked as IN-27929
     
    Last edited: Jan 5, 2023
  2. PanthenEye

    PanthenEye

    Joined:
    Oct 14, 2013
    Posts:
    2,079
  3. OBiwer

    OBiwer

    Joined:
    Aug 2, 2022
    Posts:
    61
  4. PanthenEye

    PanthenEye

    Joined:
    Oct 14, 2013
    Posts:
    2,079
    My bad! Looks like I can only get a List<AbstractClass>:

    I'd report this as a bug.

    EDIT: This is my input:

    Code (CSharp):
    1. using System;
    2. using Unity.VisualScripting;
    3. using UnityEngine;
    4.  
    5. [IncludeInSettings(true)][Inspectable]
    6. public abstract class AbstractBaseClass: MonoBehaviour
    7. {
    8.     public abstract void DoSomething();
    9. }
    10.  
    Forcing an update in package manager to version 1.8.0 didn't improve the issue either.
     
    Last edited: Jan 5, 2023
  5. OBiwer

    OBiwer

    Joined:
    Aug 2, 2022
    Posts:
    61
    I created a bug report. It's now tracked as IN-27929
     
    PanthenEye likes this.
  6. PanthenEye

    PanthenEye

    Joined:
    Oct 14, 2013
    Posts:
    2,079
    Apparently it's "by design": https://issuetracker.unity3d.com/is...when-creating-a-new-visual-scripting-variable

    EDIT: This was the response before I reopened the issue:
     
    Last edited: Feb 5, 2023
    OBiwer likes this.
  7. OBiwer

    OBiwer

    Joined:
    Aug 2, 2022
    Posts:
    61
    Well ... then it's obviously bad designed

    edit: sadly you can't use the facepalm emoji here
     
  8. PanthenEye

    PanthenEye

    Joined:
    Oct 14, 2013
    Posts:
    2,079
    I guess just like with generics they expect you to implement a custom node for any operations with abstract types. It's unfortunate, especially since [SerializeReference] exists but UVS is not using native Unity serialization, it's based on the defunct FullSerializer which explains discrepancies. The next major version of the tool will hopefully address this but per the stickied November 2022 update, it'll take them 2-3 years.

    FullSerializer does support Interfaces, so perhaps that's another avenue to explore in the meantime.
     
  9. OBiwer

    OBiwer

    Joined:
    Aug 2, 2022
    Posts:
    61
    Well.... I could live with that... but no: I can use all the functions of the abstract base class as nodes. It's just that I can't have them as variables. Nodes are fine.

    So basically I'd have to create either a wrapper type (which is super annoying) or make the base class non-abstract (even more annoying).
     
  10. OBiwer

    OBiwer

    Joined:
    Aug 2, 2022
    Posts:
    61
    The response I got:
    instead of fixing, the went with having a bad design. ‍♂️

    at least this is still in progress