Search Unity

Resolved I cant see my derived classes. Weapons + Enhancements Scriptable Objects.

Discussion in 'Scripting' started by AquaShuba, Jan 25, 2021.

  1. AquaShuba

    AquaShuba

    Joined:
    May 13, 2020
    Posts:
    3
    I'm not sure how to get my List field of type "enhancement" to see my derived classes.

    Code (CSharp):
    1.  
    2. //Base
    3. public abstract class Enhancement : ScriptableObject
    4. {
    5.     public int damage;
    6.     public virtual void Enhance() {
    7.  
    8.     }
    9. }
    10.  
    11.  
    12. //variants of enhancement
    13. [CreateAssetMenu(menuName = "Enhancement/Fire New")]
    14. public class Fire : Enhancement
    15. {
    16.     public override void Enhance()
    17.     {
    18.      
    19.     }
    20. }
    21.  
    22. [CreateAssetMenu(menuName = "Enhancement/Ice New")]
    23. public class Ice : Enhancement
    24. {
    25.     public override void Enhance()
    26.     {
    27.      
    28.     }
    29. }
    30.  
    31. // Weapon
    32. [CreateAssetMenu(menuName = "Weapon/New Weapon")]
    33. public class Weapon : ScriptableObject
    34. {
    35.     public List<Enhancement> enhancements;
    36. }
    37.  
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,909
    What do you mean by "see" them?
     
  3. AquaShuba

    AquaShuba

    Joined:
    May 13, 2020
    Posts:
    3
    When I create a new weapon and when I click on the enhancements field in the inspector. The Assets dialogs don't show any of my created Ice or Fire scriptable objects.

    upload_2021-1-25_11-12-55.png
     
  4. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,909
    Yeah that dialog has never really worked for me either. I usually just drag them in from the project window, which works fine.
     
    AquaShuba likes this.
  5. AquaShuba

    AquaShuba

    Joined:
    May 13, 2020
    Posts:
    3
    Ah ok thanks for the help! I was able to drag it in.