Solved: Had to add UnityEngine.Resources

        public static Quest GetByName(string questName)
        {
            foreach (Quest quest in **UnityEngine.Resources**.LoadAll<Quest>(""))
            {
                if(quest.name == questName)
                {
                    return quest;
                }
            }
            return null;
        }

Odd… you shouldn’t have had to add UnityEngine.Resources… is it possible that there is something in your usings clauses that includes a Resources other than UnityEngine?

To satisfy my curiosity, can you post your usings clauses for Quest.cs?

Sure

using System;
using System.Collections;
using System.Collections.Generic;
using GameDevTV.Inventories;
using UnityEngine;

namespace RPG.Quests
{
    [CreateAssetMenu(fileName = "Quest", menuName = "RPG Project/Quest", order = 0)]
    public class Quest : ScriptableObject {
        //TODO currently by design we are using the filename that was created; as the name property
        //Check later
        [SerializeField] List<Objective> objectives = new List<Objective>();
        [SerializeField] List<Reward> rewards = new List<Reward>();

        [System.Serializable]
        public class Reward
        {
            [Min(1)]
            public int number;
            public InventoryItem item;
        }

        [System.Serializable]
        public class Objective
        {
            public string reference;
            public string description;
        }
        public string GetTitle()
        {
            return name;
        }

        public int GetObjectiveCount()
        {
            return objectives.Count;
        }

        public IEnumerable<Objective> GetObjectives()
        {
            return objectives;
        }
        public IEnumerable<Reward> GetRewards()
        {
            return rewards;
        }

        public bool HasObjective(string objectiveRef)
        {
            foreach (var objective in objectives)
            {
                if(objective.reference == objectiveRef)
                {
                    return true;
                }
            }
            return false;
        }

        public static Quest GetByName(string questName)
        {
            foreach (Quest quest in UnityEngine.Resources.LoadAll<Quest>(""))
            {
                if(quest.name == questName)
                {
                    return quest;
                }
            }
            return null;
        }
    }
}


Hmmm… VSCode should have picked up that you were using UnityEngine; and avoided the unneccesary UnityEngine qualifier. None of those using clauses contain a conflicting Resources definition. (If you were to have something like float x = Random.Range(0,100); you would need to qualify it because System contains a Random class as well as UnityEngine, but as it should be unneccessary for Resources.

I’m assuming that Unity doesn’t complain if you don’t qualify Resources with UnityEngine? In any case, it doesn’t actually hurt anything to add it, it’s just redundant.

Another, little thing about unity…

I hope to develop a things to do list for the designer.
any ideas?

We have a lot of triggers in this project and being a newbie, a list for the designer would help a lot. Not to mention my future self lol

Thanks

Privacy & Terms