Search Unity

Question Set an array of spells in a ScriptableObject

Discussion in 'Scripting' started by Saw9yer, Oct 17, 2021.

  1. Saw9yer

    Saw9yer

    Joined:
    Sep 19, 2020
    Posts:
    72
    Hello everyone,
    I have a scriptable object that i use to create weapons.
    Code (CSharp):
    1. [CreateAssetMenu(fileName = "New weapon", menuName = "Weapon")]
    2. public class WeaponData : ScriptableObject
    3. {
    4.     public string name_;
    5.     public Sprite sprite;
    6.     public bool ranged;
    7.     public int energy;
    8. }
    I try to give each weapons 1 to 25 slots. In order to set spells in these slots.
    I think the best solution is to use an array
    My problem is that i don't see how to do it.
    Can you help me?
     
  2. GroZZleR

    GroZZleR

    Joined:
    Feb 1, 2015
    Posts:
    3,201
    Code (csharp):
    1.  
    2. public SpellData[] spellSlots;
    3.  
    And then drag and drop the equivalent spell SOs in the inspector?