0
\$\begingroup\$

I'm making a word game in Unity.

I've made two Scriptable Objects. The first one is for FeemData.

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[CreateAssetMenu(fileName = "New FeemData", menuName = "Feem Data", order = 51)]

public class FeemData : ScriptableObject
{
[SerializeField]
public string feemName;

[SerializeField]
public string Neem;

[SerializeField]
public Int32 neemNumber;

[SerializeField]
public string coreGrapheme;

[SerializeField]
public string shadowString;

}

And the second one is for NeemData

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[CreateAssetMenu(fileName = "New NeemData", menuName = "Neem Data", order = 51)]

public class NeemData : ScriptableObject
{
[SerializeField]
public string neemName;

[SerializeField]
public string feemText;

[SerializeField]
public Color feemColor;

}

Right now, the NeemData Scriptable Object has a string field called feemText.

In actuality, each Neem can have multiple Feems. I'd love to turn the feemText into a List of Feems, so that I can drag and drop the relevant Feems into the Neem in the Inspector.

Any suggestions on how to edit the NeemData Scriptable Object to include a List of Scriptable Objects (in this case, the FeemData)? Thank you!!

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

You should use a public or serialized List<FeemData> (or an array FeemData[]). Like so:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
    
[CreateAssetMenu(fileName = "New NeemData", menuName = "Neem Data", order = 51)]
    
public class NeemData : ScriptableObject
{
    [SerializeField]
    public string neemName;
    
    [SerializeField]
    public string feemText;
    
    [SerializeField]
    public Color feemColor;
    
    //Do this
    [SerializeField]
    public List<FeemData> Feems;
    
}
\$\endgroup\$
1
  • \$\begingroup\$ Amazing Harsh, THANK YOU SO MUCH!! It worked perfectly. \$\endgroup\$
    – kanamekun
    Jul 6 at 11:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .