|
Post by Illusion Walk on Jan 13, 2021 10:46:01 GMT
Hi,
I have some trouble with MasterAudioSettings.cs which has UNITY_EDITOR defines around the full class but is not in an editor folder.
This can cause a "script not found" warning in build because the script does not exist, but its scriptable object exists in the resources folder (even in the build). This happens for example when calling Resources.LoadAll(string.Empty) which another asset package tries to do.
It would be very helpful to either remove the editor settings from the resources folder or simply to provide a more or less empty MasterAudioSettings.cs but at least with its class definition.
Thanks!
|
|
DarkTonic Dev
Administrator
Posts: 4,386
Posts: 4,386
Member is Online
|
Post by DarkTonic Dev on Jan 13, 2021 16:27:47 GMT
I will see if I can move it to Editor folder, that seems weird. Thanks!
|
|
DarkTonic Dev
Administrator
Posts: 4,386
Posts: 4,386
Member is Online
|
Post by DarkTonic Dev on Jan 13, 2021 22:56:13 GMT
I tried to move it and it's not going to be possible. Some of the references to that are in the Editor folder, but also some non-Editor code needs to access that, and it's not possible if I were to move it into the Editor assembly.
I think your other plugin should not be loading EVERYTHING, so you'll need to find a way to exclude this file. What's the error exactly? Do you have something to copy/paste from the Console?
Unless you know how to do any of those other suggestions you had.
-B
|
|
|
Post by Illusion Walk on Jan 14, 2021 9:52:15 GMT
Hi,
here is my console output:
The referenced script (DarkTonic.MasterAudio.MasterAudioSettings) on this Behaviour is missing! (Filename: Line: 199)
The referenced script on this Behaviour (Game Object '<null>') is missing! (Filename: Line: 334)
A scripted object (probably DarkTonic.MasterAudio.MasterAudioSettings?) has a different serialization layout when loading. (Read 52 bytes but expected 152 bytes) Did you #ifdef UNITY_EDITOR a section of your serialized properties in any of your scripts? UnityEngine.Resources:LoadAll(String) TriLibCore.TriLibSettings:GetTriLibPreferences()... I know that it might be difficult to move it to an Editor folder.
Because of that I removed the UNITY_EDITOR defines from the MasterAudioSettings.cs.
In addition, I had to change slightly the BRT_Options.cs as follows:
//#if UNITY_EDITOR // <== REMOVED THIS UNITY_EDITOR DEFINE /*! \cond PRIVATE */ using UnityEngine; using UnityEditor; using System.Collections.Generic; using System.IO; namespace DarkTonic.MasterAudio { public abstract class SingletonScriptable<InstanceType> : ScriptableObject where InstanceType : ScriptableObject { protected static string AssetNameToLoad; protected static string ResourceNameToLoad; protected static List<string> FoldersToCreate = new List<string>(); #if UNITY_EDITOR // <== ADDED THE UNITY_EDITOR DEFINE HERE And at the end:
#endif // <== ADDED HERE } } /*! \endcond */ //#endif // <== REMOVED
This works for me.
Maybe it is possible to change it like this?
Thanks!
|
|
DarkTonic Dev
Administrator
Posts: 4,386
Posts: 4,386
Member is Online
|
Post by DarkTonic Dev on Jan 14, 2021 16:47:27 GMT
I assume BRT_Options.cs is the other problem asset you are talking about that's loading everything?
Now if I remove #if UNITY_EDITOR from MasterAudioSettings.cs, I cannot export a Windows standalone build because SingletonScriptable only compiles in Editor.
How about adding this? Does it work for you?
#if UNITY_EDITOR
/*! \cond PRIVATE */ namespace DarkTonic.MasterAudio { public class MasterAudioSettings : SingletonScriptable<MasterAudioSettings> { public const string AssetName = "MasterAudioSettings.asset"; public const string AssetFolder = "Assets/Resources/MasterAudio"; public const string ResourcePath = "MasterAudio/MasterAudioSettings";
public bool UseDbScale; public bool RemoveUnplayedDueToProbabilityVariation = true; public bool UseCentsPitch; public bool HideLogoNav; public bool EditMAFolder; public string InstallationFolderPath = MasterAudio.MasterAudioDefaultFolder; public MasterAudio.MixerWidthMode MixerWidthSetting = MasterAudio.MixerWidthMode.Narrow; public bool BusesShownInNarrow = true; public bool ShowWelcomeWindowOnStart = true;
static MasterAudioSettings() { AssetNameToLoad = string.Format("{0}/{1}", AssetFolder , AssetName); ResourceNameToLoad = ResourcePath; FoldersToCreate = new System.Collections.Generic.List<string> { "Assets/Resources", "Assets/Resources/MasterAudio" }; } } } /*! \endcond */ #else public class MasterAudioSettings { } #endif
Basically I added an empty version of MasterAudioSettings for non-editor in the "else".
|
|
|
Post by Illusion Walk on Jan 15, 2021 13:42:44 GMT
I will check it.
I changed SingletonScriptable.cs just to get it compiled (Sorry I wrote BRT_Options.cs instead of SingletonScriptable.cs). But with your solution that is no longer necessary.
Thanks!
|
|
DarkTonic Dev
Administrator
Posts: 4,386
Posts: 4,386
Member is Online
|
Post by DarkTonic Dev on Jan 15, 2021 16:24:22 GMT
Cool!
|
|
|
Post by Illusion Walk on Jan 19, 2021 16:52:06 GMT
Unfortunately the null object problem still exits in build.
But it works with the little changes from my previous post.
I removed the UNITY_EDITOR defines from the MasterAudioSettings.cs and changed the SingletonScriptable.cs as follows:
//#if UNITY_EDITOR // <<< REMOVED THIS UNITY_EDITOR DEFINE <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< /*! \cond PRIVATE */ using UnityEngine; using UnityEditor; using System.Collections.Generic; using System.IO; namespace DarkTonic.MasterAudio { public abstract class SingletonScriptable<InstanceType> : ScriptableObject where InstanceType : ScriptableObject { protected static string AssetNameToLoad; protected static string ResourceNameToLoad; protected static List<string> FoldersToCreate = new List<string>(); #if UNITY_EDITOR // <<< ADDED THE UNITY_EDITOR DEFINE HERE <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Is it possible to change it like that?
Thanks!
|
|
DarkTonic Dev
Administrator
Posts: 4,386
Posts: 4,386
Member is Online
|
Post by DarkTonic Dev on Jan 19, 2021 18:12:34 GMT
Thanks for the detective work! I fixed it as shown and it will be in the next update.
|
|
|
Post by Illusion Walk on Jan 20, 2021 8:39:11 GMT
Cool, thank you!
|
|
DarkTonic Dev
Administrator
Posts: 4,386
Posts: 4,386
Member is Online
|
Post by DarkTonic Dev on Jan 20, 2021 17:29:56 GMT
Any time.
|
|