Is it possible to add new Characters at runtime via Addressables?

Using Naninovel C# APIs: adding custom actor implementations or commands, overriding engine services, integrating with other systems, etc.
Post Reply
bob_newbie
Posts: 5
Joined: 04 May 2021 07:12

Is it possible to add new Characters at runtime via Addressables?

Post 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!

Elringus
admin
Posts: 521
Joined: 11 May 2020 18:03

Re: Is it possible to add new Characters at runtime via Addressables?

Post 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).

Sarami
Posts: 8
Joined: 21 Jan 2021 09:57

Re: Is it possible to add new Characters at runtime via Addressables?

Post by Sarami »

Elringus wrote: 04 May 2021 11:15

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).

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.

Elringus
admin
Posts: 521
Joined: 11 May 2020 18:03

Re: Is it possible to add new Characters at runtime via Addressables?

Post by Elringus »

Sure, that's possible with addressables without any programming.

bob_newbie
Posts: 5
Joined: 04 May 2021 07:12

Re: Is it possible to add new Characters at runtime via Addressables?

Post 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!

Elringus
admin
Posts: 521
Joined: 11 May 2020 18:03

Re: Is it possible to add new Characters at runtime via Addressables?

Post by Elringus »

It does require the latest version.

bob_newbie
Posts: 5
Joined: 04 May 2021 07:12

Re: Is it possible to add new Characters at runtime via Addressables?

Post 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!

Elringus
admin
Posts: 521
Joined: 11 May 2020 18:03

Re: Is it possible to add new Characters at runtime via Addressables?

Post 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.

bob_newbie
Posts: 5
Joined: 04 May 2021 07:12

Re: Is it possible to add new Characters at runtime via Addressables?

Post 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?

bob_newbie
Posts: 5
Joined: 04 May 2021 07:12

Re: Is it possible to add new Characters at runtime via Addressables?

Post 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?

Elringus
admin
Posts: 521
Joined: 11 May 2020 18:03

Re: Is it possible to add new Characters at runtime via Addressables?

Post 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

Sarami
Posts: 8
Joined: 21 Jan 2021 09:57

Re: Is it possible to add new Characters at runtime via Addressables?

Post 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. )

Elringus
admin
Posts: 521
Joined: 11 May 2020 18:03

Re: Is it possible to add new Characters at runtime via Addressables?

Post 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.

Elringus
admin
Posts: 521
Joined: 11 May 2020 18:03

Re: Is it possible to add new Characters at runtime via Addressables?

Post 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();
    }
}
Post Reply