Hello,
when I try to run my build on Android 11 I get these error-messages in the Unity-console:
AndroidPlayer(samsung_SM-A515F@192.168.178.22) ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
at System.ThrowHelper.ThrowArgumentOutOfRangeException (System.ExceptionArgument argument, System.ExceptionResource resource) [0x00029] in <a1e9f114a6e64f4eacb529fc802ec93d>:0
at System.ThrowHelper.ThrowArgumentOutOfRangeException () [0x00000] in <a1e9f114a6e64f4eacb529fc802ec93d>:0
at System.Collections.Generic.List`1[T].get_Item (System.Int32 index) [0x00009] in <a1e9f114a6e64f4eacb529fc802ec93d>:0
at Stem.SoundBank.get_DefaultBus () [0x00001] in /Volumes/Work/Developer/Dev_Unity3D/game_development/projects/com/***/Dev_SpaceShooter/Assets/Stem/Scripts/Persistent/SoundBank.cs:268
at Stem.SoundBank.AddSound (System.String name, UnityEngine.AudioClip clip) [0x00009] in /Volumes/Work/Developer/Dev_Unity3D/game_development/projects/com/***/Dev_SpaceShooter/Assets/Stem/Scripts/Persistent/SoundBank.cs:421
at InitSFX.Start () [0x00038] in /Volumes/Work/Developer/Dev_Unity3D/game_development/projects/com/***/Dev_SpaceShooter/Assets/Scripts/InitSFX.cs:59
(Filename: /Volumes/Work/Developer/Dev_Unity3D/game_development/projects/com/***/Dev_SpaceShooter/Assets/Scripts/InitSFX.cs Line: 59)
This is the script (line 59, InitSFX.cs) where the error appears:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Stem;
public class InitSFX : MonoBehaviour
{
public static InitSFX instance;
[Tooltip("Player-Sounds")]
[SerializeField]
private AudioClip playerShot;
[Tooltip("Enemy explosion-sounds")]
[SerializeField]
private AudioClip[] enemyExplosionSnds;
public static InitSFX Instance
{
get { return instance; }
}
void Awake() {
if (instance != null) {
Destroy(this.gameObject);
} else {
instance = this;
DontDestroyOnLoad(this.gameObject);
}
if (SFXManager._instance == null) {
Debug.Log("No valid SFX-Manager instance found!");
SFXManager.GetInstance();
}
}
// Start is called before the first frame update
void Start()
{
//player-sounds
Stem.Sound shoot = SFXManager.sfxBank.AddSound("PlayerShot", playerShot);
}
}
There is another error appearing in the script SFXManager.cs:
AndroidPlayer(samsung_SM-A515F@192.168.178.22) A scripted object (script unknown or not yet loaded) has a different serialization layout when loading. (Read 56 bytes but expected 76 bytes)
Did you #ifdef UNITY_EDITOR a section of your serialized properties in any of your scripts?
UnityEngine.StackTraceUtility:ExtractStackTrace () (at /Users/bokken/buildslave/unity/build/Runtime/Export/Scripting/StackTrace.cs:37)
UnityEngine.ResourcesAPI:Load (string,System.Type) (at /Users/bokken/buildslave/unity/build/Runtime/Export/Resources/Resources.bindings.cs:66)
UnityEngine.Resources:Load (string,System.Type) (at /Users/bokken/buildslave/unity/build/Runtime/Export/Resources/Resources.bindings.cs:117)
UnityEngine.Resources:Load<UI.Xml.XmlLayoutResourceDatabase> (string) (at /Users/bokken/buildslave/unity/build/Runtime/Export/Resources/Resources.bindings.cs:112)
UI.Xml.XmlLayoutResourceDatabase:get_instance () (at /Volumes/Work/Developer/Dev_Unity3D/game_development/projects/com/***/Dev_SpaceShooter/Assets/UI/XmlLayout/ResourceDatabase/XmlLayoutResourceDatabase.cs:20)
UI.Xml.XmlLayoutUtilities:LoadResource<UnityEngine.GameObject> (string,bool) (at /Volumes/Work/Developer/Dev_Unity3D/game_development/projects/com/***/Dev_SpaceShooter/Assets/UI/XmlLayout/XmlLayoutUtilities.cs:329)
UI.Xml.XmlLayoutPreloader:Preload_Internal () (at /Volumes/Work/Developer/Dev_Unity3D/game_development/projects/com/***/Dev_SpaceShooter/Assets/UI/XmlLayout/XmlLayoutPreloader.cs:30)
UI.Xml.XmlLayoutPreloader:Preload () (at /Volumes/Work/Developer/Dev_Unity3D/game_development/projects/com/***/Dev_SpaceShooter/Assets/UI/XmlLayout/XmlLayoutPreloader.cs:14)
UI.Xml.XmlLayout:HandlePreload () (at /Volumes/Work/Developer/Dev_Unity3D/game_development/projects/com/***/Dev_SpaceShooter/Assets/UI/XmlLayout/XmlLayout.cs:1182)
UI.Xml.XmlLayout:Awake () (at /Volumes/Work/Developer/Dev_Unity3D/game_development/projects/com/***/Dev_SpaceShooter/Assets/UI/XmlLayout/XmlLayout.cs:162)
[/Volumes/Work/Developer/Dev_Unity3D/game_development/projects/com/***/Dev_SpaceShooter/Assets/UI/XmlLayout/XmlLayoutPreloader.cs line 30]
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
using Stem;
public class SFXManager : MonoBehaviour
{
public static SFXManager _instance;
public static Stem.SoundBank sfxBank;
private static Stem.SoundInstance soundInstance = null;
private static bool onDestroyActive = false;
public static SFXManager GetInstance() {
if (!_instance) {
sfxBank = ScriptableObject.CreateInstance<Stem.SoundBank>();
sfxBank.name = "SFXBank";
sfxBank.SoundManagementMode = AudioClipManagementMode.Manual;
#if UNITY_EDITOR
if (!AssetDatabase.Contains(sfxBank)) AssetDatabase.CreateAsset(sfxBank, "Assets/Resources/Sound/SFXBank.asset");
#endif
if (Stem.SoundManager.RegisterBank(sfxBank))
{
Stem.SoundManager.PrimaryBank = sfxBank;
}
GameObject sfxManager = new GameObject("SFXManager");
_instance = sfxManager.AddComponent<SFXManager>();
_instance.Initialize();
}
return _instance;
}
}
I think the problem is the #if-part of the script above. Is there a workaround available when I try to build my game?