Forum rules - please read before posting.

Field reverting to blank upon playing scene

Hello! I made a custom action that checks a scriptable object for a boolean. All works fine, however upon pressing Play the field with the scriptable object empties itself. If I pause and re-add the object before the cutscene reaches this action it works as intended.

Could this be due to the scriptable object? I'm using the latest AC and Unity 2018.2.13f1

Thanks for your help Chris! AC is, as always, saving my skin in myriad ways.

Comments

  • I should have added the full script here, and noted that this scriptable object works fine with my other custom actions.

    /*
    *
    * Adventure Creator
    * by Chris Burton, 2013-2016
    *
    * "ActionCheckTemplate.cs"
    *
    * This is a blank action template, which has two outputs.
    *
    */

    if UNITY_EDITOR

    using UnityEditor;

    endif

    namespace AC
    {

    [System.Serializable]
    public class QuestCheck : ActionCheck
    {
    
        // Declare variables here
        Quest quest;
        public enum checkType{stage, complete, condtion , specialCheck}
        public checkType checkQuestType;
    
        public int amount;
        public bool passed;
    
        public QuestHandler questHandler;
    
    
        public QuestCheck()
        {
            this.isDisplayed = true;
            category = ActionCategory.Dialogue;
            title = "Check Quest Stage";
            description = "Check how far along a quest is, or whether it is complete";
        }
    
    
        public override bool CheckCondition ()
        {
            // Return 'true' if the condition is met, and 'false' if it is not met.
            questHandler = QuestHandler.instance;
    
            switch (checkQuestType)
            {
                case checkType.stage:
                    var questStage = questHandler.CheckQuestStage(quest);
                    if (questStage >= amount)
                    {
                        return true;
                    }
                    else
                    {
                        return false;
                    }
                case checkType.complete:
                    var questComplete = questHandler.CheckQuestComplete(quest);
                    if (questComplete == true)
                    {
                        return true;
                    }
                    else
                    {
                        return false;
                    }
                case checkType.condtion:
                    var questCondition = questHandler.CheckQuestCondition(quest);
                    if (questCondition >= amount)
                    {
                        return true;
                    }
                    else
                    {
                        return false;
                    }
                case checkType.specialCheck:
                    var questSpecialSet = questHandler.CheckSpecialSet(quest, amount);
                    if (questSpecialSet == true)
                    {
                        return true;
                    }
                    else
                    {
                        return false;
                    }
    
                default:
                    return false;
            }
    
    
        }
    
    
        #if UNITY_EDITOR
    
        override public void ShowGUI ()
        {
            // Action-specific Inspector GUI code here.  The "Condition is met" / "Condition is not met" GUI is rendered automatically afterwards.
            checkQuestType = (checkType)EditorGUILayout.EnumPopup("Type to test", checkQuestType);
            quest = (Quest)EditorGUILayout.ObjectField("Quest to affect: ", quest, typeof(Quest), true);
            amount = (int)EditorGUILayout.IntField("Amount", amount);
    
            AfterRunningOption();
        }
    
    
        public override string SetLabel ()
        {
            // Return a string used to describe the specific action's job.
    
            string labelAdd = "";
            return labelAdd;
        }
    
        #endif
    
    }
    

    }

  • I've had this solved on the discord channel by the extremely helpful Alverik. In case anyone searches these forums with the same issue I'll leave this up.

    My goof was the following: I hadn't set the Quest class to be public. I am a goon. Thanks discord channel!

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.