hippogamesunity / HeroEditorHub

Support for Hero Editor assets
18 stars 0 forks source link

Bug, with firearms script and build #183

Closed idmarinas closed 1 year ago

idmarinas commented 1 year ago

Hi:

I get this error, when build my game.

The referenced script on this Behaviour (Game Object '<null>') is missing!
UnityEngine.StackTraceUtility:ExtractStackTrace () (at C:/build/output/unity/unity/Runtime/Export/Scripting/StackTrace.cs:37)
UnityEngine.ResourcesAPI:LoadAll (string,System.Type) (at C:/build/output/unity/unity/Runtime/Export/Resources/Resources.bindings.cs:72)
UnityEngine.Resources:LoadAll (string,System.Type) (at C:/build/output/unity/unity/Runtime/Export/Resources/Resources.bindings.cs:143)
UnityEngine.Resources:LoadAll<Assets.HeroEditor.Common.Scripts.Collections.FirearmCollection> (string) (at C:/build/output/unity/unity/Runtime/Export/Resources/Resources.bindings.cs:155)
Assets.HeroEditor.Common.Scripts.Collections.FirearmCollection:Initialize () (at D:/Users/idmarinas/Documents/Proyectos Unity/Draconia Idle - Terra automata/Assets/Plugins/HeroEditor/Common/Scripts/Collections/FirearmCollection.cs:23)

I cant find error, scriptableobject have attached the script.

hippogamesunity commented 1 year ago

Hello! Validate your project for broken/missed references. You can try building the asset separately in a new project to make sure if it works.

idmarinas commented 1 year ago

How can I do that?

hippogamesunity commented 1 year ago

Find it manually https://stackoverflow.com/questions/54969972/unity-the-referenced-script-unknown-on-this-behaviour-is-missing

idmarinas commented 1 year ago

Everything OK, no errors found, except in some HeroEditor prefabs.

hippogamesunity commented 1 year ago

Does the error happen with a new project + the latest asset version?

idmarinas commented 1 year ago

Yes, I fixed it by changing Instances = Resources.LoadAll<FirearmCollection>("").ToDictionary(i => i.Id, i => i); to Instances = Resources.LoadAll<FirearmCollection>("Resources").ToDictionary(i => i.Id, i => i);

hippogamesunity commented 1 year ago

This is weird. "When using the empty string (i.e., ""), the function will load the entire contents of the Resources folder." https://docs.unity3d.com/ScriptReference/Resources.LoadAll.html

At the same time, I can confirm that the latest version works fine for Windows and Android builds. For me and other users. "Build completed with a result of 'Succeeded' in 188 seconds (187747 ms)"

idmarinas commented 1 year ago

Yes, it build correctly for me too, but when I run the game in dev mode, I get the error in the console.

hippogamesunity commented 1 year ago

As I said, the asset doesn't contain missed references and was passed a review. Check your projects' files.