2017-12-19 2 views
0

Unity WebGL에는 jslib에서 javascript 함수를 호출하는 메서드가 있지만 firebase를 사용하기 위해 이러한 함수 호출을 node.js에 통합해야합니다. 내가 할 노력은 무엇Unity3D를 통해 node.js에서 javascript 함수를 호출합니까?

은 다음과 같다 :

유니티 내부 내가 지금과 같은 외부 호출하려고 노력에서 그런
// entry.js: 
require("./style.css"); 
document.write(require("./content.js")); 

require('./UnityLoader.js'); 

var firebase = require('firebase'); 

function foo() { 
    window.alert("ENTRY HELLOW WORLD"); 
} 


wvar gameInstance = UnityLoader.instantiate("gameContainer", "Build/WebGLNodeContainer.json"); 
document.write('<div id="gameContainer" style="width: 960px; height: 600px; margin: auto"></div>'); 

:

public class FirebaseWebGL : IFirebaseLib 
    { 
     [DllImport("__Internal")] 
     private static extern void foo(); 

     public void Login(string username, string password) 
     { 
       foo(); 
     } 
    } 

나는이 'didn를 너무 놀라지 아니에요을 그 중 Unity's docs claim you can call javascript in your webpage 지침은 node.js/webpack과 잘 작동하지 않는 유니티 프로젝트에 자바 스크립트 파일로 패키징하는 것과 관련이 있습니다.

이 방법이 있습니까? 필자의 주요 목표는 firebase 로그인을 유도하고 인증 토큰을 가져 오는 것입니다.

답변

1

Node.JS 서버로 C# 또는 js 함수의 AJAX 호출을 통해 HTTP 요청을 보내야합니다.

노드 자체가 게임/경험을 호스트하는 서버가 아닌 별도의 서버이기 때문에 직접 Node.js 함수를 호출 할 수 없습니다.

관련 문제