I’m trying to save some build data (path to assetbundles, build version etc) in the pre-export method. So I can use them in runtime.
I’ve tried static variables in a static class and scriptable objects placed in resources (also calling assetdatabase.refresh) but after building and running the game the data is reset to the default values.
Does someone know how to do this?
(I can’t use playersettings)
Can you share the code that you’re using for this ? using scriptable objects in resources should probably work.
Ok, this is my code. I simplified it so it’s more clear what I’m doing.
public class CommandBuildConfig : ScriptableObject
{
public string MyBuildInfo= "";
private static CommandBuildConfig _instance;
public static CommandBuildConfig Instance
{
get
{
if (!_instance)
{
_instance = Resources.FindObjectsOfTypeAll<CommandBuildConfig>().SingleOrDefault();
}
if (!_instance)
{
_instance = CreateInstance<CommandBuildConfig>();
_instance.hideFlags = HideFlags.HideAndDontSave;
}
return _instance;
}
}
}
public class BuilderClass
{
public static void SetBuildSettings(UnityEngine.CloudBuild.BuildManifestObject manifest)
{
CommandBuildConfig.Instance.MyBuildInfo= manifest.GetValue<string>("buildNumber");
}
}
When I do this in runtime:
Debug.Log("MyBuildInfo = " + CommandBuildConfig.Instance.MyBuildInfo);
MyBuildInfo is an empty string.
I hope this makes it more clear
You are creating an instance of the ScriptableObject during the build process, but this instance is never saved back as an asset, so it will not be packed into your build and you won’t be able to retrieve the data.