Init
This commit is contained in:
57
Assets/WebGLTemplates/SGTemplate/js/audioProcess.js
Normal file
57
Assets/WebGLTemplates/SGTemplate/js/audioProcess.js
Normal file
@@ -0,0 +1,57 @@
|
||||
var adMain = document.querySelector("#adMain");
|
||||
var adAnother = document.querySelector("#adAnother");
|
||||
|
||||
// 播放第index展厅背景音乐
|
||||
function jsPlayBg(index) {
|
||||
|
||||
adMain.src = "StreamingAssets/Audios/ZT" + index + ".mp3";
|
||||
// adMain.play();
|
||||
|
||||
adMain.load();
|
||||
adMain.currentTime = 0;
|
||||
let playPromise = adMain.play();
|
||||
if (playPromise) {
|
||||
playPromise.then(() => {
|
||||
audio.play();
|
||||
}).catch(() => {
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 暂停背景音乐
|
||||
/// </summary>
|
||||
function jsPauseBackgroundMusic() {
|
||||
adMain.pause();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 恢复背景音乐
|
||||
/// </summary>
|
||||
function jsResumeBackgroundMusic() {
|
||||
adMain.play();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置背景音乐静音
|
||||
/// </summary>
|
||||
function jsSetBackgroundMute() {
|
||||
adMain.muted = !adMain.muted;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 播放音效(默认在摄像机位置播放)
|
||||
/// </summary>
|
||||
function jsPlayAudio(audioName) {
|
||||
adAnother.volume = 0.5;
|
||||
adAnother.src = "StreamingAssets/Audios/" + audioName + ".mp3";
|
||||
adAnother.play();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 停止音效
|
||||
/// </summary>
|
||||
function jsStopAudio() {
|
||||
adAnother.stop();
|
||||
}
|
||||
7
Assets/WebGLTemplates/SGTemplate/js/audioProcess.js.meta
Normal file
7
Assets/WebGLTemplates/SGTemplate/js/audioProcess.js.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7814f70edc992b84f98ad4915533daff
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
7
Assets/WebGLTemplates/SGTemplate/js/bootstrap.bundle.min.js
vendored
Normal file
7
Assets/WebGLTemplates/SGTemplate/js/bootstrap.bundle.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b4ea29eef320d4947946f9ffb3de0b0c
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
315
Assets/WebGLTemplates/SGTemplate/js/dataProcess.js
Normal file
315
Assets/WebGLTemplates/SGTemplate/js/dataProcess.js
Normal file
@@ -0,0 +1,315 @@
|
||||
/*
|
||||
* @description 是否显示测试用的FPS
|
||||
*/
|
||||
function jsIsShowFPS() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* @description 称判断是否为IOS浏览器
|
||||
*/
|
||||
function isIOSBrowser() {
|
||||
var UA = navigator.userAgent;
|
||||
if (UA.match(/iPad/) || UA.match(/iPhone/) || UA.match(/iPod/)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 加载视图(由Unity调用)
|
||||
* @param {string} data JSON格式数据
|
||||
* 对象格式 class DataInfo{ stirng ObjectID, int Type, string DataName, string[] DataDetails }
|
||||
*/
|
||||
function jsLoadView(data) {
|
||||
// 解析成对象
|
||||
let objData = JSON.parse(data);
|
||||
var dataType;
|
||||
switch (objData.Type) {
|
||||
case 0: dataType = "Video"; break;
|
||||
case 1: dataType = "Image"; break;
|
||||
case 2: dataType = "ImageText"; break;
|
||||
case 3: dataType = "ComicStrip"; break;
|
||||
case 4: dataType = "Game"; break;
|
||||
case 5: dataType = "Url"; break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
// 不同类型加载不同的HTML文件
|
||||
var url = dataType + ".html";
|
||||
|
||||
// 文件内容加载到divView
|
||||
var req = false;
|
||||
if (window.XMLHttpRequest) {// Safari, Firefox, 及其他非微软浏览器
|
||||
try {
|
||||
req = new XMLHttpRequest();
|
||||
} catch (e) {
|
||||
req = false;
|
||||
}
|
||||
} else if (window.ActiveXObject) {
|
||||
try {
|
||||
req = new ActiveXObject("Msxml2.XMLHTTP");// For Internet Explorer on Windows
|
||||
} catch (e) {
|
||||
try {
|
||||
req = new ActiveXObject("Microsoft.XMLHTTP");
|
||||
} catch (e) {
|
||||
req = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
var element = document.getElementById("divView");
|
||||
if (!element) {
|
||||
alert("无法找到id为" + id + "的div 或 span 标签。");
|
||||
return;
|
||||
}
|
||||
if (req) {
|
||||
req.open('GET', url, false); // 同步请求,等待收到全部内容
|
||||
req.send(null);
|
||||
element.innerHTML = req.responseText;
|
||||
// $("#divView").html(req.responseText);
|
||||
|
||||
// 自动加载并根据类型加载对应的资源进行显示
|
||||
if (dataType == "Video") {
|
||||
jsLoadVideo(objData);
|
||||
}
|
||||
else if (dataType == "Image") {
|
||||
jsLoadImage(objData);
|
||||
}
|
||||
else if (dataType == "Url") {
|
||||
jsLoadUrl(objData.DataName);
|
||||
}
|
||||
else if (dataType == "ComicStrip") {
|
||||
jsLoadComicStrip(objData.DataName);
|
||||
}
|
||||
else if (dataType == "ImageText") {
|
||||
// 测试写法,不代表最终写法。这里只传递一个参数,图文应该有图片和音频。
|
||||
jsLoadImageText(objData.DataName);
|
||||
}
|
||||
} else {
|
||||
element.innerHTML =
|
||||
"对不起,你的浏览器不支持" + "XMLHTTPRequest 对象。这个网页的显示要求" +
|
||||
"Internet Explorer 5 以上版本, " + "或 Firefox 或 Safari 浏览器,也可能会有其他可兼容的浏览器存在。";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 移动时关闭弹窗并清空divView内容
|
||||
*/
|
||||
function jsHideView() {
|
||||
$('#modal').addClass('center-modal');
|
||||
$('#modal').removeClass('maxmize-modal');
|
||||
modal.style.display = "none";
|
||||
//$('#modal').fadeOut(); // 会有标题在
|
||||
|
||||
var element = document.getElementById("divView");
|
||||
if (!element) {
|
||||
alert("无法找到id为" + id + "的div 或 span 标签。");
|
||||
return;
|
||||
}
|
||||
else {
|
||||
element.innerHTML = "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 加载视频
|
||||
* @param {DataInfo} datainfo 数据信息
|
||||
*/
|
||||
function jsLoadVideo(videoName,videoTitle) {
|
||||
var divVideoPlayer = document.querySelector("#divVideoPlayer");
|
||||
var btnClose = document.querySelector("#btnClose");
|
||||
var vdMain = document.querySelector("#vdPlayer");
|
||||
var vSource = document.querySelector("#vdSource");
|
||||
var vdTitle = document.querySelector("#vdTitle");
|
||||
vSource.src = "StreamingAssets/Video/" + videoName;
|
||||
vdMain.load();
|
||||
divVideoPlayer.style.display = "block";
|
||||
btnClose.style.display = "block";
|
||||
vdTitle.innerHTML = videoTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 加载图像
|
||||
* @param {DataInfo} datainfo 数据信息
|
||||
*/
|
||||
function jsLoadImage(datainfo) {
|
||||
var imgMain = document.querySelector("#imgMain");
|
||||
imgMain.src = "Content/Images/" + datainfo.DataName;
|
||||
|
||||
// 如果包含音频,则显示音频播放按钮
|
||||
if (datainfo.DataDetails.length > 1) {
|
||||
var auSource = document.querySelector("#auSource");
|
||||
auSource.src = "Content/Audios/" + datainfo.DataDetails[1];
|
||||
var btnPlay = document.querySelector("#btnPlay");
|
||||
btnPlay.style.display = "block";
|
||||
}
|
||||
|
||||
$('#modal').fadeIn(500);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 图文
|
||||
* @param {string} audioName 音频名称
|
||||
* @param {string} imageName 图片名称
|
||||
*/
|
||||
function jsLoadImageText(audioName, imageName) {
|
||||
var adMain = document.querySelector("#adMain");
|
||||
var aSource = document.querySelector("#aSource");
|
||||
aSource.src = "Content/Audios/" + audioName;
|
||||
// 这里图片应该动态添加,目前是在imageText.html写死
|
||||
$('#imgText').attr('src', 'Content/Images/' + imageName);
|
||||
adMain.load();
|
||||
$('#modal').fadeIn(500);
|
||||
setTimeout(function () {
|
||||
if (!isIOSBrowser()) {
|
||||
adMain.play();
|
||||
}
|
||||
}, 500);
|
||||
}
|
||||
|
||||
function jsLoadComicStrip(comicStripName) {
|
||||
$('#comic').attr('src', 'Content/Images/' + comicStripName);
|
||||
$('#modal').fadeIn(500);
|
||||
}
|
||||
|
||||
function jsLoadUrl(url) {
|
||||
window.open(url, "_blank");
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 判断浏览器是否竖屏
|
||||
*/
|
||||
function jsIsBroswerSP() {
|
||||
return window.orientation === 180 || window.orientation === 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 判断是否苹果浏览器
|
||||
*/
|
||||
function jsIOSBroswer() {
|
||||
var UA = navigator.userAgent;
|
||||
if (UA.match(/iPad/) || UA.match(/iPhone/) || UA.match(/iPod/)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 获取平台的类型
|
||||
* @return 0:Unity编辑器,1:非IOS平台,2:IOS平台
|
||||
*/
|
||||
function jsGetPlatformType() {
|
||||
|
||||
return isIOSBrowser() ? 2 : 1;
|
||||
}
|
||||
|
||||
function jsIsWXBrowser()
|
||||
{
|
||||
var ua = navigator.userAgent.toLowerCase();
|
||||
var isWeixin = ua.indexOf('micromessenger') != -1;
|
||||
if (isWeixin) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 设置全屏显示
|
||||
*/
|
||||
function jsSetFullScreen() {
|
||||
unityInstance.SetFullscreen(1);
|
||||
//canvas.requestFullscreen();
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 判断是否为移动端浏览器
|
||||
*/
|
||||
function jsIsMobileBroswerSP() {
|
||||
if (/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 关闭按钮单击事件
|
||||
*/
|
||||
function onBtnCloseClick() {
|
||||
//jsHideView();
|
||||
var divVideoPlayer = document.querySelector("#divVideoPlayer");
|
||||
var btnClose = document.querySelector("#btnClose");
|
||||
var vdMain = document.querySelector("#vdPlayer");
|
||||
vdMain.pause();
|
||||
divVideoPlayer.style.display = "none";
|
||||
btnClose.style.display = "none";
|
||||
gameInstance.SendMessage("H5Receiver", "HideView", "");
|
||||
}
|
||||
|
||||
// 是否为最大化
|
||||
var isModalMax = false;
|
||||
/**
|
||||
* @description 最大化按钮单击事件
|
||||
*/
|
||||
function onBtnMaxClick() {
|
||||
isModalMax = !isModalMax;
|
||||
if (isModalMax) {
|
||||
$('#modal').removeClass('center-modal');
|
||||
$('#modal').addClass('maxmize-modal');
|
||||
$('#modal').fadeIn(500);
|
||||
}
|
||||
else {
|
||||
$('#modal').removeClass('maxmize-modal');
|
||||
$('#modal').addClass('center-modal');
|
||||
$('#modal').fadeIn(500);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 音频播放按钮单击事件
|
||||
*/
|
||||
function onBtnPlayClick() {
|
||||
console.log("play");
|
||||
var auMain = document.querySelector("#auMain");
|
||||
var btnPlay = document.querySelector("#btnPlay");
|
||||
|
||||
if (auMain.paused) {
|
||||
btnPlay.style.backgroundImage = "url('../images/ui/pause.png')";
|
||||
auMain.load();
|
||||
auMain.play();
|
||||
}
|
||||
else {
|
||||
btnPlay.style.backgroundImage = "url('../images/ui/play.png')";
|
||||
auMain.pause();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 关闭按钮单击事件
|
||||
*/
|
||||
function onBtnSkipClick() {
|
||||
|
||||
// jsLoadVideo("ZT0_3_1(台湾名称的由来).mp4");
|
||||
|
||||
vdMain.pause();
|
||||
//vdMain.removeAttribute('src')
|
||||
vdMain.remove();
|
||||
|
||||
document.getElementById('boxProgress').style.display = "block";
|
||||
btnSkip.style.display = "none";
|
||||
|
||||
warningBanner.remove();
|
||||
|
||||
if (newProgress > 100) {
|
||||
hideLoadingBar();
|
||||
gameInstance.SendMessage("H5Receiver", "EnterGame", "");
|
||||
}
|
||||
else {
|
||||
logo.style.backgroundImage = "url('images/loadingTW.jpg')";
|
||||
showImages();
|
||||
}
|
||||
}
|
||||
7
Assets/WebGLTemplates/SGTemplate/js/dataProcess.js.meta
Normal file
7
Assets/WebGLTemplates/SGTemplate/js/dataProcess.js.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 73c38f62870ef5d4ab750f0c1908489f
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
2
Assets/WebGLTemplates/SGTemplate/js/jquery-3.6.1.min.js
vendored
Normal file
2
Assets/WebGLTemplates/SGTemplate/js/jquery-3.6.1.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 04c90775e6368e14ab0b58e15ef00b9f
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
87
Assets/WebGLTemplates/SGTemplate/js/loadProcess.js
Normal file
87
Assets/WebGLTemplates/SGTemplate/js/loadProcess.js
Normal file
@@ -0,0 +1,87 @@
|
||||
var index = 1;
|
||||
var newProgress;
|
||||
var opa = 1;
|
||||
var loadImg = true;
|
||||
|
||||
|
||||
function setOldProgresss(percent) {
|
||||
newProgress = Math.floor(percent * 100);
|
||||
setProgress(newProgress);
|
||||
}
|
||||
|
||||
function setProgress(percent) {
|
||||
var box = document.getElementById('boxProgress');
|
||||
var bar = document.getElementById('bar');
|
||||
var text = document.getElementById('text');
|
||||
|
||||
var allWidth = window.innerWidth; // parseInt(getStyle(box, 'width'));
|
||||
|
||||
bar.innerHTML = percent + '%';
|
||||
text.innerHTML = percent + '%';
|
||||
|
||||
bar.style.clip = 'rect(0px, ' + percent / 100 * allWidth + 'px, 40px, 0px)';
|
||||
};
|
||||
|
||||
function getStyle(obj, attr) {
|
||||
if (obj.currentStyle) {
|
||||
return obj.currentStyle[attr];
|
||||
} else {
|
||||
return getComputedStyle(obj, false)[attr];
|
||||
}
|
||||
}
|
||||
|
||||
var cusCount = 0;
|
||||
var endOfVideo = false;
|
||||
function progressCustom() {
|
||||
// newProgress += Math.floor(Math.random() * 10);
|
||||
cusCount++;
|
||||
if (cusCount == 5) {
|
||||
newProgress = 101;
|
||||
};
|
||||
|
||||
if (newProgress > 100) {
|
||||
setProgress(100);
|
||||
|
||||
loadImg = false;
|
||||
}
|
||||
else {
|
||||
setProgress(newProgress);
|
||||
setTimeout("progressCustom()", 420);
|
||||
}
|
||||
}
|
||||
|
||||
function hideLoadingBar() {
|
||||
opa -= 0.1;
|
||||
loadingBar.style.opacity = opa;
|
||||
if (opa <= 0) {
|
||||
loadingBar.style.display = "none";
|
||||
}
|
||||
else {
|
||||
setTimeout("hideLoadingBar()", 100);
|
||||
}
|
||||
}
|
||||
|
||||
function showImages() {
|
||||
|
||||
if (newProgress > 100) {
|
||||
hideLoadingBar();
|
||||
gameInstance.SendMessage("H5Receiver", "EnterGame", "");
|
||||
}
|
||||
else {
|
||||
if (loadImg) {
|
||||
setTimeout("showImages()", 2000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function stretchScreen() {
|
||||
var width = window.innerWidth;
|
||||
var height = window.innerHeight;
|
||||
// console.log(width + "," + height);
|
||||
|
||||
canvas.style.width = width + "px";
|
||||
canvas.style.height = height + "px";
|
||||
|
||||
loadingBar.style.width = width + "px";
|
||||
loadingBar.style.height = height + "px";
|
||||
}
|
||||
7
Assets/WebGLTemplates/SGTemplate/js/loadProcess.js.meta
Normal file
7
Assets/WebGLTemplates/SGTemplate/js/loadProcess.js.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3892824547c20e148ae5fd6ca3b9cc7d
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
31
Assets/WebGLTemplates/SGTemplate/js/screenProcess.js
Normal file
31
Assets/WebGLTemplates/SGTemplate/js/screenProcess.js
Normal file
@@ -0,0 +1,31 @@
|
||||
stretchScreen();
|
||||
|
||||
var mask = document.querySelector("#mask");
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD>ĺ<EFBFBD><C4BA><EFBFBD>
|
||||
function handlePortraitOfMobile() {
|
||||
if (window.orientation === 180 || window.orientation === 0) {
|
||||
mask.style.display = "block";
|
||||
} else {
|
||||
mask.style.display = "none";
|
||||
|
||||
setTimeout("stretchScreen()", 200); // <20><>ʱ<EFBFBD><CAB1><EFBFBD>ܻ<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>º<EFBFBD><C2BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
}
|
||||
}
|
||||
|
||||
// <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<D7B4><CCAC><EFBFBD><EFBFBD>
|
||||
handlePortraitOfMobile();
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>л<EFBFBD><D0BB>¼<EFBFBD>
|
||||
window.addEventListener("orientationchange", handlePortraitOfMobile);
|
||||
window.addEventListener("resize", handlePortraitOfMobile);
|
||||
|
||||
//var evt = "onorientationchange" in window ? "orientationchange" : "resize";
|
||||
//window.addEventListener(evt, function () {
|
||||
// // <20><><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD>״̬<D7B4><CCAC><EFBFBD><EFBFBD>
|
||||
// handlePortraitOfMobile();
|
||||
//}, false);
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7401d4f20c7647e4496908d86a517ae6
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user