Is it possible to add new Characters at runtime via Addressables?
Posted: 04 May 2021 08:57
by bob_newbie
Hi,
I would like to ask if it is possible to add a Character at runtime through Addressables without registering/adding it in Naninovel Configuration editor? A use case example is I released a basic apk today, after a month I would like to add new characters to my application without republishing the apk again.
In case if its possible, any documentations or guides that I can look on?
Thanks!
Re: Is it possible to add new Characters at runtime via Addressables?
Posted: 04 May 2021 11:15
by Elringus
It's possible, but will either require creating a custom character implementation (https://naninovel.com/guide/custom-acto ... mentations), which doesn't depend on configs or a custom config provider (https://naninovel.com/guide/custom-conf ... n-provider), which will pull the configs from a custom source (eg, an addressable asset).
Re: Is it possible to add new Characters at runtime via Addressables?
Posted: 05 May 2021 12:43
by Sarami
Hi
That was my question too. thanks.
I wanted to make an episodic game.
Can we do this for in game text too? the text inside nani-script.
which includes both dialogues and scripts.
like save it inside a text file and download it for each episode. from a server.
Re: Is it possible to add new Characters at runtime via Addressables?
Posted: 05 May 2021 14:14
by Elringus
Sure, that's possible with addressables without any programming.
Re: Is it possible to add new Characters at runtime via Addressables?
Posted: 17 May 2021 07:14
by bob_newbie
Hi,
I downloaded the Naninovel/Live2D, I am getting a bunch of errors. My naninovel version is v1.14b build 2020-11-09. Does this require the latest version?
Thanks!
Re: Is it possible to add new Characters at runtime via Addressables?
Posted: 17 May 2021 10:38
by Elringus
It does require the latest version.
Re: Is it possible to add new Characters at runtime via Addressables?
Posted: 19 May 2021 06:44
by bob_newbie
Hi,
We tried updating to the latest Naninovel version but it will break many things on our current code. So there is no way for us to add characters, backgrounds, audio at runtime without using the Editor via addressables using v1.14?
Thanks!
Re: Is it possible to add new Characters at runtime via Addressables?
Posted: 19 May 2021 10:27
by Elringus
bob_newbie wrote: ↑17 May 2021 07:14
I downloaded the Naninovel/Live2D, I am getting a bunch of errors. My naninovel version is v1.14b build 2020-11-09. Does this require the latest version?
This was about Live2D, wasn't it? You can use addressables with any Naninovel version, though please be aware that we won't be able to provide support for previous versions of the engine.
Re: Is it possible to add new Characters at runtime via Addressables?
Posted: 20 May 2021 03:52
by bob_newbie
Hi,
Sorry this is not about Live2D. What we want to achieve is adding backgrounds, audio, and characters via addressables. Yes we know we can access these assets via addressable and c#, but we cannot use them and call them in nani script... apparently we need to add these in the Editor manually before we can use them. So my question is, can we add these assets in the Naninovel engine dynamically through code? We are using stories/ books which is saved as nani scripts. However as the user progresses, it would be nice if we can add assets at runtime without using the Nani editor, this way we can avoid releasing apk or ipa updates.
It would be so heavy for the application to include all assets in a build, so a staggered approach in loading these assets as the user progresses the game would be the way to go. Unfortunately we do not know how to use these assets (which were not added in the Naninovel Editor) and integrate it in Naninovel at runtime.
Hope this clarifies my question. So is this doable with the curernt Nani version we have - v1.14b?
Re: Is it possible to add new Characters at runtime via Addressables?
Posted: 20 May 2021 04:03
by bob_newbie
Or I guess can we use an asset and call it in a nani script that is not pre-assigned in the Nani editor?
Re: Is it possible to add new Characters at runtime via Addressables?
Posted: 20 May 2021 11:32
by Elringus
Both loading resources from external sources and adding actors at runtime are possible; see my answers above: viewtopic.php?p=728#p728 and viewtopic.php?p=731#p731
Re: Is it possible to add new Characters at runtime via Addressables?
Posted: 06 Jun 2021 08:49
by Sarami
Elringus wrote: ↑05 May 2021 14:14
Sure, that's possible with addressables without any programming.
Hi again.
for using addressables:
I should install the package
Mark everything as addressable ( if something was missing in the group )
I shouldn't forget about the Naninovel label.
I should put external assets that work with naninovel in " Naninovel/ "
taking care of the providers.
And everything else will do its job?
( like I don't have to write code for loading them. I should just play with the editor. unless I want to do something fancy with unity. )
Re: Is it possible to add new Characters at runtime via Addressables?
Posted: 06 Jun 2021 11:17
by Elringus
That is only the case if you want to use custom addressable groups or don't want to use resource editor menus. Otherwise, Naninovel will create the groups and apply the addresses and labels automatically, so you just need to install the addressable package and Naninovel will handle the rest.
Re: Is it possible to add new Characters at runtime via Addressables?
Posted: 02 Nov 2022 12:24
by Elringus
Here is a quick example on how custom character metadata can be injected at runtime.
Code: Select all
public class CustomConfigurationProvider : ProjectConfigurationProvider
{
public override Configuration GetConfiguration (System.Type type)
{
// Return project configs as-is for everything but characters.
if (type != typeof(CharactersConfiguration))
return base.GetConfiguration(type);
// Inject (or override) metadata of the characters.
// The actual data can be retrieved via external sources at runtime.
var charsConfig = (CharactersConfiguration)base.GetConfiguration(type);
charsConfig.Metadata["NewCustomChar"] = new CharacterMetadata {
Implementation = typeof(NarratorCharacter).AssemblyQualifiedName,
DisplayName = "Custom Narrator",
UseCharacterColor = true,
MessageColor = Color.cyan,
// etc...
};
// Return our modified characters config.
return charsConfig;
}
}
public class CustomInitializer
{
// Initializing Naninovel with our custom configuration provider.
// Don't forget to disable automatic initialization in the engine config.
[RuntimeInitializeOnLoadMethod]
private static void InitializeWithCustomProvider ()
{
var customProvider = new CustomConfigurationProvider();
RuntimeInitializer.InitializeAsync(customProvider).Forget();
}
}