- Home /
Resource.LoadAll Not Working On Child Assets In Stand Alone Build
I'm attempting to make a quest/objective system using ScriptableObjects and it's working in the Unity Editor but not in a build. I have a Quest object that I create than give it objectives and rewards, which the quest object keeps reference to in two seperate lists. These objectives and rewards are also scriptable objects and are childed to the quest object when they're made.
Now the problem. I have a QuestBoard object which has a list of quests that it can give to the player. When the player attempts to get a quest, it works in the Unity Editor, but not in a stand alone build.
From debugging build I've found that the Quests that the QuestBoard has a list for, have empty lists for their rewards and objectives, yet they still contain their proper names(string). So I believe it's finding the quest asset but not the children. But I'm confused why the editor can use the same code and get all the assets.
Here's how I'm trying to load the quests from the 'Resource/Quest' folder, 'Resource/Quest' is included in the passed in string
public static Quest LoadQuest(string questPath)
{
Object[] assets = Resources.LoadAll(questPath) as Object[]; //assets.length = 1 (In build) //so it's only loading the quest asset, no reward/objective children
Quest quest = CreateInstance<Quest>();
List<QuestReward> rewards = new List<QuestReward>();
List<QuestObjective> objectives = new List<QuestObjective>();
foreach (Object asset in assets)
{
if (asset is QuestObjective)
{
objectives.Add(asset as QuestObjective);
}
else if (asset is QuestReward)
{
rewards.Add(asset as QuestReward);
}
else if (asset is Quest)
{
quest = asset as Quest; //Get the quest
}
}
quest.objectives = objectives; //Add objectives to quest
quest.rewards = rewards; //Add rewards to quest
return quest;
}
Would the children assets be excluded from the build because the list of quest references containing references to the objectives/rewards isn't enough? Any help, suggestions for a fix or alternative method would be greatly appreciated.
The correct path string is probably different from Editor and Stand Alone Build. $$anonymous$$aybe this helps: https://docs.unity3d.com/ScriptReference/Application-dataPath.html