0
\$\begingroup\$

I'm unsure as to how I would reference a scriptable object's variables within a struct from another class. I know I'd have to make a public Conversation, but I'm stuck understanding how I could access it's struct, and how I could access individual variables such as the Position, or line string array.

Is this method even viable or should I look at creating a different way of accomplishing a dialogue conversation scriptable object?

Thanks for any insights and help~

My current code:

[System.Serializable]
[CreateAssetMenu(fileName = "New Conversation", menuName = "Create/Conversation", order = 1)]

public class Conversation : ScriptableObject
{
    [System.Serializable]
    public struct LineData
    {
        public string[] line;
        public string[] option;

        public enum Position
        {
            BottomLeft,
            BottomCentre,
            BottomRight,
            MiddleLeft,
            MiddleCentre,
            MiddleRight,
            TopLeft,
            TopCentre,
            TopRight
        }

        public Position position;

        public enum TextSpeed
        {          
            Normal,
            Slow,
            Fast,
            UltraFast
        }

        public TextSpeed textSpeed;

    }
    public LineData[] Line;

}

```
\$\endgroup\$
0
\$\begingroup\$

to be honest I didn't understand much about your codes but this is a right approach in many possible approaches:

any dialogue by a character can cause one or more dialogues from the same or other characters. so every dialogue can contain this model:

    class Dialogue
    {
public bool IsRoot;
public string Guid;// or any unique text
public string CharacterName;
public string DialogueText;
public List<string> ResultingDialoguesIds;
    }

you can make a ScriptableObject class that holds a list of this class(and also you can make a graph editor in unity to let designers make dialogues for you):

class LevelDialogues : ScriptableObject
{
public List<Dialogues> Dialogues;
}

when you want to start the dialogue in your game just query for dialogue that is signed as IsRoot and step by step generate Upcoming Dialogues. that is a simple way. maybe you can include some of your text formatting variable in Dialogue class.

\$\endgroup\$
1
  • \$\begingroup\$ Thank you, this helped me get closer to what I need~ \$\endgroup\$ – TouhouSong Apr 4 at 1:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.