Skip to content

when running it on a HarmonyOS phone, the C# script fails to load #4

@haknhjciw

Description

@haknhjciw

Tested versions

https://github.com/kdada/godot
branch:openharmony

System information

Windows 11 -Godot v4.4.1 -Vulkan(Forward+)-GeForce 5070

Issue description

Hello! I followed the configuration steps in the "Additional Work Required to Support C# Scripts" section of your documentation, and here's my C# script for the Godot engine:

using Godot;
using System;

public partial class Main : Node2D
{
private Label _label;
public override void _Ready()
{
GD.Print("C# Script Running on HarmonyOS!");

    _label = new Label();
    _label.Text = "C# Script Ran Successfully";
    _label.AddThemeFontSizeOverride("font_size", 32);
    _label.AddThemeColorOverride("font_color", Colors.Yellow);
    _label.Position = new Vector2(800, 350);
    AddChild(_label);
}

}
I used the community-provided OpenHarmony .NET runtime and exported the HarmonyOS project. However, when running it on a HarmonyOS phone, the C# script fails to load. The error message is:

ERROR: Condition "native_name == StringName()" is true. Returning: nullptr
at: instance_create (modules\mono\csharp_script.cpp:2461)
Through debugging, I confirmed that GDMono::initialize() completes successfully, and the message ".NET: GodotPlugins initialized" is printed. Do you have any idea what might be causing this issue? Thank you!

Additionally, could you please let me know where the repository/address of the above demo in mp4 is? I'd like to give it a try.

Steps to reproduce

Export the HarmonyOS project and run it on a mobile phone. The C# script execution failed because the native_name is empty in CSharpScript::instance_create().

Minimal reproduction project (MRP)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions