#Help with ScriptableObject

1 messages · Page 1 of 1 (latest)

shrewd shuttle
#
namespace Entity.Dialogue
{
    using System.Collections;
    using System.Collections.Generic;
    using System;
    using UnityEngine;

    [Serializable]
    [CreateAssetMenu (fileName = "Data", menuName = "Dialogue Script")]
    public class DialogueScript : ScriptableObject
    {
        [SerializeField]
        public DialogueCommand[] commands;

        public DialogueScript (DialogueCommand[] commands)
        {
            this.commands = commands;
        }
    }
}
quick kettle
#

Show DialogueCommand

shrewd shuttle
#

I tried adding [Serializable] and SerializeField but neither worked

quick kettle
#

also you don't need both [SerializeField] and public on a fiekld

#

only one or the other

shrewd shuttle
#
    public struct DialogueCommand
    {
        public Command command;
        public string arg;
        public AudioClip clip;

        public DialogueCommand (Command command, string arg = "", AudioClip clip = null)
        {
            this.command = command;
            this.arg     = arg;
            this.clip    = clip;
        }
    }
quick kettle
#

also Command needs to also be serializable

shrewd shuttle
#

seems to be working

#

oh, command isn't serialized

quick kettle
#

ah if Command is an enum then it's fine

#

looks like it's working

shrewd shuttle
#

Now to do some fancy stuff with odin inspector and maybe I can hide the "clip" property when the command isn't Command.Say

shrewd shuttle