Search Unity

Strange behaviour of ScriptableObject reference at Inspector

Discussion in 'Scripting' started by leegod, Oct 1, 2019.

  1. leegod

    leegod

    Joined:
    May 5, 2010
    Posts:
    2,475
    I am experiencing very strange behaviour of unity engine...

    Code (CSharp):
    1. public [abstract] class ActorGeneral : ScriptableObject
    2. {
    3.     public string Name;
    4.     public Sprite Portrait;
    5. }
    6.  
    There is inherited specific class from above.

    But if I write [abstract] at above base class, derived specific scriptableObject's inspector's reference missed when turn off Unity and turn on Unity again after save scene, save project.

    If I remove [abstract] at above base class, derived specific scriptableObject's inspector's reference live as normal.

    And before hit the play button, this scriptableobject says there is script error and fix it, but just after press play button and play, its gone and works again.

    Why this happen, how to fix?

    reference.PNG
     
  2. jister

    jister

    Joined:
    Oct 9, 2009
    Posts:
    1,749
    You can not use an abstract class as an object only direved classes.
     
  3. jister

    jister

    Joined:
    Oct 9, 2009
    Posts:
    1,749
  4. leegod

    leegod

    Joined:
    May 5, 2010
    Posts:
    2,475
  5. jister

    jister

    Joined:
    Oct 9, 2009
    Posts:
    1,749
    I didn't see the whole tut, but in the scripts on that page i dont see abstract anywhere. Abstract class can only be used as a base class, inherit a class from it and use that.
     
    Ryiah likes this.
  6. leegod

    leegod

    Joined:
    May 5, 2010
    Posts:
    2,475
    Of course I assigned inherited specific class, not abstract class itself.
     
  7. Why do you have square brackets around the abstract keyword?

    BTW, the first script starts with this :) :
    Code (CSharp):
    1. public abstract class Ability : ScriptableObject {
     
    Last edited by a moderator: Oct 2, 2019
  8. leegod

    leegod

    Joined:
    May 5, 2010
    Posts:
    2,475
    @Lurking-Ninja Just for emphasize and easy to let you know, of course not used as-is like at code.
     
  9. jister

    jister

    Joined:
    Oct 9, 2009
    Posts:
    1,749
    Oeps ;p