ialex32x / unity-jsb

It brings Javascript runtime capability to Unity3D by integrating QuickJS.
MIT License
335 stars 41 forks source link

UNITY_EDITOR conflicting with binding #96

Closed FreakTheMighty closed 1 year ago

FreakTheMighty commented 1 year ago

With jsb.Editor.UnityBinding enabled, the generated bindings produce

        public static ClassDecl Bind(TypeRegister register)
        {
            var cls = register.CreateClass("ScriptableObject", typeof(UnityEngine.ScriptableObject), QuickJS.Binding.CommonFix.CrossBindConstructor);
            cls.AddMethod(true, "CreateInstance", QuickJS.Unity.ScriptableObjectFix.BindStatic_CreateInstance);
            return cls;
        }

However, this method ScriptableObjectFix.BindStatic_CreateInstance, is wrapped inside of a #if UNITY_EDITOR, so it fails on build.

Am I missing something? Is there a way to indicate that the bindings for editor only methods should be skipped or wrapped in their own directives?

ialex32x commented 1 year ago

ScriptableObjectFix.BindStatic_CreateInstance should be available even if UNITY_EDITOR is not defined. @FreakTheMighty Thanks a lot.