Comparing version 1.0.16 to 1.0.17
@@ -51,4 +51,4 @@ | ||
unityInstance.parentNode = parentNode; | ||
db.cacheFile(param.host + "library").then((library) => { | ||
AB3D.interface = new Interface(unityInstance, db,library, param.succeed); | ||
db.cacheFile(param.host + "library").then((library) => { | ||
AB3D.interface = new Interface(unityInstance, db, library, param.succeed); | ||
unityInstance.Invoke = function (prama, register) { | ||
@@ -74,3 +74,3 @@ if (register) { | ||
} | ||
} | ||
} | ||
}) | ||
@@ -83,5 +83,5 @@ }).catch((message) => { | ||
}); | ||
} | ||
} | ||
function development() { | ||
@@ -101,25 +101,28 @@ script.setAttribute('src', 'http://192.168.1.111/unity/resource/AB3DEngine.loader.js'); | ||
// devicePixelRatio: 1, // 取消注释将覆盖在高DPI显示上的低DPI渲染。 | ||
}, (progress) => { | ||
console.log(100 * progress + "%") | ||
}).then((unityInstance) => { | ||
unityInstance.parentNode = parentNode; | ||
AB3D.interface = new Interface(unityInstance, db, param.host, param.succeed); | ||
unityInstance.Invoke = function (prama, register) { | ||
if (register) { | ||
for (const re of register) { | ||
Event.addEvent(re.code, re.callBack); | ||
} | ||
} | ||
unityInstance.SendMessage("Interface", "Reflect", JSON.stringify(prama)); | ||
} | ||
unityInstance.Untie = function (register) { | ||
for (const re of register) { | ||
Event.removeEvent(re.code, re.callBack); | ||
} | ||
} | ||
unityInstance.Register = function (register) { | ||
if (register) { | ||
for (const re of register) { | ||
Event.addEvent(re.code, re.callBack); | ||
} | ||
} | ||
} | ||
AB3D.interface = new Interface(unityInstance, param); | ||
// unityInstance.Invoke = function (prama, register) { | ||
// if (register) { | ||
// for (const re of register) { | ||
// Event.addEvent(re.code, re.callBack); | ||
// } | ||
// } | ||
// unityInstance.SendMessage("Interface", "Reflect", JSON.stringify(prama)); | ||
// } | ||
// unityInstance.Untie = function (register) { | ||
// for (const re of register) { | ||
// Event.removeEvent(re.code, re.callBack); | ||
// } | ||
// } | ||
// unityInstance.Register = function (register) { | ||
// if (register) { | ||
// for (const re of register) { | ||
// Event.addEvent(re.code, re.callBack); | ||
// } | ||
// } | ||
// } | ||
}).catch((message) => { | ||
@@ -149,3 +152,3 @@ alert(message); | ||
var db = new IndexDBCache(); | ||
AB3D.interface = new Interface(unityInstance, db,param.host, param.succeed); | ||
AB3D.interface = new Interface(unityInstance, db, param.host, param.succeed); | ||
unityInstance.Invoke = function (prama, register) { | ||
@@ -152,0 +155,0 @@ if (register) { |
@@ -1,4 +0,2 @@ | ||
import Load from "./Module/Load.js"; | ||
import Event from "./System/Event.js"; | ||
import Decorate from "./Module/Decorate.js"; | ||
window.ReportReady = function (obj) { | ||
@@ -18,22 +16,89 @@ var parma = JSON.parse(obj); | ||
event;//事件中心 | ||
loadModule;//加载模块 | ||
decorate;//装饰模块 | ||
constructor(unityInstance, db, host, callback) { | ||
unityInstance; | ||
constructor(_unityInstance, pr) { | ||
let that = this; | ||
that.unityInstance = _unityInstance; | ||
that.event = Event; | ||
that.loadModule = new Load(unityInstance); | ||
that.decorate = new Decorate(unityInstance); | ||
var unityBack; | ||
var parentNode = document.getElementById(pr.domid); | ||
var inputFile = document.createElement("input"); | ||
inputFile.type = "file"; | ||
inputFile.style.width = 0 + "px"; | ||
inputFile.onchange = onFileSelected; | ||
parentNode.appendChild(inputFile); | ||
var inputField = document.createElement("input"); | ||
inputField.type = "text"; | ||
inputField.style = 'position: absolute;'; | ||
inputField.addEventListener("input", function (event) { | ||
console.log("输入的内容:", event.target.value); | ||
var datapr = { | ||
instanceID: unityBack.instanceID, | ||
text: event.target.value | ||
} | ||
_unityInstance.SendMessage(unityBack.gameObjectName, unityBack.callBackName, JSON.stringify(datapr)); | ||
// 在这里添加你想要执行的其他操作 | ||
}); | ||
parentNode.appendChild(inputField); | ||
var param = { | ||
host: host | ||
assetsUrl: pr.assetsUrl, | ||
severUrl: pr.severUrl | ||
} | ||
unityInstance.SendMessage("Interface", "Init", JSON.stringify(param)) | ||
Event.addEvent(100001, (backstr) => { | ||
console.log(backstr); | ||
if (callback) callback(that); | ||
if (pr.succeed) pr.succeed(that); | ||
}); | ||
Event.addEvent(100002, (backstr) => { | ||
console.log(backstr); | ||
if (callback) callback(that); | ||
_unityInstance.SendMessage("Interface", "Init", JSON.stringify(param)) | ||
Event.addEvent(200001, (str) => { | ||
inputFile.click(); | ||
unityBack = str; | ||
}); | ||
Event.addEvent(300001, (str) => { | ||
// inputField.click(); | ||
inputField.focus(); | ||
unityBack = str; | ||
inputField.value = str.text; | ||
inputField.selectionStart = str.index; | ||
inputField.selectionEnd = str.index; | ||
}); | ||
function onFileSelected(event) { | ||
var file = event.target.files[0]; | ||
var now = new Date(); | ||
var year = now.getFullYear(); | ||
var month = now.getMonth() + 1; | ||
var date = now.getDate(); | ||
var formData = new FormData(); | ||
formData.append('file', file); | ||
formData.append("filePath", "intelligent_coach/image/" + year + "/" + month + "/" + date + "/" + Math.floor(Date.now() / 1000)); | ||
// 使用 fetch 上传文件 | ||
fetch(pr.severUrl + '/api/thirdparty/oss/uploadFileApp', { // 替换成你的服务器URL | ||
method: 'POST', | ||
body: formData, | ||
}) | ||
.then(response => response.json()) | ||
.then(data => { | ||
console.log('Success:', data); | ||
var datapr = { | ||
instanceID: unityBack.instanceID, | ||
url: data.message | ||
} | ||
_unityInstance.SendMessage(unityBack.gameObjectName, unityBack.callBackName, JSON.stringify(datapr)); | ||
// 可以在这里处理上传成功后的逻辑,例如显示上传成功的提示 | ||
}) | ||
.catch(error => { | ||
console.error('Error:', error); | ||
// 可以在这里处理上传失败的逻辑,例如显示上传失败的提示 | ||
}); | ||
} | ||
function onInputText(event) { | ||
} | ||
} | ||
loadModel(modelid) { | ||
this.unityInstance.SendMessage("Interface", "Load", modelid); | ||
} | ||
} | ||
@@ -40,0 +105,0 @@ |
{ | ||
"name": "abengine", | ||
"version": "1.0.16", | ||
"version": "1.0.17", | ||
"description": "引入 npm i ABengine", | ||
@@ -5,0 +5,0 @@ "main": "ab3d.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
129613
795
4